パターンマッチングを行う必要のある2つの引数を持つ関数があります。最初のパターンでカリー化を使用すると、コンパイルされません。
drop' :: Int -> [a] -> [a]
drop' 0 = id -- ghci: "Equations for drop' have different numbers of arguments"
drop' n (x:xs) = drop' (n-1) xs
コンパイラは次の出力を提供します。
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.
ただし、カレーパターンのみを指定すると、コンパイルされます。
drop' :: Int -> [a] -> [a]
drop' 0 = id -- compiles
何が得られますか?