I just observed that if instead of ->
, I write =>
in the type signature definition of a function, it doesn't result in an compile time error. Example code:
mysum :: Num a => [a] => a -- Notice => after the list [a]
mysum [] = 0
mysum (x:xs) = x + mysum xs
Why does this happen ? And is there a way to avoid this ?
Compiler Used: GHC 7.6.2
Update: Successful compilation in ideone.
This is a bug in GHC 7.6.2. You should try it in the most recent compiler and if it still doesn't give an error there, then you should file a bug report.
Actually, I think this bug is already known and fixed in GHC 7.8.
This seems to be fixed in 7.8.2
foo.hs:1:19:
Expected a constraint, but ‘[a]’ has kind ‘*’
In the type signature for ‘mysum’: mysum :: Num a => [a] => a
I would assume it's just a bug specific to 7.6.x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With