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

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


Ah, thanks for the explanation. I hadn't heard of ExtendedDefaultRules
before.

Peter


On 8 June 2013 14:35, Brandon Allbery <allbery.b at gmail.com> wrote:

> On Sat, Jun 8, 2013 at 9:02 AM, Peter Hall <peter.hall at memorphic.com>wrote:
>
>> 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
>>
>
>  No bug; it's the monomorphism restriction combining with extended
> defaulting to infer a monomorphic type. If you want to keep the
> monomorphism restriction and throw a type error, disable
> ExtendedDefaultRules.
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130608/e4928352/attachment.htm>


More information about the Beginners mailing list