Created
August 29, 2011 17:36
-
-
Save qzchenwl/1178905 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- file: ch15/Supply.hs | |
next = S $ do st <- get | |
case st of | |
[] -> return Nothing | |
(x:xs) -> do put xs | |
return (Just x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@md2perpe This is an example from Real World Haskell.
The
get
is defined as:The
(>>=)
is defined as:We can apply function
(\s -> let (a, s') = runState m s ...)
onst
, sost
must have type ofs
forState s a
In the Supply example,
State [a] (Maybe a)
... I think I know...