Safe Haskell | None |
---|---|
Language | Haskell2010 |
Effect
newtype Select s m a where Source #
An effect for backtracking search.
Instances
Eff (Shift (s, r)) m => Handler (SelectH r) (Select s) m Source # | |
Defined in Control.Effect.Internal.Select effHandler :: EffHandler (Select s) m Source # |
Actions
select :: Eff (Select s) m => (forall r. (a -> m (s, r)) -> m r) -> m a Source #
Perform a search: capture the continuation
of the program, so that you may test values of a
and observe
what corresponding s
each value would result in
at the end of the program (which may be seen as the evaluation of a
).
When you find a satisfactory a
, you may return the associated r
.
The way higher-order actions interact with the continuation depends
on the interpretation of Select
. In general, you cannot expect to interact
with the continuation in any meaningful way: for example, you should not
assume that you will be able to catch an exception thrown at some point in
the future of the computation by using catch
on the
continuation.
Interpretations
runSelect :: forall s a m p. (Carrier m, Threaders '[ContThreads] m p) => (a -> m s) -> SelectC s a m a -> m a Source #