为什么我可以在模式匹配中讨论其中一种模式而不是另一种模式?

Gui*_*ern 10 haskell currying pattern-matching

我有一个函数有两个参数,我必须模式匹配.如果我在第一个模式上使用currying它将无法编译:

  drop' :: Int -> [a] -> [a] 
  drop' 0  = id -- ghci: "Equations for drop' have different numbers of arguments"
  drop' n (x:xs) = drop' (n-1) xs
Run Code Online (Sandbox Code Playgroud)

编译器提供此输出:

99.hs:106:3:
Equations for drop' have different numbers of arguments
  99.hs:106:3-15
  99.hs:107:3-33
In an equation for `split':
    split xs n
      = (take' n xs, drop' n xs)
      where
          take' 0 _ = []
          take' n (x : xs) = x : take (n - 1) xs
          drop' 0 = id
          drop' n (x : xs) = drop' (n - 1) xs  
 Failed, modules loaded: none.
Run Code Online (Sandbox Code Playgroud)

但是,如果我只给出咖喱图案,那么它会编译:

  drop' :: Int -> [a] -> [a] 
  drop' 0  = id -- compiles
Run Code Online (Sandbox Code Playgroud)

是什么赋予了?

Kot*_*lar 10

我能找到的唯一解释(http://www.haskell.org/pipermail/haskell-cafe/2009-March/058456.html):

问题主要是语法上的,在某种意义上,大多数具有不同参数的定义都是普通的错别字.另一个可能是实现问题:它使模式匹配规则更复杂.