Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why did my mistake annotating this type signature not break things?

I had defined an alias for the function execState:

myCleverName = execState

GHC warned about a top-level binding with no annotated type signature, so I'd written:

myCleverName :: State s a => s -> s

Immediately obvious to most of you is that "fat arrow" => should have just been a regular skinny one ->. But I only just noticed that today, yet both the module containing the alias and the code using the alias have been compiling fine for weeks, with not so much as a warning that I used the wrong syntax. Why is that?

Thanks!

like image 526
J Cooper Avatar asked Feb 11 '23 22:02

J Cooper


1 Answers

GHC 7.6.3 had a bug that allowed things like this but it's fixed (or should be) in GHC 7.8. Internally, type class constraints are represented as implicit function arguments and I think that's why 7.6.3 was confused. They still are represented that way, but the sanity checking has been improved.

like image 129
David Young Avatar answered May 19 '23 00:05

David Young