Skip to content

Instantly share code, notes, and snippets.

@mstksg
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstksg/aa70c9182c387e6f67b1 to your computer and use it in GitHub Desktop.
Save mstksg/aa70c9182c387e6f67b1 to your computer and use it in GitHub Desktop.
Home-made IO+State Monad
andThen :: (s -> IO (a, s)) -> (s -> IO (b, s)) -> (s -> IO (b, s))
andThenWith :: (s -> IO (a, s)) -> (a -> (s -> IO (b, s))) -> (s -> IO (b, s))
-- type synonym:
--
-- > type MIOS s a = s -> IO (s, a)
--
-- lets us write the above as:
--
-- andThen :: MIOS s a -> MIOS s b -> MIOS s b
-- andThenWith :: MIOS s a -> (a -> MIOS s b) -> MIOS s b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment