Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Resumable i o r where
- prompt :: Member (Resumable i o) effs => o -> Eff effs i
- select :: forall i o effs a. Member (Resumable i o) effs => Eff effs a -> Eff effs a -> Eff effs a
- never :: forall i o effs a. Member (Resumable i o) effs => Eff effs a
- data Request o = Request {
- rqID :: RequestID
- itID :: IterationID
- rqRequest :: o
- data Response i = Response {
- rspRqID :: RequestID
- rspItID :: IterationID
- rspResponse :: i
- newtype RequestID = RequestID Natural
- newtype IterationID = IterationID Natural
- newtype Requests o = Requests {
- unRequests :: [Request o]
- type ResumableEffs i o effs a = NonDet ': (State IterationID ': (State RequestID ': (State (ReqMap i o effs a) ': (State (Requests o) ': effs))))
- newtype Responses i = Responses {
- unResponses :: Map (IterationID, RequestID) i
- insertResponse :: Response i -> Responses i -> Responses i
- responses :: Responses i -> [Response i]
- _Responses :: forall i. Iso' (Responses i) (Map (IterationID, RequestID) i)
- handleResumable :: forall i o effs. (Member (Yield o i) effs, Member NonDet effs) => Eff (Resumable i o ': effs) ~> Eff effs
- suspendNonDet :: forall i o a effs. Eff (Yield o i ': ResumableEffs i o effs a) a -> Eff effs (Maybe (MultiRequestContStatus i o effs a))
- data MultiRequestContStatus i o effs a
- = AResult a
- | AContinuation (MultiRequestContinuation i o effs a)
- data MultiRequestContinuation i o effs a = MultiRequestContinuation {
- ndcCont :: Response i -> Eff effs (Maybe (MultiRequestContStatus i o effs a))
- ndcRequests :: Requests o
- newtype ReqMap i o effs a = ReqMap {
- unReqMap :: Map (RequestID, IterationID) (i -> Eff (ResumableEffs i o effs a) a)
The Resumable
effect
select :: forall i o effs a. Member (Resumable i o) effs => Eff effs a -> Eff effs a -> Eff effs a Source #
Handling the Resumable
effect
Instances
Response | |
|
Instances
A value that uniquely identifies requests made during the execution of
Resumable
programs.
Instances
newtype IterationID Source #
A value that uniquely identifies groups of requests.
Instances
Requests | |
|
Instances
type ResumableEffs i o effs a = NonDet ': (State IterationID ': (State RequestID ': (State (ReqMap i o effs a) ': (State (Requests o) ': effs)))) Source #
Responses | |
|
Instances
responses :: Responses i -> [Response i] Source #
A list of all responses ordered by iteration and request ID
_Responses :: forall i. Iso' (Responses i) (Map (IterationID, RequestID) i) Source #
Handling the Resumable
effect with continuations
handleResumable :: forall i o effs. (Member (Yield o i) effs, Member NonDet effs) => Eff (Resumable i o ': effs) ~> Eff effs Source #
Interpret the Resumable
effect in terms of the Yield
and NonDet
effects.
suspendNonDet :: forall i o a effs. Eff (Yield o i ': ResumableEffs i o effs a) a -> Eff effs (Maybe (MultiRequestContStatus i o effs a)) Source #
Interpret Yield
as a prompt-type effect using NonDet
to
branch out and choose a branch, and the State
effects to
keep track of request IDs.
data MultiRequestContStatus i o effs a Source #
Status of a suspended MultiRequestContinuation
.
AResult a | Done |
AContinuation (MultiRequestContinuation i o effs a) | Waiting for inputs |
data MultiRequestContinuation i o effs a Source #
A continuation that accepts a response to one of several requests.
MultiRequestContinuation | |
|
newtype ReqMap i o effs a Source #
A map of requests to continuations. For each request, identified by
a pair of RequestID
and IterationID
, ReqMap
contains the
continuation that takes the response to the request.
ReqMap | |
|