超级基本问题 - 但我似乎无法得到明确的答案。下面的函数将无法编译:基本的Haskell函数类型?
randomfunc :: a -> a -> b
randomfunc e1 e2
| e1 > 2 && e2 > 2 = "Both greater"
| otherwise = "Not both greater"
main = do
let x = randomfunc 2 1
putStrLn $ show x
我很困惑,为什么这不起作用。这两个参数都是类型'a'(Ints),返回参数是类型'b'(字符串)?
错误:
"Couldn't match expected type ‘b’ with actual type ‘[Char]’"