[Haskell-beginners] Is this a GHC bug? Problem inferring type

Peter Hall peter.hall at memorphic.com
Sat Jun 8 15:02:02 CEST 2013


This is confusing me, and I'm wondering if it's a compiler bug. I have this:

   foo = (++) `on` show

I'm expecting the type to be:

    foo :: Show a => a -> a -> String

But GHCI is inferring:

    foo :: () -> () -> String


If I explicitly provide a type annotation, or if I use
-XNoMonormorphismRestriction, then it all works fine. I would expect a
compile error if the type couldn't be inferred due to the Monomorphism
Restriction, but instead it has silently chosen the least useful type.

Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130608/a47f2c28/attachment.htm>


More information about the Beginners mailing list