Eval forgotten unless type specified?

In this passage, after the seq call, :sprint reveals x and y to be evaluated: let x = 1 + 2 :: Int let y = x + 1 :sprint x :sprint y seq y () :sprint x :sprint y The above is a verbatim quote of Marlow's Concurrency book, chapter 2. 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?

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
participants (2)
-
Jeffrey Brown
-
Tom Ellis