module Control.Monad.TaggedException.Unsafe
( Throws
, throwsOne
, throwsTwo
, throwsThree
, hideOne
, hideTwo
, hideThree
, liftT1
, liftT2
, liftT3
, insideT
, insideTf
, insideTf2
, insideT2
, insideT3
, joinT
, joinT3
, flipT
, embedT
, liftMask
, liftBindLike
, liftFlipBindLike
, liftKleisliLike
)
where
import Data.Function ((.), ($))
import Data.Functor (Functor(fmap))
import Control.Monad.TaggedException.Internal.Throws
( Throws(Throws, hideException)
, liftMask
)
throwsOne :: m a -> Throws e m a
throwsOne = Throws
throwsTwo :: m a -> Throws e' (Throws e m) a
throwsTwo = Throws . Throws
throwsThree :: m a -> Throws e'' (Throws e' (Throws e m)) a
throwsThree = Throws . Throws . Throws
hideOne :: Throws e m a -> m a
hideOne = hideException
hideTwo :: Throws e (Throws e' m) a -> m a
hideTwo = hideException . hideException
hideThree :: Throws e (Throws e' (Throws e'' m)) a -> m a
hideThree = hideException . hideException . hideException
liftT1
:: (m a -> m b)
-> Throws e m a -> Throws e m b
liftT1 = (Throws .) . (. hideException)
liftT2
:: (m a -> m b -> m c)
-> Throws e m a -> Throws e m b -> Throws e m c
liftT2 f m n = Throws $ f (hideException m) (hideException n)
liftT3
:: (m a -> m b -> m c -> m d)
-> Throws e m a -> Throws e m b -> Throws e m c -> Throws e m d
liftT3 f m n o =
Throws $ f (hideException m) (hideException n) (hideException o)
insideT
:: (m a -> m' b)
-> Throws e m a -> Throws e m' b
insideT = (Throws .) . (. hideException)
insideTf
:: (Functor f)
=> (f (m a) -> m' b)
-> f (Throws e m a)
-> Throws e m' b
insideTf = (Throws .) . (. fmap hideException)
insideTf2
:: (Functor f, Functor f')
=> (f (f' (m a)) -> m' b)
-> f (f' (Throws e m a))
-> Throws e m' b
insideTf2 = (Throws .) . (. fmap (fmap hideException))
insideT2
:: (m1 a -> m2 b -> m3 c)
-> Throws e m1 a -> Throws e m2 b -> Throws e m3 c
insideT2 f m n = Throws $ f (hideException m) (hideException n)
insideT3
:: (m1 a -> m2 b -> m3 c -> m4 d)
-> Throws e m1 a -> Throws e m2 b -> Throws e m3 c -> Throws e m4 d
insideT3 f m n o =
Throws $ f (hideException m) (hideException n) (hideException o)
joinT
:: Throws e (Throws e m) a
-> Throws e m a
joinT = hideException
joinT3
:: Throws e (Throws e (Throws e m)) a
-> Throws e m a
joinT3 = hideTwo
flipT
:: Throws e' (Throws e m) a
-> Throws e (Throws e' m) a
flipT = throwsTwo . hideTwo
embedT :: (m a -> Throws e n b) -> Throws e m a -> Throws e n b
embedT = (. hideException)
liftBindLike
:: (m a -> (b -> m c) -> m d)
-> Throws e m a
-> (b -> Throws e m c)
-> Throws e m d
liftBindLike f x g = throwsOne $ f (hideException x) (hideException . g)
liftFlipBindLike
:: ((a -> m b) -> m c -> m d)
-> (a -> Throws e m b) -> Throws e m c -> Throws e m d
liftFlipBindLike f g x = Throws $ f (hideException . g) (hideException x)
liftKleisliLike
:: ((a -> m a') -> (b -> m b') -> c -> m c')
-> (a -> Throws e m a') -> (b -> Throws e m b') -> c -> Throws e m c'
liftKleisliLike f g h = Throws . f (hideException . g) (hideException . h)