Created
June 1, 2014 18:43
-
-
Save aostiles/1bc4becc60f3fe53a35e to your computer and use it in GitHub Desktop.
This file contains 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
module IHaskell.Eval.RIO (RIO(), runRIO, IHaskell.Eval.RIO.putStrLn, IHaskell.Eval.RIO.putStr,MyGhcMonad) where | |
import qualified System.IO | |
import GHC | |
import MonadUtils | |
import Exception | |
-- Notice that symbol UnsafeRIO is not exported from this module! | |
newtype RIO a = UnsafeRIO { runRIO :: IO a } | |
type MyGhcMonad = GhcT RIO | |
instance Monad RIO where | |
return = UnsafeRIO . return | |
(UnsafeRIO m) >>= k = UnsafeRIO $ m >>= runRIO . k | |
instance Functor RIO where | |
fmap f (UnsafeRIO a) = UnsafeRIO (fmap f a) | |
instance MonadIO RIO where | |
liftIO a = UnsafeRIO (a) | |
instance ExceptionMonad RIO where | |
gcatch (UnsafeRIO ioa) handler = | |
putStrLn :: String -> RIO () | |
putStrLn s = UnsafeRIO (System.IO.putStrLn s) | |
putStr :: String -> RIO () | |
putStr s = UnsafeRIO (System.IO.putStr s) | |
print :: Show a => a -> RIO () | |
print s = UnsafeRIO (System.IO.print s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment