Haskell函数中的非穷举模式

Haskell函数中的非穷举模式,haskell,non-exhaustive-patterns,Haskell,Non Exhaustive Patterns,我有一个类Evol,希望在我的类型MolSeq的列表上应用distanceMatrix的实例。molseqDistMat函数可以按预期工作,但我无法理解在尝试运行distanceMatrix[Molseq]时出现的错误。我理解错误的意思,但我找不到异常。这就是错误所在 *F2> distanceMatrix l *** Exception: lab2.hs:79:3-43: Non-exhaustive patterns in function distanceMatrix 这是代码

我有一个类Evol,希望在我的类型MolSeq的列表上应用distanceMatrix的实例。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)
类进化a,其中
距离矩阵::[a]->[(字符串,字符串,双精度)]
实例Evol MolSeq,其中
距离矩阵[a]=molseqDistMat[a][]-[(字符串,字符串,双精度)]->[(字符串,
字符串(双精度)]
molseqDistMat todo res
|空(尾部todo)=分辨率
|否则=molseqDistMat(尾部todo)(res++)(doRow(头部todo)(尾部
待办事项][]))
doRow::MolSeq->[MolSeq]->[(字符串,字符串,双精度)]->[(字符串,
字符串(双精度)]
多罗摩尔休息结果
|null rest=反向结果
|否则=doRow mol(尾座)(名称mol,名称(头座),
距离摩尔(头枕)):结果)
您可能需要:

distanceMatrix xs = molseqDistMat xs [] -- <- Line 79
distanceMatrix xs=molseqDistMat xs[]--您可能需要:

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

distanceMatrix xs=molseqDistMat xs[]——使用
-Wall
启用警告:您将在编译时发现这一点,GHC甚至会提供一个您的定义中未包含的列表示例。感谢您的提示!使用
-Wall
启用警告:您会在编译时发现这一点,GHC甚至会提供一个您的定义中未包含的列表示例。感谢您的提示!