[Haskell-beginners] Change in type that I don't understand

David McBride toad3k at gmail.com
Fri Jan 27 13:35:08 UTC 2017


If you have the Monomorphism restriction set, it will choose types
based on the type defaulting rules (Num changes to Integer).  This is
because polymorphic code is slower than code that has concrete types.

Try :set -XNoMonomorphismRestriction, then test it again.

It may be that different versions of ghci have a different default for
that pragma.

On Fri, Jan 27, 2017 at 6:23 AM, Jan Erik Moström <lists at mostrom.pp.se> wrote:
> Hi,
>
> Here is something that I don't understand, why does the named value have a
> different type than just the value itself?
>
> Prelude> let f x = x * x
> Prelude> :t f
> f :: Num a => a -> a
> Prelude> :t [f]
> [f] :: Num a => [a -> a]
> Prelude> let g = [f]
> Prelude> :t g
> g :: [Integer -> Integer]
>
> = jem
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


More information about the Beginners mailing list