| full-sessions-0.4.189: yet another implementation of session types which does not require annotations | Source code | Contents | Index |
|
Control.Concurrent.FullSession.Session |
|
|
|
Synopsis |
|
newtype Session t ss tt a = Session (IO a) | | runS :: (IsEnded ss T, Ended l ss, Length ss l) => (forall t. Session t Nil ss a) -> IO a | | (>>>=) :: Session t ss tt a -> (a -> Session t tt uu b) -> Session t ss uu b | | ireturn :: a -> Session t ss ss a | | io :: IO a -> Session t ss ss a | | new :: Length ss l => Session t ss (Cap Nil Bot :|: ss) (Channel t l) | | send :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap e (Send v s)) (Cap e s) ss tt) => Channel t n -> v -> Session t ss tt () | | recv :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap e (Recv v s)) (Cap e s) ss tt) => Channel t n -> Session t ss tt v | | sel1 :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap e (Select s x)) (Cap e s) ss tt) => Channel t n -> Session t ss tt () | | sel2 :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap e (Select x s)) (Cap e s) ss tt) => Channel t n -> Session t ss tt () | | select :: (Length ss l, Length tt l, Length uu l, Sub l (S n) n', Update n' (Cap e (Select x y)) (Cap e x) uu ss, Update n' (Cap e (Select x y)) (Cap e y) uu tt) => Channel t n -> Bool -> Session t ss xx () -> Session t tt xx () -> Session t uu xx () | | offer :: (Length ss l, Length tt l, Length uu l, Sub l (S n) n', Update n' (Cap e (Offer x y)) (Cap e x) uu ss, Update n' (Cap e (Offer x y)) (Cap e y) uu tt) => Channel t n -> Session t ss xx a -> Session t tt xx a -> Session t uu xx a | | sendS :: (Length ss l, Length tt l, Sub l (S n) n', Sub l (S m) m', Update n' (Cap e (Throw u' u)) (Cap e u) ss tt', Update m' (Cap e' u') (Cap e' End) tt' tt) => Channel t n -> Channel t m -> Session t ss tt () | | recvS :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap e (Catch u' u)) (Cap e u) ss tt) => Channel t n -> Session t ss (Cap Nil u' :|: tt) (Channel t l) | | sendS_new :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap e (Throw u' u)) (Cap e u) ss tt, Comp2 u' u'') => Channel t n -> Session t ss (Cap Nil u'' :|: tt) (Channel t l) | | forkIO :: (Length ss l, Length tt' l, Length tt l, Length ss' l', Ended l' ss', IsEnded ss' T, Par ss tt' tt) => Session t ss ss' () -> Session t tt tt' ThreadId | | forkOS :: (Length ss l, Length tt' l, Length tt l, Length ss' l', Ended l' ss', IsEnded ss' T, Par ss tt' tt) => Session t ss ss' () -> Session t tt tt' ThreadId | | forkOS_ :: (Length ss l, Length tt' l, Length tt l, Length ss' l', Ended l' ss', IsEnded ss' T, Par ss tt' tt) => Session t ss ss' () -> Session t tt tt' () | | forkIO_ :: (Length ss l, Length tt' l, Length tt l, Length ss' l', Ended l' ss', IsEnded ss' T, Par ss tt' tt) => Session t ss ss' () -> Session t tt tt' () | | enter :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap e (Rec r)) (Cap (r :|: e) r) ss tt) => Channel t n -> Session t ss tt () | | zero :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap (r :|: e) (Var Z)) (Cap (r :|: e) r) ss tt) => Channel t n -> Session t ss tt () | | suc :: (Length ss l, Length tt l, Sub l (S n) n', Update n' (Cap (r :|: e) (Var (S v))) (Cap e (Var v)) ss tt) => Channel t n -> Session t ss tt () | | recur :: (Sub l2 l d, AppendEnd d ss ss', Sub l2 (S n) n', EndedWithout n' l2 x ss', Length ss l, Length ss' l2, IsEnded tt' T, Length tt' l2, Ended l2 tt') => (Channel t n -> Session t ss tt ()) -> Channel t n -> Session t ss' tt' () | | class IsEnded ss b | ss -> b | | class Ended l ss | l -> ss | | class Comp s t u | s u -> t, t u -> s, s t -> u | | class Comp2 s t | s -> t, t -> s | | class Par ss tt' tt | ss tt' -> tt, ss tt -> tt', tt tt' -> ss | | class Par2 t ss tt' tt | t ss tt' -> tt, t ss tt -> tt', t tt tt' -> ss | | class EndedWithout n l s ss | n l s -> ss | | class AppendEnd n ss ss' | n ss -> ss', n ss' -> ss | | typecheck :: (Ended l ss, Length ss l, IsEnded ss T) => Session t Nil ss a -> Session t Nil ss a | | typecheck' :: Session t Nil ss a -> Session t Nil ss a |
|
|
Documentation |
|
newtype Session t ss tt a | Source |
|
Session monad.
t is an index (like in the ST monad),
ss is the precondition of the computation,
tt is the postcondition of the computation,
and a is the return value
| Constructors | |
|
|
|
return the value computed by a session. The forall ensures that internal channels
used by the session is inaccessible to the rest of the program
|
|
|
bind for indexed monad
|
|
|
bind, discarding the result of the computation on LHS
return for indexed monad
|
|
|
run a computation of type IO a
|
|
|
create a channel
|
|
|
output on a channel
|
|
|
input on a channel
|
|
|
output a label `1'
|
|
|
output a label `2'
|
|
|
output a label
|
|
|
input a label i
|
|
|
output a channel
|
|
|
input a channel
|
|
|
create a channel, then pass it to other process
|
|
|
start a new thread
|
|
|
start a new OS thread
|
|
|
|
|
|
|
expand a (Rec u) to u (from Pucella and Tov)
|
|
|
replace (Var Z) with recursion body (from Pucella and Tov)
|
|
|
(from Pucella and Tov)
|
|
|
recursion
|
|
class IsEnded ss b | ss -> b | Source |
|
T if the all elements of ss are Cap Nil End
| | Instances | |
|
|
class Ended l ss | l -> ss | Source |
|
generates a list of ended types
| | Instances | |
|
|
class Comp s t u | s u -> t, t u -> s, s t -> u | Source |
|
sesion type algebra
| | Instances | Comp c (Cap Nil End) c | Comp (Cap Nil End) c c | (TCast v v', TCast e e', TCast e' Nil) => Comp (Cap e (Var v)) (Cap e' (Var v')) (Cap e'' Bot) | (Comp2 r r', TCast e e', TCast e' Nil) => Comp (Cap e (Rec r)) (Cap e' (Rec r')) (Cap e'' Bot) | (Comp2 u u', Comp2 v v', TCast e e', TCast e' e'', TCast e' Nil) => Comp (Cap e (Offer u v)) (Cap e' (Select u' v')) (Cap e'' Bot) | (Comp2 u u', Comp2 v v', TCast e e', TCast e' e'', TCast e' Nil) => Comp (Cap e (Select u v)) (Cap e' (Offer u' v')) (Cap e'' Bot) | (Comp2 u u', TCast v v', TCast e e', TCast e' e'', TCast e' Nil) => Comp (Cap e (Catch v u)) (Cap e' (Throw v' u')) (Cap e'' Bot) | (Comp2 u u', TCast v v', TCast e e', TCast e' e'', TCast e' Nil) => Comp (Cap e (Throw v u)) (Cap e' (Catch v' u')) (Cap e'' Bot) | (Comp2 u u', TCast t t', TCast e e', TCast e' e'', TCast e' Nil) => Comp (Cap e (Recv t' u')) (Cap e' (Send t u)) (Cap e'' Bot) | (Comp2 u u', TCast t t', TCast e e', TCast e' e'', TCast e' Nil) => Comp (Cap e (Send t u)) (Cap e' (Recv t' u')) (Cap e'' Bot) | Comp (Cap Nil End) (Cap Nil End) (Cap Nil End) |
|
|
|
class Comp2 s t | s -> t, t -> s | Source |
|
session type algebra (2)
| | Instances | Comp2 End End | TCast v v' => Comp2 (Var v) (Var v') | Comp2 r r' => Comp2 (Rec r) (Rec r') | (Comp2 u u', Comp2 v v') => Comp2 (Offer u v) (Select u' v') | (Comp2 u u', Comp2 v v') => Comp2 (Offer u v) (Select u' v') | (Comp2 u u', Comp2 v v') => Comp2 (Select u v) (Offer u' v') | (Comp2 u u', Comp2 v v') => Comp2 (Select u v) (Offer u' v') | (Comp2 u u', TCast v v') => Comp2 (Catch v u) (Throw v' u') | (Comp2 u u', TCast v v') => Comp2 (Catch v u) (Throw v' u') | (Comp2 u u', TCast v v') => Comp2 (Throw v u) (Catch v' u') | (Comp2 u u', TCast v v') => Comp2 (Throw v u) (Catch v' u') | (Comp2 u u', TCast t t') => Comp2 (Recv t' u') (Send t u) | (Comp2 u u', TCast t t') => Comp2 (Recv t' u') (Send t u) | (Comp2 u u', TCast t t') => Comp2 (Send t u) (Recv t' u') | (Comp2 u u', TCast t t') => Comp2 (Send t u) (Recv t' u') |
|
|
|
class Par ss tt' tt | ss tt' -> tt, ss tt -> tt', tt tt' -> ss | Source |
|
parallel composition
| | Instances | |
|
|
class Par2 t ss tt' tt | t ss tt' -> tt, t ss tt -> tt', t tt tt' -> ss | Source |
|
the specialized case for ended ss
| | Instances | |
|
|
class EndedWithout n l s ss | n l s -> ss | Source |
|
| Instances | |
|
|
class AppendEnd n ss ss' | n ss -> ss', n ss' -> ss | Source |
|
| Instances | |
|
|
|
|
|
|
Produced by Haddock version 2.4.2 |