Created
June 1, 2014 21:04
-
-
Save aostiles/b4b39172f0c3c4f55830 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 act) handle = UnsafeRIO $ act `gcatch` \e -> runRIO (handle e) | |
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