The section "The seq
Function" on https://serokell.io/blog/haskell-to-core mentions that
The
seq
function, which forces evaluation of its argument to weak-head normal form, is desugared into a case-expression, relying on the fact that in Core, case-expressions are strict:
-- Haskell
seq a b
-- Core
case a of
_ -> b
But running the two versions of code in Haskell says otherwise, i.e. it seems that seq a b
is strict but case a of _ -> b
is not.
Is this a difference in semantics between Haskell and Core? If so, is there some rationale for the behavior in Haskell being different from Core?
case
is defined only to evaluate "as much as necessary" to determine the branch to take, though I don't know exactly how that's determined. That would be a semantic difference with Core, or at least a surface-levelcase
need not translate to an equivalentcase
in Core. I don't know where that's specified. $\endgroup$