Module Session.Bare

module Bare: sig .. end

Session initiation and termination

val create : ?name:string -> unit -> ('a, 'b) Session.st * ('b, 'a) Session.st

create () creates a new session.

val close : Session.et -> unit

close ep closes endpoint ep.

Basic message passing

val send : 'm -> ('m * ('a, 'b) Session.st) Session.ot -> ('b, 'a) Session.st

send e ep sends e on the endpoint ep with output capability.

val receive : ('m * ('a, 'b) Session.st) Session.it -> 'm * ('a, 'b) Session.st

receive ep receives a message from the endpoint ep with input capability.

Choices

val select : (('a, 'b) Session.st -> 'm) -> 'm Session.ot -> ('b, 'a) Session.st

select f ep sends f to the peer endpoint of ep, where it is used to compute the received message.

val select_true : [> `True of ('a, 'b) Session.st ] Session.ot -> ('b, 'a) Session.st

select_true ep selects the True branch of a choice.

val select_false : [> `False of ('a, 'b) Session.st ] Session.ot -> ('b, 'a) Session.st

select_false ep selects the False branch of a choice.

val branch : ([>  ] as 'm) Session.it -> 'm

branch ep receives a selection from the endpoint ep with input capability.

Endpoint validity and identity

val is_valid : ('a, 'b) Session.st -> bool

is_valid ep determines whether ep is a valid endpoint or not.

val acquire : ('a, 'b) Session.st -> ('a, 'b) Session.st

acquire ep acquires the endpoint ep, if it is valid.

val try_acquire : ('a, 'b) Session.st -> ('a, 'b) Session.st option

try_acquire ep attempts to acquire the endpoint ep.

val same_session : ('a, 'b) Session.st -> ('c, 'd) Session.st -> bool

same_session ep ep' checks whether ep and ep' are endpoints of the same session (but not necessarily peer endpoints).

val string_of_endpoint : ('a, 'b) Session.st -> string

string_of_endpoint ep returns a textual representation of the endpoint ep.

Resumption combinators

val (@=) : (('a, 'b) Session.st -> 'm * Session.et) ->
((('a, 'b) Session.st, ('c, 'd) Session.st) Session.seq,
(('b, 'a) Session.st, ('d, 'c) Session.st) Session.seq)
Session.st -> 'm * ('c, 'd) Session.st

f @= ep evaluates f ep.

val (@>) : (('a, 'b) Session.st -> Session.et) ->
((('a, 'b) Session.st, ('c, 'd) Session.st) Session.seq,
(('b, 'a) Session.st, ('d, 'c) Session.st) Session.seq)
Session.st -> ('c, 'd) Session.st

f @> ep evaluates f ep.