[Haskell-cafe] How does GHC's implementation of par work?
batterseapower at hotmail.com
Tue May 26 20:32:35 EDT 2009
2009/5/26 Ryan Ingram <ryani.spam at gmail.com>:
> What causes par# to
> get executed? Does GHC overload case for unboxed return values to
> force the evaluation of the scrutinee even if its return value isn't
As you noted, the type of "par" is a -> Int#. Furthermore, the only
possible evaluation semantics for unboxed types in GHC's intermediate
language is strict. This means that your case expression has to
evaluate the scrutinee eagerly.
Indeed, consider the following program (which looks even lazier than
let x :: Int# = error "boom!"
This will diverge in either Haskell or Core, because both languages
promise that if have an unlifted thing in your environment /it really
has been evaluated/. SPJ and I recently wrote a paper  proposing an
intermediate language for GHC that would allow Core to express thunks
of unlifted types, but even so I don't think we would actually want to
change the semantics of bindings of unlifted types in Haskell.
More information about the Haskell-Cafe