import "Prelude" data RealWorld = RealWorld data IO a = IO (RealWorld -> (RealWorld, a)) @inline unIO (IO m) = m instance Functor IO where @inline fmap f x = x >>= (return . f) instance Monad IO where @inline return x = IO (\s -> (s, x)) @inline (IO m) >>= f = IO (\s -> do (newS, v) = m s unIO (f v) newS ) @inline runIO :: IO a -> a runIO m = snd (unIO m RealWorld) main = runIO (return (13 :: Integer)) -- 13