Skip to content

Instantly share code, notes, and snippets.

@tomasv
Created May 2, 2011 21:14
Show Gist options
  • Save tomasv/952379 to your computer and use it in GitHub Desktop.
Save tomasv/952379 to your computer and use it in GitHub Desktop.
module Main where
import Control.Monad.Writer
import Control.Monad.Reader
rwt :: A Int
rwt = ask >>= \x -> tell ("Got " ++ show x) >> return (x * 2)
type A = ReaderT Int (WriterT String Maybe)
runA :: A a -> Int -> Maybe (a, String)
runA app i = runWriterT (runReaderT app i)
main = do
let ee = runA rwt 6
putStrLn $ (show ee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment