4 ms·
I don't agree. Bind creates a data dependence that forces an evaluation order. do x <- f y <- g x No matter what Monad you're speaking of, i
by bad_user 6y ago
I don't agree. Bind creates a data dependence that forces an evaluation order.
do
x <- f
y <- g x
No matter what Monad you're speaking of, in this expression "x" is going to be evaluated before "y", what we sometimes call a happens before relationship, because evaluating "y" depends on evaluating "x".
- ImprobableTruth 6y agoUnless you're using some non-standard definition of evaluation, this is not true when using a lazy strategy. Consider the term ((const c) x) for g x which reduces to c without ever evaluating x.
- tome 6y agoWhat are you basing your disagreement on? Can you explain to me in which sense "x" is evaluated before "y" in this example? {-# LANGUAGE BangPatterns #-} import Data.Functor.Identity import Debug.Trace f = let !_ = trace "Evaluating f" () in return 1 g x = let !_ = trace "Evaluating g" () in return (x + 1) example :: Int example = runIdentity $ do x <- f y <- g x return y > example Evaluating g Evaluating f 2