Skip to content

Instantly share code, notes, and snippets.

@danclien
Last active August 29, 2015 14:19
Show Gist options
  • Save danclien/131df023e415a831a700 to your computer and use it in GitHub Desktop.
Save danclien/131df023e415a831a700 to your computer and use it in GitHub Desktop.
`newtype` IO
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Applicative
-- Don't export the 'MyIO' constructor
newtype MyIO a = MyIO { runMyIO :: IO a
} deriving (Functor, Applicative, Monad)
myGetLine :: MyIO String
myGetLine = MyIO getLine
myPutStrLn :: String -> MyIO ()
myPutStrLn = MyIO . putStrLn
main = runMyIO $ do
a <- myGetLine
myPutStrLn a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment