2 {-# OPTIONS -fno-implicit-prelude -#include "cbits/stgio.h" #-}
11 newtype IIO a = IIO (State# RealWorld -> (# State# RealWorld, a #))
13 unIIO :: IIO a -> (State# RealWorld -> (# State# RealWorld, a #))
16 instance Functor IIO where
17 fmap f x = x >>= (return . f)
19 instance Monad IIO where
23 m >> k = m >>= \ _ -> k
24 return x = returnIIO x
27 fail s = error s -- not ioError?
30 bindIIO :: IIO a -> (a -> IIO b) -> IIO b
31 bindIIO (IIO m) k = IIO ( \ s ->
33 (# new_s, a #) -> unIIO (k a) new_s
36 returnIIO :: a -> IIO a
37 returnIIO x = IIO (\ s -> (# s, x #))