Last active
August 29, 2015 14:06
-
-
Save skatenerd/d147c77cfa5aae2d805b to your computer and use it in GitHub Desktop.
histogram. implement writer in terms of state monad?
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
first :: State [String] Int | |
first = state $ \initialstate -> (0, initialstate) | |
appender to_emit to_append = (state $ \lateststate -> (to_emit, (show to_append):lateststate)) | |
histogram = do | |
firstanswer <- first | |
secondanswer <- appender "HI" firstanswer | |
appender 876 secondanswer | |
main = let foo = runState histogram [] | |
in putStrLn $ show foo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment