Safe Haskell | None |
---|---|
Language | Haskell98 |
- ifThenElse :: Bool -> t -> t -> t
- data Process s a = Process {
- getProcess :: IO a
- data Session
- data Delegate = Delg Session
- type family Dual s
- type family DualP s t :: Constraint
- type family EqFix f f' s :: Constraint
- type Duality env c = DualP (env :@ Ch c) (env :@ Op c)
- type family m :@ c :: Session
- type family SessionSeq s t
- data Name
- data Chan n = forall a . MkChan (Chan a)
- type family CmpSessionMap x y
- fail :: t
- type family DistribL g
- type family DistribInsideSeq k a :: Session
- type ToFix s = ToFixP (DistribL s)
- type family ToFixPP a a' b b' :: Session
- type family ToFixP s
- type family ToFixes env :: [Map Name Session]
- type family Balanced s t :: Constraint
- type family BalancedF s t :: Constraint
- type family NotBal s :: Constraint
Documentation
ifThenElse :: Bool -> t -> t -> t Source
Process computation type indexed by an environment of the (free) channel names used in the computation, paired with a specification of their behaviour.
Process | |
|
Session types
forall a . a :! Session | Send |
forall a . a :? Session | Receive |
forall a . a :*! Session | Output |
Session :+ Session | Alternation (for branch/select) |
Bal Session | Marks a session that should |
End | End of session |
Fix Session Session | Denotes an affine fixed point, where Fix a b = a* . b |
Star | A placeholder for a recursion variable- never generated by
the encoding or produced by any operation, but set as
the session type for a recursive call in a fixed-point (see |
Effect [Map Name Session] Process Source | |
type Combine Session s t = SessionSeq s t Source | |
type Unit [Map Name Session] Process = [] (Map Name Session) Source | |
type Plus [Map Name Session] Process s t = Union Name Session s t Source | |
type Inv [Map Name Session] Process s t = Balanced s t Source | |
type Cmp (Map Name Session) ((:->) Name Session c a) ((:->) Name Session d b) = CmpSessionMap ((:->) Name Session c a) ((:->) Name Session d b) Source | Compare channel names for normalising type-level finite map representations |
Duality function: calculuate the dual of a simple, non-recursive session type
type family DualP s t :: Constraint Source
Duality relation: extends the duality function to include recursive session types
DualP End End = () | |
DualP (t :! s) (t' :? s') = (t ~ t', DualP s s') | |
DualP (t :? s) (t' :! s') = (t ~ t', DualP s s') | |
DualP (Bal s) s' = DualP s s' | |
DualP s (Bal s') = DualP s s' | |
DualP (s :+ t) (s' :+ t') = (DualP s s', DualP t t') | |
DualP (Fix a b) s = EqFix a (Fix a b) (Dual s) | |
DualP s (Fix a b) = EqFix a (Fix a b) (Dual s) |
type family EqFix f f' s :: Constraint Source
Compute fixed-point equality of session types by unrolling
EqFix a (Fix Star b) b = () | |
EqFix a (Fix Star b) s = EqFix a (Fix a b) s | |
EqFix a (Fix (t :! s) b) (t' :! s') = (t ~ t', EqFix a (Fix s b) s') | |
EqFix a (Fix (t :? s) b) (t' :? s') = (t ~ t', EqFix a (Fix s b) s') | |
EqFix a (Fix (t1 :+ t2) b) (t1' :+ t2') = (t1 ~ t1', t2 ~ t2') | |
EqFix a (Fix (t :*! s) b) (t' :*! s') = (t ~ t', EqFix a (Fix s b) s') |
type Duality env c = DualP (env :@ Ch c) (env :@ Op c) Source
Predicate over environments that channel c
has dual endpoints with dual session types
type family m :@ c :: Session Source
Lookup a channel from an enrivonment, returning End
if it is not a member
type family SessionSeq s t Source
Sequential composition of sessions
SessionSeq End (Bal s) = s | |
SessionSeq End s = s | |
SessionSeq (a :? s) t = a :? SessionSeq s t | |
SessionSeq (a :! s) t = a :! SessionSeq s t | |
SessionSeq (a :*! s) t = a :*! SessionSeq s t | |
SessionSeq (s1 :+ s2) t = SessionSeq s1 t :+ SessionSeq s2 t | |
SessionSeq (Bal s) t = SessionSeq s t | |
SessionSeq Star Star = Star |
Channel endpoint names
Effect [Map Name Session] Process Source | |
type Unit [Map Name Session] Process = [] (Map Name Session) Source | |
type Plus [Map Name Session] Process s t = Union Name Session s t Source | |
type Inv [Map Name Session] Process s t = Balanced s t Source | |
type Cmp (Map Name Session) ((:->) Name Session c a) ((:->) Name Session d b) = CmpSessionMap ((:->) Name Session c a) ((:->) Name Session d b) Source | Compare channel names for normalising type-level finite map representations |
Namec channels, encapsulating Concurrent Haskell channels
type family CmpSessionMap x y Source
Compare channel names for normalising type-level finite map representations
Normalises session types using the left-distributivity rule for effects: i.e. f * (g + h) = (f * g) + (f * h)
DistribL (a :! (s :+ t)) = DistribL (a :! s) :+ DistribL (a :! t) | |
DistribL (a :? (s :+ t)) = DistribL (a :? s) :+ DistribL (a :? t) | |
DistribL (a :? s) = DistribInsideSeq ((:?) a) (DistribL s) | |
DistribL (a :! s) = DistribInsideSeq ((:!) a) (DistribL s) | |
DistribL (a :+ b) = DistribL a :+ DistribL b | |
DistribL Star = Star | |
DistribL End = End |
type family DistribInsideSeq k a :: Session Source
Part of the normalisation procedure for left-distributivity
DistribInsideSeq k (s :+ t) = k s :+ k t | |
DistribInsideSeq k s = k s |
type ToFix s = ToFixP (DistribL s) Source
Map an affine equation on effects to the fixed point solution:
That is '(Seq Star a) :+ b' where Star
is the placeholder for a recursion variable
then 'ToFix ((Seq Star a) :+ b) = Fix a b'
type family Balanced s t :: Constraint Source
Predicate for checking that two environments are balanced
type family BalancedF s t :: Constraint Source
Side recursive case of balancing (check each var -> session type map against every other
BalancedF (c :-> s) [] = () | |
BalancedF (Ch c :-> Bal s) ((Op c :-> Bal t) : env) = t ~ Dual s | |
BalancedF (Op c :-> Bal s) ((Ch c :-> Bal t) : env) = t ~ Dual s | |
BalancedF (Ch c :-> Bal s) ((Op c :-> t) : env) = t ~ Dual s | |
BalancedF (Op c :-> Bal s) ((Ch c :-> t) : env) = t ~ Dual s | |
BalancedF (c :-> s) ((c :-> t) : env) = (NotBal s, NotBal t) | |
BalancedF (c :-> s) ((d :-> t) : env) = BalancedF (c :-> s) env |