我有一个带有两个参数的函数,我必须对其进行模式匹配。如果我在第一个模式上使用柯里化,它将无法编译:
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
是什么赋予了?