Non type-variable argument in the constraint error on Haskell map function

前端 未结 2 1016
猫巷女王i
猫巷女王i 2021-02-14 08:35

I am writing a function called mapper2 that applies a function to two lists:

mapper2 :: (a-> b -> c) -> [a] -> [b] -> [c]
mapper2 f (         


        
2条回答
  •  悲&欢浪女
    2021-02-14 09:06

    Look at mapper2's type.

    mapper2 :: (a -> b -> c) -> [a] -> [b] -> [c]
    

    Now look at the type of the function you're passing in.

    (\x -> x * 2) :: Num a => a -> a
    

    The mapper2 function expects a function of two arguments to be passed in, but your lambda only takes one argument.

提交回复
热议问题