fused-effects-0.1.2.0: A fast, flexible, fused effect system.

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Cull

Synopsis

Documentation

data Cull m k Source #

Cull effects are used with NonDet to provide control over branching.

Constructors

Cull (m a) (a -> k) 
Instances
Effect Cull Source # 
Instance details

Defined in Control.Effect.Cull

Methods

handle :: Functor f => f () -> (forall x. f (m x) -> n (f x)) -> Cull m (m a) -> Cull n (n (f a)) Source #

HFunctor Cull Source # 
Instance details

Defined in Control.Effect.Cull

Methods

fmap' :: (a -> b) -> Cull m a -> Cull m b Source #

hmap :: (forall x. m x -> n x) -> Cull m a -> Cull n a Source #

Functor (Cull m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

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

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

(Alternative m, Carrier sig m, Effect sig, Monad m) => Carrier (Cull :+: (NonDet :+: sig)) (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

ret :: a -> CullC m a Source #

eff :: (Cull :+: (NonDet :+: sig)) (CullC m) (CullC m a) -> CullC m a Source #

cull :: (Carrier sig m, Member Cull sig) => m a -> m a Source #

Cull nondeterminism in the argument, returning at most one result.

run (runNonDet (runCull (cull (pure a <|> pure b)))) == [a]
run (runNonDet (runCull (cull (pure a <|> pure b) <|> pure c))) == [a, c]
run (runNonDet (runCull (cull (asum (map pure (repeat a)))))) == [a]

runCull :: (Alternative m, Carrier sig m, Effect sig, Monad m) => Eff (CullC m) a -> m a Source #

Run a Cull effect. Branches outside of any cull block will not be pruned.

run (runNonDet (runCull (pure a <|> pure b))) == [a, b]

newtype CullC m a Source #

Constructors

CullC 

Fields

Instances
(Alternative m, Carrier sig m, Effect sig, Monad m) => Carrier (Cull :+: (NonDet :+: sig)) (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

ret :: a -> CullC m a Source #

eff :: (Cull :+: (NonDet :+: sig)) (CullC m) (CullC m a) -> CullC m a Source #