fused-effects-1.1.2.1: A fast, flexible, fused effect system.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Carrier.Empty.Church

Description

A church-encoded carrier for Empty.

Since: 1.1.0.0

Synopsis

Empty carrier

runEmpty :: m b -> (a -> m b) -> EmptyC m a -> m b Source #

Run an Empty effect, returning the first continuation for empty programs and applying the second to successful results.

runEmpty j k empty = j
runEmpty j k (pure a) = k a

Since: 1.1.0.0

evalEmpty :: Applicative m => EmptyC m a -> m () Source #

Run an Empty effect, discarding its result.

This is convenient for using empty to signal early returns without needing to know whether control exited normally or not.

evalEmpty = runEmpty (pure ()) (const (pure ()))

Since: 1.1.0.0

execEmpty :: Applicative m => EmptyC m a -> m Bool Source #

Run an Empty effect, replacing its result with a Bool indicating whether control exited normally.

This is convenient for using empty to signal early returns when all you need to know is whether control exited normally or not, and not what value it exited with.

execEmpty = runEmpty (pure False) (const (pure True))
execEmpty (pure a) = pure True
execEmpty empty = pure False

Since: 1.1.0.0

newtype EmptyC m a Source #

Since: 1.1.0.0

Constructors

EmptyC (forall b. m b -> (a -> m b) -> m b) 

Instances

Instances details
MonadTrans EmptyC Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

lift :: Monad m => m a -> EmptyC m a #

MonadFail m => MonadFail (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

fail :: String -> EmptyC m a #

MonadFix m => MonadFix (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

mfix :: (a -> EmptyC m a) -> EmptyC m a #

MonadIO m => MonadIO (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

liftIO :: IO a -> EmptyC m a #

Applicative (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

pure :: a -> EmptyC m a #

(<*>) :: EmptyC m (a -> b) -> EmptyC m a -> EmptyC m b #

liftA2 :: (a -> b -> c) -> EmptyC m a -> EmptyC m b -> EmptyC m c #

(*>) :: EmptyC m a -> EmptyC m b -> EmptyC m b #

(<*) :: EmptyC m a -> EmptyC m b -> EmptyC m a #

Functor (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

fmap :: (a -> b) -> EmptyC m a -> EmptyC m b #

(<$) :: a -> EmptyC m b -> EmptyC m a #

Monad (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

(>>=) :: EmptyC m a -> (a -> EmptyC m b) -> EmptyC m b #

(>>) :: EmptyC m a -> EmptyC m b -> EmptyC m b #

return :: a -> EmptyC m a #

Algebra sig m => Algebra (Empty :+: sig) (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Church

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (EmptyC m) -> (Empty :+: sig) n a -> ctx () -> EmptyC m (ctx a) Source #

Empty effect