Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Select s m a where
- select :: Eff (Select s) m => (forall r. (a -> m (s, r)) -> m r) -> m a
- runSelect :: forall s a m p. (Carrier m, Threaders '[ContThreads] m p) => (a -> m s) -> SelectC s a m a -> m a
- runSelectFast :: forall s a m p. (Carrier m, Threaders '[ContFastThreads] m p) => (a -> m s) -> SelectFastC s a m a -> m a
- type SelectC s r = CompositionC '[ReinterpretC (SelectH r) (Select s) '[Shift (s, r)], ShiftC (s, r)]
- type SelectFastC s r = CompositionC '[ReinterpretC (SelectH r) (Select s) '[Shift (s, r)], ShiftFastC (s, r)]
Effect
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 #
runSelectFast :: forall s a m p. (Carrier m, Threaders '[ContFastThreads] m p) => (a -> m s) -> SelectFastC s a m a -> m a Source #
Run a
effect by providing an evaluator
for the final result of type Select
sa
.
Compared to runSelect
, this is quite a bit faster, but is significantly
more restrictive in what interpreters are used after it, since there are
very few primitive effects that the carrier for runSelectFast
is able to
thread.
In fact, of all the primitive effects featured in this library, only
one satisfies ContFastThreads
: namely, Reader
.
Derivs
(SelectFastC
s r m) =Select
s ':Derivs
m
Prims
(SelectFastC
s r m) =Prims
m
Carriers
type SelectC s r = CompositionC '[ReinterpretC (SelectH r) (Select s) '[Shift (s, r)], ShiftC (s, r)] Source #
type SelectFastC s r = CompositionC '[ReinterpretC (SelectH r) (Select s) '[Shift (s, r)], ShiftFastC (s, r)] Source #