3 ms·
Indeed. And while monads provide a certain kind of sequence, it's important to remember that what is being sequenced is just some data dependencies—later effect
by nybble41 6y ago
Indeed. And while monads provide a certain kind of sequence, it's important to remember that what is being sequenced is just some data dependencies—later effects can depend on the result of earlier effect. The evaluation order can be completely different depending on the type of monad and how the data is actually used. For an extreme example, take the forward & backward state (or "Tardis") monad[1], or for that matter any monad that implements MonadFix (including IO). The fact that the code is written in some order using a monad does not imply that it gets evaluated in that same order.
[1] https://hackage.haskell.org/package/tardis-0.4.1.0/docs/Control-Monad-Tardis.html https://hackage.haskell.org/package/tardis-0.4.1.0/docs/Cont...