Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Is this a GHC bug? Problem inferring type (Peter Hall)
   2. Re:  Is this a GHC bug? Problem inferring type (Brandon Allbery)
   3. Re:  Is this a GHC bug? Problem inferring type (Peter Hall)
   4. Re:  Is this a GHC bug? Problem inferring type (Michael Peternell)
   5. Re:  Is this a GHC bug? Problem inferring type (Brandon Allbery)
   6. Re:  Is this a GHC bug? Problem inferring type (Peter Hall)
   7. Re:  Is this a GHC bug? Problem inferring type (Graham Gill)


----------------------------------------------------------------------

Message: 1
Date: Sat, 8 Jun 2013 14:02:02 +0100
From: Peter Hall <[email protected]>
Subject: [Haskell-beginners] Is this a GHC bug? Problem inferring type
To: "[email protected]" <[email protected]>
Message-ID:
        <CAA6hAk4LupBkJh=0UyFTPqx=hw--bnri2kcxmyjthjdul+u...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

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-0001.htm>

------------------------------

Message: 2
Date: Sat, 8 Jun 2013 09:35:52 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Is this a GHC bug? Problem inferring
        type
To: Peter Hall <[email protected]>,      The Haskell-Beginners
        Mailing List - Discussion of primarily  beginner-level topics related
        to Haskell <[email protected]>
Message-ID:
        <cakfcl4ue_0ozbycjafr1qexhz_e23qs7mswoxjw3uertprs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sat, Jun 8, 2013 at 9:02 AM, Peter Hall <[email protected]> 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
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130608/3c65d193/attachment-0001.htm>

------------------------------

Message: 3
Date: Sat, 8 Jun 2013 14:39:31 +0100
From: Peter Hall <[email protected]>
Subject: Re: [Haskell-beginners] Is this a GHC bug? Problem inferring
        type
To: Brandon Allbery <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <caa6hak5delnnfn5teldcjtss8r+rwfdaech-qqrgq8ofknq...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

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

Peter


On 8 June 2013 14:35, Brandon Allbery <[email protected]> wrote:

> On Sat, Jun 8, 2013 at 9:02 AM, Peter Hall <[email protected]>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
> [email protected]
> [email protected]
> 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-0001.htm>

------------------------------

Message: 4
Date: Sat, 8 Jun 2013 20:54:44 +0200
From: Michael Peternell <[email protected]>
Subject: Re: [Haskell-beginners] Is this a GHC bug? Problem inferring
        type
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

in my opinion this is a bug of ghc. maybe the implementation works exactly as 
it should, according to the specification: then it's a bug in the specification.

Show a => a -> a -> String
just makes much much more sense than
() -> () -> String
which makes no sense at all imho

and i think it would be possible to infer the type in this case.

++ :: [a] -> [a] -> [a]
show :: Show e => e -> String
on :: (b -> b -> c) -> (d -> b) -> d -> d -> c

on (++) show :: d -> d -> c
(++) :: [a] -> [a] -> [a] = b -> b -> c
-> b = c = [a]
show :: Show e => e -> String = (d -> b)
-> b = String, Show d
-> c = String, a = Char

on (++) show :: Show d => d -> d -> String

is it really not possible to write an algorithm that can deduce this kind of 
stuff?

Am 08.06.2013 um 15:35 schrieb Brandon Allbery <[email protected]>:

> On Sat, Jun 8, 2013 at 9:02 AM, Peter Hall <[email protected]> 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
> [email protected]                                  [email protected]
> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners




------------------------------

Message: 5
Date: Sat, 8 Jun 2013 15:33:50 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Is this a GHC bug? Problem inferring
        type
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <CAKFCL4XP55S4_z-T=jp_o27heznxacagvenmlncefdgn8qo...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sat, Jun 8, 2013 at 2:54 PM, Michael Peternell
<[email protected]>wrote:

> in my opinion this is a bug of ghc. maybe the implementation works exactly
> as it should, according to the specification: then it's a bug in the
> specification.
>
> Show a => a -> a -> String
>

...is not monomorphic. If you want that to be inferred, turn off the
monomorphism restriction. (And yes, many people *do* consider the
monomorphism restriction of standard Haskell to be a bug in the
specification.)

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130608/15585ae7/attachment-0001.htm>

------------------------------

Message: 6
Date: Sat, 8 Jun 2013 21:11:13 +0100
From: Peter Hall <[email protected]>
Subject: Re: [Haskell-beginners] Is this a GHC bug? Problem inferring
        type
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <CAA6hAk4Xo-b7-Z0iMZNuuBK96y7d6Xt8323wUc1ysJEOa=q...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

>
>> Show a => a -> a -> String
>>
>
> ...is not monomorphic. If you want that to be inferred, turn off the
> monomorphism restriction. (And yes, many people *do* consider the
> monomorphism restriction of standard Haskell to be a bug in the
> specification.)
>
>
When are we due a new spec? 1998 was quite a while ago...

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

------------------------------

Message: 7
Date: Sat, 08 Jun 2013 16:15:53 -0400
From: Graham Gill <[email protected]>
Subject: Re: [Haskell-beginners] Is this a GHC bug? Problem inferring
        type
To: [email protected],   The Haskell-Beginners Mailing List -
        Discussion of primarily beginner-level topics related to Haskell
        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"

On 08/06/2013 4:11 PM, Peter Hall wrote:
>
>
>         Show a => a -> a -> String
>
>
>     ...is not monomorphic. If you want that to be inferred, turn off
>     the monomorphism restriction. (And yes, many people *do* consider
>     the monomorphism restriction of standard Haskell to be a bug in
>     the specification.)
>
>
> When are we due a new spec? 1998 was quite a while ago...
>
> Peter

2010 <http://www.haskell.org/haskellwiki/Haskell_2010>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130608/498769a1/attachment.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 60, Issue 14
*****************************************

Reply via email to