| Copyright | (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o.; 2017 Alexis King (c) 2023-2024 Sayo Koyoneda |
|---|---|
| License | MPL-2.0 (see the file LICENSE) |
| Maintainer | ymdfield@outlook.jp |
| Safe Haskell | None |
| Language | GHC2021 |
Data.Effect.Coroutine
Description
This module provides effects for the coroutine, comes
from Control.Monad.Freer.Coroutine
in the freer-simple package (The continuation part (b -> c) has been removed. If necessary, please manually compose the Coyoneda) .
Synopsis
- data Yield a b c where
- type LYield a b = LiftFOE (Yield a b)
- pattern LYield :: forall a1 b a2 f. () => (a1 ~ b, ()) => a2 -> LiftFOE (Yield a2 b) f a1
- yield :: SendFOE (Yield a b) f => a -> f b
- yield' :: forall {k} (tag :: k) a b f. SendFOE (Tag (Yield a b) tag) f => a -> f b
- yield'' :: forall {k} (key :: k) a b f. SendFOEBy key (Yield a b) f => a -> f b
- yield_ :: Yield a () <: f => a -> f ()
- data Status (f :: Type -> Type) a b r
- continueStatus :: Monad m => (x -> m (Status m a b r)) -> Status m a b x -> m (Status m a b r)
- loopStatus :: Monad m => (a -> m b) -> Status m a b r -> m r
Documentation
data Yield a b c where Source #
An effect for coroutines.
Realizes an operation that transfers control to the caller of the computation with coroutines along with a value of type a,
and receives a value of type b from the caller.
yield :: SendFOE (Yield a b) f => a -> f b Source #
Transfers control to the caller of the computation with coroutines along with a value of type a, and receives a value of type b from the caller.
yield' :: forall {k} (tag :: k) a b f. SendFOE (Tag (Yield a b) tag) f => a -> f b Source #
Transfers control to the caller of the computation with coroutines along with a value of type a, and receives a value of type b from the caller.
yield'' :: forall {k} (key :: k) a b f. SendFOEBy key (Yield a b) f => a -> f b Source #
Transfers control to the caller of the computation with coroutines along with a value of type a, and receives a value of type b from the caller.
yield_ :: Yield a () <: f => a -> f () Source #
A version of yield where the value returned from the caller of the computation with coroutines is unit.
data Status (f :: Type -> Type) a b r Source #
The execution result when handling a computation that includes the Yield effect. A computation that may include suspension.
If the computation does not include yield, the completed result of the computation is obtained as Done.
If the computation includes yield, execution is suspended at that point, and the value of type a thrown by yield and the continuation of the computation from the point of yield are obtained as Continue.
By re-executing this continuation, you can resume the computation.
Arguments
| :: Monad m | |
| => (x -> m (Status m a b r)) | Additional continuation |
| -> Status m a b x | Computation status to extend |
| -> m (Status m a b r) |
Extends the computation result by appending the specified continuation.