Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
histogram. implement writer in terms of state monad?
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