Sibi
Sibi

Reputation: 48644

Replacing => in place of -> in function type signature

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.

Upvotes: 9

Views: 300

Answers (2)

Jakub Arnold
Jakub Arnold

Reputation: 87210

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.

Upvotes: 1

Dominique Devriese
Dominique Devriese

Reputation: 3093

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.

Upvotes: 11

Related Questions