[Haskell-cafe] To seq or not to seq, that is the question
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sat Mar 9 09:34:41 CET 2013
On Fri, Mar 08, 2013 at 08:53:15PM -0800, Edward Z. Yang wrote:
> Are these equivalent? If not, under what circumstances are they not
> equivalent? When should you use each?
>
> evaluate a >> return b
[...]
> - Use 'evaluate' when you mean to say, "Evaluate this thunk to HNF
> before doing any other IO actions, please." Use it as much as
> possible in IO.
I've never looked at evaluate before but I've just found it's haddock and
given it some thought.
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception-Base.html#v:evaluate
Since it is asserted that
evaluate x = (return $! x) >>= return
is it right to say (on an informal level at least) that evaluating an IO
action to WHNF means evaluating it to the outermost >>= or return?
> For non-IO monads, since everything is imprecise anyway, it doesn't
> matter.
Could you explain what you mean by "imprecise"?
Tom
More information about the Haskell-Cafe
mailing list