Haskell 中函数的非详尽模式

Non-exhaustive pattern in function in Haskell

我有一个 class Evol 并希望将 distanceMatrix 实例应用于我的类型 MolSeq 的列表。函数 molseqDistMat 按预期工作,但我无法理解在尝试 运行 distanceMatrix [Molseq] 时遇到的错误。我明白错误的意思,但我找不到异常。这是错误。

*F2> distanceMatrix l
*** Exception: lab2.hs:79:3-43: Non-exhaustive patterns in function 
distanceMatrix

这是代码。

class Evol a where
  distanceMatrix :: [a] -> [(String, String, Double)]

instance Evol MolSeq where
  distanceMatrix [a] = molseqDistMat [a] [] -- <- Line 79

molseqDistMat :: [MolSeq] -> [(String, String, Double)] -> [(String, 
String, Double)]
molseqDistMat todo res
  | null (tail todo) = res
  | otherwise = molseqDistMat (tail todo) (res++(doRow (head todo) (tail 
todo) []))

doRow :: MolSeq -> [MolSeq] -> [(String, String, Double)] -> [(String, 
String, Double)]
doRow mol rest result
  | null rest = reverse result
  | otherwise = doRow mol (tail rest) ((name mol, name (head rest), 
distance mol (head rest)):result)

你可能想要:

distanceMatrix xs = molseqDistMat xs [] -- <- Line 79

[a] 是一种匹配恰好包含一个元素的列表的模式。