0 | module Idrall.IOEither
4 | = MkIOEither (IO (Either a b))
7 | Functor (IOEither a) where
8 | map func (MkIOEither x) = MkIOEither (map (map func) x)
12 | liftA2 : Applicative f => (a -> b -> c) -> f a -> f b -> f c
13 | liftA2 f a b = (map f a) <*> b
16 | Applicative (IOEither a) where
17 | pure x = MkIOEither (pure (pure x))
18 | (<*>) (MkIOEither x) (MkIOEither y) = MkIOEither (liftA2 (<*>) x y)
21 | Monad (IOEither a) where
22 | (>>=) (MkIOEither x) f = MkIOEither (do x' <- x
24 | (Left l) => pure (Left l)
25 | (Right r) => let MkIOEither g = f r in
30 | liftEither : Either e a -> IOEither e a
31 | liftEither = MkIOEither . pure
34 | liftIOEither : IOEither e a -> IO (Either e a)
35 | liftIOEither (MkIOEither x) = x
38 | mapErr : (e -> e') -> IOEither e a -> IOEither e' a
39 | mapErr f (MkIOEither x) = MkIOEither (do
42 | (Left l) => pure (Left (f l))
43 | (Right r) => pure (Right r))