Haskell 我不断地得到;函数isPermutation中的非穷举模式;当我有所有可能的病例时?

Haskell 我不断地得到;函数isPermutation中的非穷举模式;当我有所有可能的病例时?,haskell,permutation,Haskell,Permutation,我正在尝试创建一个使用两个列表的函数。出于某种原因,当我通过时: isPermutation[]],或[][1,2,3]或[1,2,3][]- 我在函数isPermutation中得到了非穷举模式 isPermutation :: (Eq a)=>[a]->[a]->Bool **isPermutaiton** [] [] = True **isPermutaiton** [] ys = False **isPermutation** xs [] = False isPermu

我正在尝试创建一个使用两个列表的函数。出于某种原因,当我通过时:

isPermutation[]],或[][1,2,3]或[1,2,3][]- 我在函数isPermutation中得到了非穷举模式

isPermutation :: (Eq a)=>[a]->[a]->Bool
**isPermutaiton** [] [] = True
**isPermutaiton** [] ys = False
**isPermutation** xs [] = False
isPermutation (x:xs) (ys) = True
我不明白为什么我会得到这个,因为我涵盖了所有的案件

更新 *感谢克里斯·泰勒:-这是一个简单的打字错误。我把一个函数名“ispermutaton”而不是“isPermutation”拼错了*


请注意拼写,因为Haskell不会意识到您的意思是同一个函数(duh),或者您正在“声明”两个不同的函数,且大小写错开。

您的第二行和第三行有一个打字错误--
ispermutaton
而不是
isPermutation

你已经有效地定义了

foo [] [] = True       -- both arguments empty
foo [] ys = False      -- first argument empty, second argument anything

bar  xs    [] = False  -- second argument empty, first argument anything
bar (x:xs) ys = True   -- first argument at least one element, second anything

因此,无论何时使用非空的第一个参数调用
foo
(即
ispermutaton
),您都会得到一个错误;无论何时使用空的第一个参数和非空的第二个参数调用
bar
(即
isPermutation
),您都会得到一个错误。

如果显示有问题的代码,如果有人给了你解决方案,不要编辑它来消除错误。添加一个更新来解释错误,并(如果您愿意)添加一个固定代码外观的示例。但是要保留原来的错误,这样人们就可以从你的问题中正确地学习。另外还添加了解释。如果在给函数提供与实现分离的类型签名时出现警告,那将非常有用,因为我在过去曾多次被这种警告所困扰。有人知道有没有办法打开这样的警告?