fused-effects-0.3.1.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 #

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

Defined in Control.Effect.Cull

Methods

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

ret :: 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 => 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
MonadTrans CullC Source # 
Instance details

Defined in Control.Effect.Cull

Methods

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

Monad (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

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

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

return :: a -> CullC m a #

fail :: String -> CullC m a #

Functor (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

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

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

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

Defined in Control.Effect.Cull

Methods

fail :: String -> CullC m a #

Applicative (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

pure :: a -> CullC m a #

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

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

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

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

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

Defined in Control.Effect.Cull

Methods

liftIO :: IO a -> CullC m a #

Alternative (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

empty :: CullC m a #

(<|>) :: CullC m a -> CullC m a -> CullC m a #

some :: CullC m a -> CullC m [a] #

many :: CullC m a -> CullC m [a] #

MonadPlus (CullC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

mzero :: CullC m a #

mplus :: CullC m a -> CullC m a -> CullC m a #

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

Defined in Control.Effect.Cull

Methods

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

ret :: a -> CullC m a Source #

runNonDetOnce :: (Alternative f, Carrier sig m, Effect sig) => OnceC m a -> m (f a) Source #

Run a NonDet effect, returning the first successful result in an Alternative functor.

Unlike runNonDet, this will terminate immediately upon finding a solution.

run (runNonDetOnce (asum (map pure (repeat a)))) == [a]
run (runNonDetOnce (asum (map pure (repeat a)))) == Just a

newtype OnceC m a Source #

Constructors

OnceC 

Fields

Instances
Monad (OnceC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

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

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

return :: a -> OnceC m a #

fail :: String -> OnceC m a #

Functor (OnceC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

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

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

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

Defined in Control.Effect.Cull

Methods

fail :: String -> OnceC m a #

Applicative (OnceC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

pure :: a -> OnceC m a #

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

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

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

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

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

Defined in Control.Effect.Cull

Methods

liftIO :: IO a -> OnceC m a #

Alternative (OnceC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

empty :: OnceC m a #

(<|>) :: OnceC m a -> OnceC m a -> OnceC m a #

some :: OnceC m a -> OnceC m [a] #

many :: OnceC m a -> OnceC m [a] #

MonadPlus (OnceC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

mzero :: OnceC m a #

mplus :: OnceC m a -> OnceC m a -> OnceC m a #

(Carrier sig m, Effect sig) => Carrier (NonDet :+: sig) (OnceC m) Source # 
Instance details

Defined in Control.Effect.Cull

Methods

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

ret :: a -> OnceC m a Source #