Skip to content

Instantly share code, notes, and snippets.

@keizo042
Last active August 29, 2015 14:14
Show Gist options
  • Save keizo042/8e63910e55fcfd878c2c to your computer and use it in GitHub Desktop.
Save keizo042/8e63910e55fcfd878c2c to your computer and use it in GitHub Desktop.
import Control.Monad.Writer
sayHello :: Writer (Sum Int, Sum Int) String
sayHello = do
tell (0,1)
return "hello"
sayGoodbye :: Writer (Sum Int, Sum Int) String
sayGoodbye = do
tell (1,0)
return "goodbye"
tweeting = do
sayHello
sayHello
sayHello
sayHello
sayGoodbye
sayGoodbye
main :: IO ()
main = do
print $ runWriter tweeting
-- putStrLn $ show $ hello . snd t
-- putStrLn $ show $ goodbye . snd t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment