This FAQ says that
The seq operator is
seq :: a -> b -> b
x
seq
y will evaluate x, enough to chec
Of course seq by itself does not "evaluate" anything. It just records the forcing order dependency. The forcing itself is triggered by pattern-matching. When seq x (f x)
is forced, x
will be forced first (memoizing the resulting value), and then f x
will be forced. Haskell's lazy evaluation means it memoizes the results of forcing of expressions, so no repeat "evaluation" (scary quotes here) will be performed.
I put "evaluation" into scary quotes because it implies full evaluation. In the words of Haskell wikibook,
"Haskell values are highly layered; 'evaluating' a Haskell value could mean evaluating down to any one of these layers."
Let me reiterate: seq
by itself does not evaluate anything. seq x x
does not evaluate x
under any circumstance. seq x (f x)
does not evaluate anything when f = id
, contrary to what the report seems to have been saying.