|
Control.Concurrent.Session |
|
|
Description |
This is just a convenience module that reexports everything
you're expected to need.
|
|
Synopsis |
|
| | (~||~) :: forall prog prog' progOut progIn outgoing incoming finalState finalResult jumps l. (Dual prog prog', ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn, SWellFormedConfig l (D0 E) prog, SWellFormedConfig l (D0 E) prog', TyListIndex progOut l (MVar (ProgramCell (Cell outgoing))), TyListIndex progIn l (MVar (ProgramCell (Cell incoming)))) => SessionChain prog progOut progIn (outgoing, incoming) finalState finalResult -> OfferImpls jumps prog progOut progIn finalState finalResult -> OfferImpls (Cons (Cons (Jump l) Nil) jumps) prog progOut progIn finalState finalResult | | sjump :: forall l prog prog' progOut progIn outgoing incoming. (Dual prog prog', ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn, SWellFormedConfig l (D0 E) prog, SWellFormedConfig l (D0 E) prog', TyListIndex progOut l (MVar (ProgramCell (Cell outgoing))), TyListIndex progIn l (MVar (ProgramCell (Cell incoming)))) => SessionChain prog progOut progIn (Cons (Jump l) Nil, Cons (Jump l) Nil) (outgoing, incoming) () | | soffer :: forall outgoing incoming finalResult prog prog' progOut progIn jumps. (Dual prog prog', ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn) => OfferImpls jumps prog progOut progIn (outgoing, incoming) finalResult -> SessionChain prog progOut progIn (Cons (Choice jumps) Nil, Cons (Choice jumps) Nil) (outgoing, incoming) finalResult | | sselect :: forall prog prog' progOut progIn label jumps outgoing incoming len jumpTarget. (Dual prog prog', ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn, TyListLength jumps len, SmallerThan label len, TypeNumberToInt label, TyListIndex jumps label (Cons (Jump jumpTarget) Nil), SWellFormedConfig jumpTarget (D0 E) prog, SWellFormedConfig jumpTarget (D0 E) prog', TyListIndex progOut jumpTarget (MVar (ProgramCell (Cell outgoing))), TyListIndex progIn jumpTarget (MVar (ProgramCell (Cell incoming)))) => label -> SessionChain prog progOut progIn (Cons (Choice jumps) Nil, Cons (Choice jumps) Nil) (outgoing, incoming) () | | ssend :: forall t prog prog' progOut progIn nxt incoming. (Dual prog prog', ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn) => t -> SessionChain prog progOut progIn (Cons t nxt, incoming) (nxt, incoming) () | | srecv :: forall t prog prog' progOut progIn nxt outgoing. (Dual prog prog', ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn) => SessionChain prog progOut progIn (outgoing, Cons t nxt) (outgoing, nxt) t | | run :: forall prog prog' progOut progIn init fromO fromI toO toI toO' toI' res res'. (Dual prog prog', Dual prog' prog, ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn, SWellFormedConfig init (D0 E) prog, SWellFormedConfig init (D0 E) prog', TyListIndex progOut init (MVar (ProgramCell (Cell fromO))), TyListIndex progIn init (MVar (ProgramCell (Cell fromI)))) => prog -> init -> SessionChain prog progOut progIn (fromO, fromI) (toO, toI) res -> SessionChain prog' progIn progOut (fromI, fromO) (toO', toI') res' -> IO (res, res') | | data End | | | | | | data Jump l | | data Select | | data Offer | | jump :: TyNum n => n -> Cons (Jump n) Nil | | end :: Cons End Nil | | select :: SListOfJumps (Cons val nxt) => Cons val nxt -> Cons (Select (Cons val nxt)) Nil | | offer :: SListOfJumps (Cons val nxt) => Cons val nxt -> Cons (Offer (Cons val nxt)) Nil | | class Dual a b | a -> b, b -> a where | | | (~>) :: (TyList nxt, SNonTerminal a, SValidSessionType nxt) => a -> nxt -> Cons a nxt | | (~|~) :: (TyNum target, TyList nxt) => target -> nxt -> Cons (Cons (Jump target) Nil) nxt | | class SWellFormedConfig idxA idxB ss | | testWellformed :: SWellFormedConfig idxA idxB ss => ss -> idxA -> idxB -> Bool | | data Cons | | cons :: TyList n => t -> n -> Cons t n | | data Nil | | nil :: Nil | | data E = E | | data D0 n = D0 n | | data D1 n = D1 n | | data D2 n = D2 n | | data D3 n = D3 n | | data D4 n = D4 n | | data D5 n = D5 n | | data D6 n = D6 n | | data D7 n = D7 n | | data D8 n = D8 n | | data D9 n = D9 n | | module Control.Concurrent.Session.SMonad | | emptyMap :: TyMap Nil Nil | | module Control.Concurrent.Session.Interleaving |
|
|
Documentation |
|
|
Use OfferImpls to construct the implementations of the branches
of an offer. Really, it's just a slightly fancy list.
| Constructors | OfferImplsNil :: OfferImpls Nil prog progOut progIn finalState finalResult | |
|
|
|
|
Use to construct OfferImpls. This function automatically adds the
necessary sjump to the start of each branch implementation.
|
|
|
Perform a jump. Now you may think that you should indicate where
you want to jump to. But of coures, that's actually specified by
the session type so you don't have to specify it at all in the
implementation.
|
|
|
Offer a number of branches. This is basically an external choice
- the other party uses sselect to decide which branch to take.
Use OfferImpls in order to construct the list of implementations of
branches. Note that every implementation must result in the same
final state and emit the same value.
|
|
sselect :: forall prog prog' progOut progIn label jumps outgoing incoming len jumpTarget. (Dual prog prog', ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn, TyListLength jumps len, SmallerThan label len, TypeNumberToInt label, TyListIndex jumps label (Cons (Jump jumpTarget) Nil), SWellFormedConfig jumpTarget (D0 E) prog, SWellFormedConfig jumpTarget (D0 E) prog', TyListIndex progOut jumpTarget (MVar (ProgramCell (Cell outgoing))), TyListIndex progIn jumpTarget (MVar (ProgramCell (Cell incoming)))) => label -> SessionChain prog progOut progIn (Cons (Choice jumps) Nil, Cons (Choice jumps) Nil) (outgoing, incoming) () | Source |
|
Select which branch we're taking at a branch point. Use a type
number (Control.Concurrent.Session.Number) to indicate the branch
to take.
|
|
|
Send a value to the other party. Of course, the value must be of
the correct type indicated in the session type.
|
|
|
Recieve a value from the other party. This will block as
necessary. The type of the value received is specified by the
session type. No magic coercion needed.
|
|
run :: forall prog prog' progOut progIn init fromO fromI toO toI toO' toI' res res'. (Dual prog prog', Dual prog' prog, ProgramToMVarsOutgoing prog progOut, ProgramToMVarsOutgoing prog' progIn, SWellFormedConfig init (D0 E) prog, SWellFormedConfig init (D0 E) prog', TyListIndex progOut init (MVar (ProgramCell (Cell fromO))), TyListIndex progIn init (MVar (ProgramCell (Cell fromI)))) => prog -> init -> SessionChain prog progOut progIn (fromO, fromI) (toO, toI) res -> SessionChain prog' progIn progOut (fromI, fromO) (toO', toI') res' -> IO (res, res') | Source |
|
Run! Provide a program and a start point within that program
(which is automatically sjumped to), the two implementations
which must be duals of each other, run them, have them communicate,
wait until they both finish and die and then return the results
from both of them.
|
|
|
Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Instances | |
|
|
|
Instances | |
|
|
|
Instances | |
|
|
|
|
|
|
|
|
|
|
class Dual a b | a -> b, b -> a where | Source |
|
| Methods | | | Instances | |
|
|
|
|
|
|
class SWellFormedConfig idxA idxB ss | Source |
|
|
|
|
|
|
Instances | (TyListDrop cnt' nxt lst, Pred cnt cnt') => TyListDrop cnt (Cons val nxt) lst | TyListTake (D0 E) (Cons val nxt) Nil | (TyListTake cnt' nxt nxt', Pred (D9 r) cnt') => TyListTake (D9 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D8 r) cnt') => TyListTake (D8 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D7 r) cnt') => TyListTake (D7 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D6 r) cnt') => TyListTake (D6 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D5 r) cnt') => TyListTake (D5 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D4 r) cnt') => TyListTake (D4 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D3 r) cnt') => TyListTake (D3 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D2 r) cnt') => TyListTake (D2 r) (Cons val nxt) (Cons val nxt') | (TyListTake cnt' nxt nxt', Pred (D1 r) cnt') => TyListTake (D1 r) (Cons val nxt) (Cons val nxt') | TyListDrop (D0 E) (Cons val nxt) (Cons val nxt) | (TyListLength n l, Succ l l', Show n, Show t) => Show (Cons t n) | TyList nxt => TyList (Cons val nxt) | (SValidSessionType nxt, SNonTerminal val) => SValidSessionType (Cons val nxt) | STerminal a => SValidSessionType (Cons a Nil) | (SValidSessionType val, SListOfSessionTypes nxt) => SListOfSessionTypes (Cons val nxt) | (SListOfJumps nxt, TyNum val) => SListOfJumps (Cons (Cons (Jump val) Nil) nxt) | (TyListLength n len, Succ len len') => TyListLength (Cons t n) len' | (OnlyOutgoing nxt nxt', TyList nxt, TyList nxt') => OnlyOutgoing (Cons (Recv t) nxt) nxt' | (SNoJumpsBeyond val idx, SNoJumpsBeyond nxt idx) => SNoJumpsBeyond (Cons val nxt) idx | (TyListReverse' nxt (Cons v acc) n, TyList acc) => TyListReverse' (Cons v nxt) acc n | (TyListIndex nxt idx' res, Pred idx idx', SmallerThan idx' len, TyListLength nxt len) => TyListIndex (Cons val nxt) idx res | (Succ acc acc', TyListElem' nxt acc' val idx) => TyListElem' (Cons val' nxt) acc val idx | TyListElem' (Cons val nxt) idx val idx | TyListAppend nxt b nxt' => TyListAppend (Cons val nxt) b (Cons val nxt') | TyListIndex (Cons res nxt) (D0 E) res | OnlyOutgoing (Cons (Offer jl) Nil) (Cons (Choice jl) Nil) | OnlyOutgoing (Cons (Select jl) Nil) (Cons (Choice jl) Nil) | OnlyOutgoing (Cons (Jump l) Nil) (Cons (Jump l) Nil) | (OnlyOutgoing nxt nxt', TyList nxt, TyList nxt') => OnlyOutgoing (Cons (Send t) nxt) (Cons t nxt') | OnlyOutgoing (Cons End Nil) (Cons End Nil) | (TyList nxt, TyList nxt', Dual val val', Dual nxt nxt') => Dual (Cons val nxt) (Cons val' nxt') | (ProgramToMVarsOutgoing nxt nxt', OnlyOutgoing val val', TyList nxt, TyList nxt') => ProgramToMVarsOutgoing (Cons val nxt) (Cons (MVar (ProgramCell (Cell val'))) nxt') |
|
|
|
|
|
|
Instances | |
|
|
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
module Control.Concurrent.Session.SMonad |
|
|
|
module Control.Concurrent.Session.Interleaving |
|
Produced by Haddock version 2.3.0 |