[Haskell-cafe] unsafeInterleaveIO, lazyness and sharing
g9ks157k at acme.softbase.org
Tue Aug 26 19:48:49 EDT 2008
Haskell is non-strict but not necessarily lazy. So it’s possible that an
expression is reduced to WHNF although it is not used yet. Could this “early
reduction” also happen to outputs of unsafeInterleaveIO actions (which might
trigger the action too early)? While I’d expect those outputs to be
evaluated lazily (reduced as late as possible), I cannot find anything in the
docs that guarantees this.
In addition, I’d like to know whether unsafeInterleaveIO outputs are
guaranteed to be evaluated at most once so that the “interleaved action” is
executed at most once. Again, I suppose that this is the case while I cannot
find a guarantee for it.
More information about the Haskell-Cafe