forked from proglang/ldgv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-- Simple example of Label-Dependent Session Types | ||
-- Interprets addition of two numbers | ||
|
||
type SendInt : ! ~ssn = !Int. ?Int. !Int. ?Int. Unit | ||
type SendIntClient : ! ~ssn = !Int. ?Int. Unit | ||
type SendSendIntClient : ! ~ssn = !SendIntClient. Unit | ||
type SendIntServer : ! ~ssn = ?Int. !Int. Unit | ||
type SendSendIntServer : ! ~ssn = !SendIntServer. Unit | ||
|
||
val send2 (c: SendInt) = | ||
let x = ((send c) 1) in | ||
let <n, x2> = recv x in | ||
let y = ((send x2) 41) in | ||
let <m, y2> = recv y in | ||
let y3 = end y2 in | ||
(m + n) | ||
|
||
val add2 (c1: dualof SendInt) = | ||
let <m, c2> = recv c1 in | ||
let c22 = (send c2) 1300 in | ||
let <n, c3> = recv c22 in | ||
let c32 = (send c3) 37 in | ||
let c4 = end c32 in | ||
(m + n) | ||
|
||
val main : Int | ||
val main = | ||
let sock = (create 4343) in | ||
let con = (connect sock SendInt "127.0.0.1" 4242 ) in -- This cannot be localhost, since this might break on containerized images | ||
let x = ((send con) 1) in | ||
let <n, x2> = recv x in | ||
let con2 = (connect sock SendSendIntClient "127.0.0.1" 4340) in | ||
let con22 = ((send con2) x2) in | ||
let con23 = end con22 in | ||
(n) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- Simple example of Label-Dependent Session Types | ||
-- Interprets addition of two numbers | ||
|
||
type SendInt : ! ~ssn = !Int. ?Int. !Int. ?Int. Unit | ||
type SendIntClient : ! ~ssn = !Int. ?Int. Unit | ||
type SendSendIntClient : ! ~ssn = !SendIntClient. Unit | ||
type SendIntServer : ! ~ssn = ?Int. !Int. Unit | ||
type SendSendIntServer : ! ~ssn = !SendIntServer. Unit | ||
|
||
val send2 (c: SendInt) = | ||
let x = ((send c) 1) in | ||
let <n, x2> = recv x in | ||
let y = ((send x2) 41) in | ||
let <m, y2> = recv y in | ||
let y3 = end y2 in | ||
(m + n) | ||
|
||
val add2 (c1: dualof SendInt) = | ||
let <m, c2> = recv c1 in | ||
let c22 = (send c2) 1300 in | ||
let <n, c3> = recv c22 in | ||
let c32 = (send c3) 37 in | ||
let c4 = end c32 in | ||
(m + n) | ||
|
||
val main : Int | ||
val main = | ||
let sock = (create 4340) in | ||
let con = (accept sock (dualof SendSendIntClient)) in -- This cannot be localhost, since this might break on containerized images | ||
let <talk, y> = (recv con) in | ||
let x = ((send talk) 41) in | ||
let <n, x2> = recv x in | ||
let con2 = end x2 in | ||
(n) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- Simple example of Label-Dependent Session Types | ||
-- Interprets addition of two numbers | ||
|
||
type SendInt : ! ~ssn = !Int. ?Int. !Int. ?Int. Unit | ||
type SendIntClient : ! ~ssn = !Int. ?Int. Unit | ||
type SendSendIntClient : ! ~ssn = !SendIntClient. Unit | ||
type SendIntServer : ! ~ssn = ?Int. !Int. Unit | ||
type SendSendIntServer : ! ~ssn = !SendIntServer. Unit | ||
|
||
val send2 (c: SendInt) = | ||
let x = ((send c) 1) in | ||
let <n, x2> = recv x in | ||
let y = ((send x2) 41) in | ||
let <m, y2> = recv y in | ||
let y3 = end y2 in | ||
(m + n) | ||
|
||
val add2 (c1: dualof SendInt) = | ||
let <m, c2> = recv c1 in | ||
let c22 = (send c2) 1300 in | ||
let <n, c3> = recv c22 in | ||
let c32 = (send c3) 37 in | ||
let c4 = end c32 in | ||
(m + n) | ||
|
||
val main : Int | ||
val main = | ||
let sock = (create 4242) in | ||
let con = (accept sock (dualof SendInt)) in | ||
let <m, c2> = recv con in | ||
let c22 = (send c2) 1300 in | ||
let con2 = (accept sock (SendSendIntServer)) in | ||
let con3 = ((send con2) c22) in | ||
let con4 = end con3 in | ||
(m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- Simple example of Label-Dependent Session Types | ||
-- Interprets addition of two numbers | ||
|
||
type SendInt : ! ~ssn = !Int. ?Int. !Int. ?Int. Unit | ||
type SendIntClient : ! ~ssn = !Int. ?Int. Unit | ||
type SendSendIntClient : ! ~ssn = !SendIntClient. Unit | ||
type SendIntServer : ! ~ssn = ?Int. !Int. Unit | ||
type SendSendIntServer : ! ~ssn = !SendIntServer. Unit | ||
|
||
val send2 (c: SendInt) = | ||
let x = ((send c) 1) in | ||
let <n, x2> = recv x in | ||
let y = ((send x2) 41) in | ||
let <m, y2> = recv y in | ||
let y3 = end y2 in | ||
(m + n) | ||
|
||
val add2 (c1: dualof SendInt) = | ||
let <m, c2> = recv c1 in | ||
let c22 = (send c2) 1300 in | ||
let <n, c3> = recv c22 in | ||
let c32 = (send c3) 37 in | ||
let c4 = end c32 in | ||
(m + n) | ||
|
||
val main : Int | ||
val main = | ||
let sock = (create 4240) in | ||
let con = (connect sock (dualof SendSendIntServer) "127.0.0.1" 4242) in | ||
let <talk, c1> = recv con in | ||
let <m, c2> = recv talk in | ||
let c22 = (send c2) 37 in | ||
let con4 = end c22 in | ||
(m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters