(* An example with session types *) #load "libthread" #load "libsessiontype" open SessionType type protocol = !int; !int; ?int; 1 let server c = let (x, c) = recv c in let (y, c) = recv c in send (x + y) c; () let client c x y = let c = send x c in let c = send y c in let (r, _) = recv c in r let main x y = let rv : protocol rendezvous = newRendezvous () in AThread.fork (λ _ → server (accept rv)); client (request rv) x y in print (main 3 4)