简体   繁体   中英

Haskell error, expected type

Im getting this error on this code!

esImpar :: Integer -> Bool
esImpar a = if (a mod 2) /= 0 then True
        else False

Error: Couldn't match expected type (Integer -> Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer' with actual type Integer

The function `a' is applied to three arguments,

but its type Integer' has none

In the first argument of (/=), namely (a mod fromIntegral 2)

In the expression: (a mod 2) /= 0

mod by itself is just a function, not an operator; you can use it as mod a 2 or infix as a `mod` 2 . (Here you are trying to use a as a function, as the error message says.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM