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

Control.Carrier.Choose.Church

Description

A carrier for Choose effects (nondeterminism without failure).

Under the hood, it uses a Church-encoded binary tree to avoid the problems associated with a naïve list-based implementation (see "ListT done right").

Since: 1.0.0.0

Synopsis

Choose carrier

runChoose :: (m b -> m b -> m b) -> (a -> m b) -> ChooseC m a -> m b Source #

Run a Choose effect with continuations respectively interpreting <|> and pure.

runChoose fork leaf (pure a <|> b) = leaf a `fork` runChoose fork leaf b

Since: 1.0.0.0

runChooseS :: (Semigroup b, Applicative m) => (a -> m b) -> ChooseC m a -> m b Source #

Run a Choose effect, mapping results into a Semigroup.

Since: 1.0.0.0

newtype ChooseC m a Source #

A carrier for Choose effects based on Ralf Hinze’s design described in Deriving Backtracking Monad Transformers.

Since: 1.0.0.0

Constructors

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

Instances

Instances details
MonadTrans ChooseC Source # 
Instance details

Defined in Control.Carrier.Choose.Church

Methods

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

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

Defined in Control.Carrier.Choose.Church

Methods

fail :: String -> ChooseC m a #

MonadFix m => MonadFix (ChooseC m) Source #

Separate fixpoints are computed for each branch.

Instance details

Defined in Control.Carrier.Choose.Church

Methods

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

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

Defined in Control.Carrier.Choose.Church

Methods

liftIO :: IO a -> ChooseC m a #

Applicative (ChooseC m) Source # 
Instance details

Defined in Control.Carrier.Choose.Church

Methods

pure :: a -> ChooseC m a #

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

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

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

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

Functor (ChooseC m) Source # 
Instance details

Defined in Control.Carrier.Choose.Church

Methods

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

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

Monad (ChooseC m) Source # 
Instance details

Defined in Control.Carrier.Choose.Church

Methods

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

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

return :: a -> ChooseC m a #

Algebra sig m => Algebra (Choose :+: sig) (ChooseC m) Source # 
Instance details

Defined in Control.Carrier.Choose.Church

Methods

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

Choose effect