seq vs. rnf in Haskell

Viewed 411

According to the definitions given by "Parallel and Concurrent Programming in Haskell" on page 29, the class method "return normal form" is defined as:

rnf a = a `seq` ()

Just to see if wrapping seq in another function, as the authors prescribe, really had the result of forcing 'a' to be evaluated to normal form, I tried implementing the function myself and got a result in the negative:

Prelude Control.DeepSeq > myrnf a = a `seq` ()
Prelude Control.DeepSeq > xs = map (+1) [1..10] :: [Int]
Prelude Control.DeepSeq > :sprint xs
xs = _
Prelude Control.DeepSeq > myrunf xs
()
Prelude Control.DeepSeq > :sprint xs
xs = _ : _
Prelude Control.DeepSeq > rnf xs
()
Prelude Control.DeepSeq > :sprint xs
xs = [2,3,4,5,6,7,8,9,10,11]

So have the authors made a glaring mistake, or am I missing something here?

Edit: I realised my original question contained elementary mistakes. Here is the proper form of the question.

1 Answers
Related