Created
July 22, 2016 10:38
-
-
Save berdario/12515c23556b3fba751c2582d330b382 to your computer and use it in GitHub Desktop.
State monad does not force ordering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.State (execState, get, modify) | |
import Debug.Trace (trace) | |
foo :: IO () | |
foo = do | |
(x, y) <- pure $ flip execState (1,1) $ do | |
(x, y) <- get | |
modify (\(x, y) -> (trace "x1" (x+1), (trace "y1" y))) | |
(x, y) <- get | |
modify (\(x, y) -> (trace "x2" x, trace "y2" (y*3))) | |
print y | |
print x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment