fused-effects-1.1.2.3: A fast, flexible, fused effect system.
Safe HaskellNone
LanguageHaskell2010

Control.Carrier.Empty.Maybe

Description

A carrier for an Empty effect, indicating failure with a Nothing value. Users that need access to an error message should use the Fail effect.

Note that Empty effects can, when they are the last effect in a stack, be interpreted directly to a Maybe without a call to runEmpty.

Since: 1.0.0.0

Synopsis

Empty carrier

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

Run an Empty effect, returning Nothing for empty computations, or Just the result otherwise.

runEmpty empty = pure Nothing
runEmpty (pure a) = pure (Just a)

Since: 1.0.0.0

evalEmpty :: Functor 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 = void . runEmpty

Since: 1.1.0.0

execEmpty :: Functor 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 = fmap isJust . runEmpty
execEmpty (pure a) = pure True
execEmpty empty = pure False

Since: 1.1.0.0

newtype EmptyC (m :: Type -> Type) a Source #

Since: 1.0.0.0

Constructors

EmptyC (MaybeT m a) 

Instances

Instances details
MonadTrans EmptyC Source # 
Instance details

Defined in Control.Carrier.Empty.Maybe

Methods

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

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

Defined in Control.Carrier.Empty.Maybe

Methods

liftIO :: IO a -> EmptyC m a #

Monad m => Applicative (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Maybe

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 m => Functor (EmptyC m) Source # 
Instance details

Defined in Control.Carrier.Empty.Maybe

Methods

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

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

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

Defined in Control.Carrier.Empty.Maybe

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 #

MonadFail m => MonadFail (EmptyC m) Source #

EmptyC passes MonadFail operations along to the underlying monad m, rather than interpreting it as a synonym for empty à la MaybeT.

Instance details

Defined in Control.Carrier.Empty.Maybe

Methods

fail :: String -> EmptyC m a #

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

Defined in Control.Carrier.Empty.Maybe

Methods

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

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

Defined in Control.Carrier.Empty.Maybe

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