Haskell 混合{,非}点自由函数定义子句失败

Haskell 混合{,非}点自由函数定义子句失败,haskell,Haskell,像这样的定义 mergeLists :: Ord a => [a] -> [a] -> [a] mergeLists [] = id mergeLists l [] = l mergeLists (x:xs) (y:ys) = if y < x then y : mergeLists (x:xs) ys else x : mergeLists xs (y:ys) 当问题行被重写为mergeLists[]l=l时,错误消失了 Haskell是否禁止在单个函

像这样的定义

mergeLists :: Ord a => [a] -> [a] -> [a]
mergeLists [] = id
mergeLists l [] = l
mergeLists (x:xs) (y:ys) = if y < x
    then y : mergeLists (x:xs) ys
    else x : mergeLists xs (y:ys)
当问题行被重写为
mergeLists[]l=l
时,错误消失了


Haskell是否禁止在单个函数定义中混合使用无点子句和非无点子句?

通过此方法在Haskell中定义函数时,每个声明必须具有相同数量的参数。这是因为可能的打字错误和更容易的模式匹配

由于第一行仅包含一个参数,
[]
,因此会导致错误,因为所有其他定义都包含两个参数


在这种特殊情况下,这是禁止混合有点和无点样式的,是的,但似乎是为了避免前面提到的打字错误。

从两个建议问题中,“定义函数[…]”一个重点是“为什么”,而“参数数量[…]”一个重点是“如何”。
MergeLists.hs:3:1: error:
    Equations for ‘mergeLists’ have different numbers of arguments
      MergeLists.hs:3:1-18
      MergeLists.hs:4:1-19
  |
3 | mergeLists [] = id
  | ^^^^^^^^^^^^^^^^^^...