Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

haskell

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.

like image 519
Sibi Avatar asked Jun 02 '14 07:06

Sibi


2 Answers

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.

like image 132
Dominique Devriese Avatar answered Sep 22 '22 00:09

Dominique Devriese


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.

like image 31
Jakub Arnold Avatar answered Sep 21 '22 00:09

Jakub Arnold