simple example

This commit is contained in:
Sam Caldwell 2018-07-31 14:46:36 -04:00 committed by Sam Caldwell
parent e7e8f5e174
commit c66b62cf46
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#lang typed/syndicate/roles
;; Expected Output
;; pong: 8339
(define-type-alias ds-type
(U (Tuple String Int)
(Observe (Tuple String ★/t))))
(dataspace ds-type
(spawn ds-type
(start-facet echo
(fields)
(on (asserted (tuple "ping" (bind x Int)))
(start-facet _
(fields)
(assert (tuple "pong" x))))))
(spawn ds-type
(start-facet serve
(fields)
(assert (tuple "ping" 8339))
(on (asserted (tuple "pong" (bind x Int)))
(printf "pong: ~v\n" x)))))