Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Cut m k
- cutfail :: (Carrier sig m, Member Cut sig) => m a
- call :: (Carrier sig m, Member Cut sig) => m a -> m a
- cut :: (Alternative m, Carrier sig m, Member Cut sig) => m ()
- runCut :: Alternative m => CutC m a -> m a
- runCutAll :: (Alternative f, Applicative m) => CutC m a -> m (f a)
- newtype CutC m a = CutC {
- runCutC :: forall b. (a -> m b -> m b) -> m b -> m b -> m b
Documentation
call :: (Carrier sig m, Member Cut sig) => m a -> m a Source #
Delimit the effect of cutfail
s, allowing backtracking to resume.
run (runNonDet (runCut (call (cutfail <|> pure a) <|> pure b))) == [b]
cut :: (Alternative m, Carrier sig m, Member Cut sig) => m () Source #
Commit to the current branch, preventing backtracking within the nearest enclosing call
(if any) on failure.
run (runNonDet (runCut (pure a <|> cut *> pure b))) == [a, b]
run (runNonDet (runCut (cut *> pure a <|> pure b))) == [a]
run (runNonDet (runCut (cut *> empty <|> pure a))) == []
runCut :: Alternative m => CutC m a -> m a Source #
Run a Cut
effect within an underlying Alternative
instance (typically another Carrier
for a NonDet
effect).
run (runNonDetOnce (runCut (pure a))) == Just a
runCutAll :: (Alternative f, Applicative m) => CutC m a -> m (f a) Source #
Run a Cut
effect, returning all its results in an Alternative
collection.
Instances
MonadTrans CutC Source # | |
Defined in Control.Effect.Cut | |
Monad (CutC m) Source # | |
Functor (CutC m) Source # | |
MonadFail m => MonadFail (CutC m) Source # | |
Defined in Control.Effect.Cut | |
Applicative (CutC m) Source # | |
MonadIO m => MonadIO (CutC m) Source # | |
Defined in Control.Effect.Cut | |
Alternative (CutC m) Source # | |
MonadPlus (CutC m) Source # | |
(Carrier sig m, Effect sig) => Carrier (Cut :+: (NonDet :+: sig)) (CutC m) Source # | |