{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Carrier.Fail.Either
(
runFail
, FailC(..)
, module Control.Effect.Fail
) where
import Control.Algebra
import Control.Applicative (Alternative(..))
import Control.Carrier.Throw.Either
import Control.Effect.Fail
import Control.Monad (MonadPlus(..))
import Control.Monad.Fail as Fail
import Control.Monad.Fix
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
runFail :: FailC m a -> m (Either String a)
runFail :: forall (m :: * -> *) a. FailC m a -> m (Either String a)
runFail (FailC ThrowC String m a
m) = forall e (m :: * -> *) a. ThrowC e m a -> m (Either e a)
runThrow ThrowC String m a
m
{-# INLINE runFail #-}
newtype FailC m a = FailC (ThrowC String m a)
deriving (Algebra (Fail :+: sig), forall a. FailC m a
forall a. FailC m a -> FailC m [a]
forall a. FailC m a -> FailC m a -> FailC m a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
forall {m :: * -> *}.
(Alternative m, Monad m) =>
Applicative (FailC m)
forall (m :: * -> *) a. (Alternative m, Monad m) => FailC m a
forall (m :: * -> *) a.
(Alternative m, Monad m) =>
FailC m a -> FailC m [a]
forall (m :: * -> *) a.
(Alternative m, Monad m) =>
FailC m a -> FailC m a -> FailC m a
many :: forall a. FailC m a -> FailC m [a]
$cmany :: forall (m :: * -> *) a.
(Alternative m, Monad m) =>
FailC m a -> FailC m [a]
some :: forall a. FailC m a -> FailC m [a]
$csome :: forall (m :: * -> *) a.
(Alternative m, Monad m) =>
FailC m a -> FailC m [a]
<|> :: forall a. FailC m a -> FailC m a -> FailC m a
$c<|> :: forall (m :: * -> *) a.
(Alternative m, Monad m) =>
FailC m a -> FailC m a -> FailC m a
empty :: forall a. FailC m a
$cempty :: forall (m :: * -> *) a. (Alternative m, Monad m) => FailC m a
Alternative, forall a. a -> FailC m a
forall a b. FailC m a -> FailC m b -> FailC m a
forall a b. FailC m a -> FailC m b -> FailC m b
forall a b. FailC m (a -> b) -> FailC m a -> FailC m b
forall a b c. (a -> b -> c) -> FailC m a -> FailC m b -> FailC m c
forall {m :: * -> *}. Monad m => Functor (FailC m)
forall (m :: * -> *) a. Monad m => a -> FailC m a
forall (m :: * -> *) a b.
Monad m =>
FailC m a -> FailC m b -> FailC m a
forall (m :: * -> *) a b.
Monad m =>
FailC m a -> FailC m b -> FailC m b
forall (m :: * -> *) a b.
Monad m =>
FailC m (a -> b) -> FailC m a -> FailC m b
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> FailC m a -> FailC m b -> FailC m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: forall a b. FailC m a -> FailC m b -> FailC m a
$c<* :: forall (m :: * -> *) a b.
Monad m =>
FailC m a -> FailC m b -> FailC m a
*> :: forall a b. FailC m a -> FailC m b -> FailC m b
$c*> :: forall (m :: * -> *) a b.
Monad m =>
FailC m a -> FailC m b -> FailC m b
liftA2 :: forall a b c. (a -> b -> c) -> FailC m a -> FailC m b -> FailC m c
$cliftA2 :: forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> c) -> FailC m a -> FailC m b -> FailC m c
<*> :: forall a b. FailC m (a -> b) -> FailC m a -> FailC m b
$c<*> :: forall (m :: * -> *) a b.
Monad m =>
FailC m (a -> b) -> FailC m a -> FailC m b
pure :: forall a. a -> FailC m a
$cpure :: forall (m :: * -> *) a. Monad m => a -> FailC m a
Applicative, forall a b. a -> FailC m b -> FailC m a
forall a b. (a -> b) -> FailC m a -> FailC m b
forall (m :: * -> *) a b. Functor m => a -> FailC m b -> FailC m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> FailC m a -> FailC m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> FailC m b -> FailC m a
$c<$ :: forall (m :: * -> *) a b. Functor m => a -> FailC m b -> FailC m a
fmap :: forall a b. (a -> b) -> FailC m a -> FailC m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> FailC m a -> FailC m b
Functor, forall a. a -> FailC m a
forall a b. FailC m a -> FailC m b -> FailC m b
forall a b. FailC m a -> (a -> FailC m b) -> FailC m b
forall (m :: * -> *). Monad m => Applicative (FailC m)
forall (m :: * -> *) a. Monad m => a -> FailC m a
forall (m :: * -> *) a b.
Monad m =>
FailC m a -> FailC m b -> FailC m b
forall (m :: * -> *) a b.
Monad m =>
FailC m a -> (a -> FailC m b) -> FailC m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: forall a. a -> FailC m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> FailC m a
>> :: forall a b. FailC m a -> FailC m b -> FailC m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
FailC m a -> FailC m b -> FailC m b
>>= :: forall a b. FailC m a -> (a -> FailC m b) -> FailC m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
FailC m a -> (a -> FailC m b) -> FailC m b
Monad, forall a. (a -> FailC m a) -> FailC m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
forall {m :: * -> *}. MonadFix m => Monad (FailC m)
forall (m :: * -> *) a. MonadFix m => (a -> FailC m a) -> FailC m a
mfix :: forall a. (a -> FailC m a) -> FailC m a
$cmfix :: forall (m :: * -> *) a. MonadFix m => (a -> FailC m a) -> FailC m a
MonadFix, forall a. IO a -> FailC m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall {m :: * -> *}. MonadIO m => Monad (FailC m)
forall (m :: * -> *) a. MonadIO m => IO a -> FailC m a
liftIO :: forall a. IO a -> FailC m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> FailC m a
MonadIO, forall a. FailC m a
forall a. FailC m a -> FailC m a -> FailC m a
forall {m :: * -> *}. (Alternative m, Monad m) => Monad (FailC m)
forall (m :: * -> *).
(Alternative m, Monad m) =>
Alternative (FailC m)
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
forall (m :: * -> *) a. (Alternative m, Monad m) => FailC m a
forall (m :: * -> *) a.
(Alternative m, Monad m) =>
FailC m a -> FailC m a -> FailC m a
mplus :: forall a. FailC m a -> FailC m a -> FailC m a
$cmplus :: forall (m :: * -> *) a.
(Alternative m, Monad m) =>
FailC m a -> FailC m a -> FailC m a
mzero :: forall a. FailC m a
$cmzero :: forall (m :: * -> *) a. (Alternative m, Monad m) => FailC m a
MonadPlus, forall (m :: * -> *) a. Monad m => m a -> FailC m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: forall (m :: * -> *) a. Monad m => m a -> FailC m a
$clift :: forall (m :: * -> *) a. Monad m => m a -> FailC m a
MonadTrans)
instance Algebra sig m => Fail.MonadFail (FailC m) where
fail :: forall a. String -> FailC m a
fail = forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Member eff sig, Algebra sig m) =>
eff m a -> m a
send forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) k. String -> Fail m k
Fail
{-# INLINE fail #-}