[Haskell-cafe] Eval forgotten unless type specified?

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sun Oct 19 08:43:13 UTC 2014


On Sat, Oct 18, 2014 at 11:32:46PM -0700, Jeffrey Brown wrote:
> In the below, however, :sprint shows them unevaluated both before and
> after
> the seq call.
> let x = 1 + 2
> let y = x + 1
> :sprint x
> :sprint y
> seq y ()
> :sprint x
> :sprint y
>
> Why?

Because you are using GHC 7.8 where the mmonomorphism restriction is not
imposed.  Without the monomorphism restriction `1 + 2` is of type `Num a =>
a`, not `Int`, and forcing it does not memoize the result.

Try running GHCi with `-XMonomorphismRestriction`.

Tom


More information about the Haskell-Cafe mailing list