plutus-contract-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.Contract.Resumable

Synopsis

The Resumable effect

data Resumable i o r where Source #

A data type for representing non-deterministic prompts.

Constructors

RRequest :: o -> Resumable i o i 
RSelect :: Resumable i o Bool 
RZero :: Resumable i o a 

prompt :: Member (Resumable i o) effs => o -> Eff effs i Source #

select :: forall i o effs a. Member (Resumable i o) effs => Eff effs a -> Eff effs a -> Eff effs a Source #

never :: forall i o effs a. Member (Resumable i o) effs => Eff effs a Source #

Handling the Resumable effect

data Request o Source #

Constructors

Request 

Fields

Instances

Instances details
Functor Request Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fmap :: (a -> b) -> Request a -> Request b Source #

(<$) :: a -> Request b -> Request a Source #

Foldable Request Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fold :: Monoid m => Request m -> m Source #

foldMap :: Monoid m => (a -> m) -> Request a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Request a -> m Source #

foldr :: (a -> b -> b) -> b -> Request a -> b Source #

foldr' :: (a -> b -> b) -> b -> Request a -> b Source #

foldl :: (b -> a -> b) -> b -> Request a -> b Source #

foldl' :: (b -> a -> b) -> b -> Request a -> b Source #

foldr1 :: (a -> a -> a) -> Request a -> a Source #

foldl1 :: (a -> a -> a) -> Request a -> a Source #

toList :: Request a -> [a] Source #

null :: Request a -> Bool Source #

length :: Request a -> Int Source #

elem :: Eq a => a -> Request a -> Bool Source #

maximum :: Ord a => Request a -> a Source #

minimum :: Ord a => Request a -> a Source #

sum :: Num a => Request a -> a Source #

product :: Num a => Request a -> a Source #

Traversable Request Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

traverse :: Applicative f => (a -> f b) -> Request a -> f (Request b) Source #

sequenceA :: Applicative f => Request (f a) -> f (Request a) Source #

mapM :: Monad m => (a -> m b) -> Request a -> m (Request b) Source #

sequence :: Monad m => Request (m a) -> m (Request a) Source #

Eq o => Eq (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

(==) :: Request o -> Request o -> Bool Source #

(/=) :: Request o -> Request o -> Bool Source #

Ord o => Ord (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Show o => Show (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Generic (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Associated Types

type Rep (Request o) :: Type -> Type Source #

Methods

from :: Request o -> Rep (Request o) x Source #

to :: Rep (Request o) x -> Request o Source #

ToJSON o => ToJSON (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSON o => FromJSON (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToSchema o => ToSchema (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Pretty o => Pretty (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

pretty :: Request o -> Doc ann Source #

prettyList :: [Request o] -> Doc ann Source #

type Rep (Request o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

type Rep (Request o) = D1 ('MetaData "Request" "Plutus.Contract.Resumable" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'False) (C1 ('MetaCons "Request" 'PrefixI 'True) (S1 ('MetaSel ('Just "rqID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RequestID) :*: (S1 ('MetaSel ('Just "itID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IterationID) :*: S1 ('MetaSel ('Just "rqRequest") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 o))))

data Response i Source #

Constructors

Response 

Instances

Instances details
Functor Response Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fmap :: (a -> b) -> Response a -> Response b Source #

(<$) :: a -> Response b -> Response a Source #

Foldable Response Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fold :: Monoid m => Response m -> m Source #

foldMap :: Monoid m => (a -> m) -> Response a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Response a -> m Source #

foldr :: (a -> b -> b) -> b -> Response a -> b Source #

foldr' :: (a -> b -> b) -> b -> Response a -> b Source #

foldl :: (b -> a -> b) -> b -> Response a -> b Source #

foldl' :: (b -> a -> b) -> b -> Response a -> b Source #

foldr1 :: (a -> a -> a) -> Response a -> a Source #

foldl1 :: (a -> a -> a) -> Response a -> a Source #

toList :: Response a -> [a] Source #

null :: Response a -> Bool Source #

length :: Response a -> Int Source #

elem :: Eq a => a -> Response a -> Bool Source #

maximum :: Ord a => Response a -> a Source #

minimum :: Ord a => Response a -> a Source #

sum :: Num a => Response a -> a Source #

product :: Num a => Response a -> a Source #

Traversable Response Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

traverse :: Applicative f => (a -> f b) -> Response a -> f (Response b) Source #

sequenceA :: Applicative f => Response (f a) -> f (Response a) Source #

mapM :: Monad m => (a -> m b) -> Response a -> m (Response b) Source #

sequence :: Monad m => Response (m a) -> m (Response a) Source #

Eq i => Eq (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

(==) :: Response i -> Response i -> Bool Source #

(/=) :: Response i -> Response i -> Bool Source #

Ord i => Ord (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Show i => Show (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Generic (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Associated Types

type Rep (Response i) :: Type -> Type Source #

Methods

from :: Response i -> Rep (Response i) x Source #

to :: Rep (Response i) x -> Response i Source #

ToJSON i => ToJSON (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSON i => FromJSON (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Pretty i => Pretty (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

pretty :: Response i -> Doc ann Source #

prettyList :: [Response i] -> Doc ann Source #

type Rep (Response i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

type Rep (Response i) = D1 ('MetaData "Response" "Plutus.Contract.Resumable" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'False) (C1 ('MetaCons "Response" 'PrefixI 'True) (S1 ('MetaSel ('Just "rspRqID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RequestID) :*: (S1 ('MetaSel ('Just "rspItID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IterationID) :*: S1 ('MetaSel ('Just "rspResponse") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 i))))

newtype RequestID Source #

A value that uniquely identifies requests made during the execution of Resumable programs.

Constructors

RequestID Natural 

Instances

Instances details
Enum RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Eq RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Num RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Ord RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Show RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Generic RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Associated Types

type Rep RequestID :: Type -> Type Source #

ToJSON RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToJSONKey RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSON RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSONKey RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToSchema RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Pretty RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

pretty :: RequestID -> Doc ann Source #

prettyList :: [RequestID] -> Doc ann Source #

type Rep RequestID Source # 
Instance details

Defined in Plutus.Contract.Resumable

type Rep RequestID = D1 ('MetaData "RequestID" "Plutus.Contract.Resumable" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'True) (C1 ('MetaCons "RequestID" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))

newtype IterationID Source #

A value that uniquely identifies groups of requests.

Constructors

IterationID Natural 

Instances

Instances details
Enum IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Eq IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Num IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Ord IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Show IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Generic IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Associated Types

type Rep IterationID :: Type -> Type Source #

Semigroup IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Monoid IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToJSON IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToJSONKey IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSON IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSONKey IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToSchema IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

Pretty IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

type Rep IterationID Source # 
Instance details

Defined in Plutus.Contract.Resumable

type Rep IterationID = D1 ('MetaData "IterationID" "Plutus.Contract.Resumable" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'True) (C1 ('MetaCons "IterationID" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))

newtype Requests o Source #

Constructors

Requests 

Fields

Instances

Instances details
Functor Requests Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fmap :: (a -> b) -> Requests a -> Requests b Source #

(<$) :: a -> Requests b -> Requests a Source #

Foldable Requests Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fold :: Monoid m => Requests m -> m Source #

foldMap :: Monoid m => (a -> m) -> Requests a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Requests a -> m Source #

foldr :: (a -> b -> b) -> b -> Requests a -> b Source #

foldr' :: (a -> b -> b) -> b -> Requests a -> b Source #

foldl :: (b -> a -> b) -> b -> Requests a -> b Source #

foldl' :: (b -> a -> b) -> b -> Requests a -> b Source #

foldr1 :: (a -> a -> a) -> Requests a -> a Source #

foldl1 :: (a -> a -> a) -> Requests a -> a Source #

toList :: Requests a -> [a] Source #

null :: Requests a -> Bool Source #

length :: Requests a -> Int Source #

elem :: Eq a => a -> Requests a -> Bool Source #

maximum :: Ord a => Requests a -> a Source #

minimum :: Ord a => Requests a -> a Source #

sum :: Num a => Requests a -> a Source #

product :: Num a => Requests a -> a Source #

Traversable Requests Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

traverse :: Applicative f => (a -> f b) -> Requests a -> f (Requests b) Source #

sequenceA :: Applicative f => Requests (f a) -> f (Requests a) Source #

mapM :: Monad m => (a -> m b) -> Requests a -> m (Requests b) Source #

sequence :: Monad m => Requests (m a) -> m (Requests a) Source #

Eq o => Eq (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

(==) :: Requests o -> Requests o -> Bool Source #

(/=) :: Requests o -> Requests o -> Bool Source #

Ord o => Ord (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Show o => Show (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Generic (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Associated Types

type Rep (Requests o) :: Type -> Type Source #

Methods

from :: Requests o -> Rep (Requests o) x Source #

to :: Rep (Requests o) x -> Requests o Source #

Semigroup (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Monoid (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToJSON o => ToJSON (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSON o => FromJSON (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Pretty o => Pretty (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

pretty :: Requests o -> Doc ann Source #

prettyList :: [Requests o] -> Doc ann Source #

type Rep (Requests o) Source # 
Instance details

Defined in Plutus.Contract.Resumable

type Rep (Requests o) = D1 ('MetaData "Requests" "Plutus.Contract.Resumable" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'True) (C1 ('MetaCons "Requests" 'PrefixI 'True) (S1 ('MetaSel ('Just "unRequests") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Request o])))

type ResumableEffs i o effs a = NonDet ': (State IterationID ': (State RequestID ': (State (ReqMap i o effs a) ': (State (Requests o) ': effs)))) Source #

newtype Responses i Source #

Constructors

Responses 

Instances

Instances details
Functor Responses Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fmap :: (a -> b) -> Responses a -> Responses b Source #

(<$) :: a -> Responses b -> Responses a Source #

Foldable Responses Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

fold :: Monoid m => Responses m -> m Source #

foldMap :: Monoid m => (a -> m) -> Responses a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Responses a -> m Source #

foldr :: (a -> b -> b) -> b -> Responses a -> b Source #

foldr' :: (a -> b -> b) -> b -> Responses a -> b Source #

foldl :: (b -> a -> b) -> b -> Responses a -> b Source #

foldl' :: (b -> a -> b) -> b -> Responses a -> b Source #

foldr1 :: (a -> a -> a) -> Responses a -> a Source #

foldl1 :: (a -> a -> a) -> Responses a -> a Source #

toList :: Responses a -> [a] Source #

null :: Responses a -> Bool Source #

length :: Responses a -> Int Source #

elem :: Eq a => a -> Responses a -> Bool Source #

maximum :: Ord a => Responses a -> a Source #

minimum :: Ord a => Responses a -> a Source #

sum :: Num a => Responses a -> a Source #

product :: Num a => Responses a -> a Source #

Traversable Responses Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

traverse :: Applicative f => (a -> f b) -> Responses a -> f (Responses b) Source #

sequenceA :: Applicative f => Responses (f a) -> f (Responses a) Source #

mapM :: Monad m => (a -> m b) -> Responses a -> m (Responses b) Source #

sequence :: Monad m => Responses (m a) -> m (Responses a) Source #

Eq i => Eq (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Ord i => Ord (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Show i => Show (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Generic (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Associated Types

type Rep (Responses i) :: Type -> Type Source #

Methods

from :: Responses i -> Rep (Responses i) x Source #

to :: Rep (Responses i) x -> Responses i Source #

Semigroup (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Monoid (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

ToJSON i => ToJSON (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

FromJSON i => FromJSON (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Pretty i => Pretty (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

Methods

pretty :: Responses i -> Doc ann Source #

prettyList :: [Responses i] -> Doc ann Source #

type Rep (Responses i) Source # 
Instance details

Defined in Plutus.Contract.Resumable

type Rep (Responses i) = D1 ('MetaData "Responses" "Plutus.Contract.Resumable" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'True) (C1 ('MetaCons "Responses" 'PrefixI 'True) (S1 ('MetaSel ('Just "unResponses") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (IterationID, RequestID) i))))

responses :: Responses i -> [Response i] Source #

A list of all responses ordered by iteration and request ID

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.

Constructors

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.

Constructors

MultiRequestContinuation 

Fields

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.

Constructors

ReqMap 

Fields