This commit is contained in:
Sam Caldwell 2018-08-14 17:02:39 -04:00 committed by Sam Caldwell
parent 0f2469c364
commit 86330bde03
2 changed files with 36 additions and 3 deletions

View File

@ -0,0 +1,21 @@
#lang typed/syndicate/roles
;; Expected Output
;; f: 0
;; f: 18
(define-type-alias ds-type
(U (Tuple String Int)
(Observe ★/t)))
(dataspace ds-type
(spawn ds-type
(start-facet server
(field [f Int 0])
(begin/dataflow
(printf "f = ~v\n" (ref f)))
(on (asserted (tuple "key" (bind v Int)))
(set! f v))))
(spawn ds-type
(start-facet client
(assert (tuple "key" 18)))))

View File

@ -6,12 +6,12 @@
require only-in
;; Types
Int Bool String Tuple Bind Discard List
Role Reacts Shares Know ¬Know Message Stop
Role Reacts Shares Know ¬Know Message OnDataflow Stop OnStart OnStop
FacetName Field ★/t
Observe Inbound Outbound Actor U
Computation Value Endpoints Roles Spawns
;; Statements
let let* if spawn dataspace start-facet set! begin stop #;unsafe-do
let let* if spawn dataspace start-facet set! begin stop begin/dataflow #;unsafe-do
;; Derived Forms
during define/query-value define/query-set
;; endpoints
@ -76,7 +76,7 @@
(define-type-constructor Message #:arity = 1)
(define-type-constructor Field #:arity = 1)
(define-type-constructor Bind #:arity = 1)
(define-base-types OnStart OnStop MakesField)
(define-base-types OnStart OnStop OnDataflow MakesField)
(define-for-syntax field-prop-name 'fields)
@ -812,6 +812,18 @@
( : ★/t)
( ep (τ-r))]])
(define-typed-syntax (begin/dataflow s ...+)
[ (begin s ...) s-
( : _)
( ep (~effs))
( f (~effs τ-f ...))
( s (~effs τ-s ...))]
#:with τ-r (type-eval #'(Reacts OnDataflow τ-f ... τ-s ...))
--------------------------------------------------
[ (syndicate:begin/dataflow s-)
( : ★/t)
( ep (τ-r))])
;; pat -> ([Id Type] ...)
(define-for-syntax (pat-bindings stx)
(syntax-parse stx