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.  Inconsistencies in type inference (Stefan Jaax)
   2. Re:  Inconsistencies in type inference (David Virebayre)
   3. Re:  Inconsistencies in type inference (Brent Yorgey)
   4. Re:  Inconsistencies in type inference (Frerich Raabe)


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

Message: 1
Date: Tue, 25 Jun 2013 13:22:08 +0200
From: Stefan Jaax <[email protected]>
Subject: [Haskell-beginners] Inconsistencies in type inference
To: [email protected]
Message-ID:
        <CANb2C1q+_GbrgSEo9mRf87LUam+U=8efafhdbspwazmxaag...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hey,

While trying to wrap my head around how type inference works in haskell
I stumbled across the following inconsistency:

If I type
               :t (*)

in ghci, I obtain

                (*) :: Num a => a -> a -> a

But if I write

               let mul = (*)
               :t mul

I get the less generic type signature

               mul :: Integer -> Integer -> Integer

How is this inconsistency explained? After all, I would expect the haskell
compiler to deduce the most generic type possible.

Thanks in advance,
Stefan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130625/8cc08a73/attachment-0001.htm>

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

Message: 2
Date: Tue, 25 Jun 2013 13:36:26 +0200
From: David Virebayre <[email protected]>
Subject: Re: [Haskell-beginners] Inconsistencies in type inference
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <CAM_wFVudUb_5DqYw9kAboX=TrQju+aNAqgz+m0=32pmle18...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

The monomorphism restriction forces ghci to infer a default type.

Prelude> :set -XNoMonomorphismRestriction
Prelude> let mul = (*)
Prelude> :t mul
mul :: Num a => a -> a -> a



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

Message: 3
Date: Tue, 25 Jun 2013 14:45:50 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Inconsistencies in type inference
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

I should add that it is recommended to disable the monomorphism
restriction, by putting

  :set -XNoMonomorphismRestriction

in your .ghci file.  It has very dubious benefits and usually only
serves to confuse.

-Brent

On Tue, Jun 25, 2013 at 01:36:26PM +0200, David Virebayre wrote:
> The monomorphism restriction forces ghci to infer a default type.
> 
> Prelude> :set -XNoMonomorphismRestriction
> Prelude> let mul = (*)
> Prelude> :t mul
> mul :: Num a => a -> a -> a
> 
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners



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

Message: 4
Date: Wed, 26 Jun 2013 09:47:16 +0200
From: Frerich Raabe <[email protected]>
Subject: Re: [Haskell-beginners] Inconsistencies in type inference
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=ISO-8859-1; format=flowed

Am 6/25/2013 8:45 PM, schrieb Brent Yorgey:
> I should add that it is recommended to disable the monomorphism
> restriction, by putting
>
>    :set -XNoMonomorphismRestriction
>
> in your .ghci file.  It has very dubious benefits and usually only
> serves to confuse.

Hm, this is interesting. To me, most of the extensions are in the "crazy 
stuff only the profesionalls use" category - I successfully tip-toed 
around them so far. :-)

Are there other extensions which people would consider to be "generally 
good to have, unless you know a good reason *not* to enable them"?

-- 
Frerich Raabe - [email protected]
www.froglogic.com - Multi-Platform GUI Testing




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

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


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

Reply via email to