You can see how StateT is implemented :
newtype StateT s m a = StateT { runStateT :: s -> m (a,s) }
To align with the state IO, you simply put IOin place mand get the desired type: s -> IO (a,s).
, - s -> IO (Either e (a, s)) s -> IO (Either e a, s) , , .
, s -> Either e (IO (a, s)) monad .
, .
, , , () s: data M e a = M { runM :: Either e (IO a) }
:
unsafePerformIO :: IO a -> a
unsafePerformIO io = fromLeft $ runM $ do
a <- M $ Right $ io
M $ Left a
, , m .
IO , State. , Either e (s -> (a, s)) .
source
share