diff --git a/syndicate/assertions.rkt b/syndicate/assertions.rkt new file mode 100644 index 0000000..c91e42d --- /dev/null +++ b/syndicate/assertions.rkt @@ -0,0 +1,24 @@ +#lang racket/base + +(provide message-struct + assertion-struct + (struct-out observe) + (struct-out seal) + (struct-out inbound) + (struct-out outbound)) + +;; Thin veneers over `struct` for declaring intent. +(define-syntax-rule (assertion-struct item ...) (struct item ... #:prefab)) +(define-syntax-rule (message-struct item ...) (struct item ... #:prefab)) + +(assertion-struct observe (specification)) + +;; Seals are used by protocols to prevent routing from examining +;; internal structure of values. +(struct seal (contents) ;; NB. Neither transparent nor prefab + #:methods gen:custom-write + [(define (write-proc s port mode) + (fprintf port "#{~v}" (seal-contents s)))]) + +(struct inbound (assertion) #:prefab) +(struct outbound (assertion) #:prefab) diff --git a/syndicate/dataspace.rkt b/syndicate/dataspace.rkt index 2d2d7d6..778122c 100644 --- a/syndicate/dataspace.rkt +++ b/syndicate/dataspace.rkt @@ -5,11 +5,6 @@ with-non-script-context ;; TODO: shouldn't be provided run-scripts! ;; TODO: how to cleanly provide this? - message-struct - assertion-struct - (struct-out observe) - (struct-out seal) - dataspace? dataspace-assertions ;; TODO: shouldn't be provided - needed by test.rkt generate-id! ;; TODO: shouldn't be provided - inline syntax.rkt?? @@ -66,20 +61,6 @@ (require "pattern.rkt") (require "bag.rkt") -;; TODO: move somewhere sensible -;; Thin veneers over `struct` for declaring intent. -(define-syntax-rule (assertion-struct item ...) (struct item ... #:prefab)) -(define-syntax-rule (message-struct item ...) (struct item ... #:prefab)) - -(assertion-struct observe (specification)) - -;; Seals are used by protocols to prevent routing from examining -;; internal structure of values. -(struct seal (contents) ;; NB. Neither transparent nor prefab - #:methods gen:custom-write - [(define (write-proc s port mode) - (fprintf port "#{~v}" (seal-contents s)))]) - ;; An `ActorID` uniquely identifies an actor in a `Dataspace`. ;; A `FID` is a Facet ID, uniquely identifying a facet in a `Dataspace`. diff --git a/syndicate/main.rkt b/syndicate/main.rkt index 0f02183..606cf09 100644 --- a/syndicate/main.rkt +++ b/syndicate/main.rkt @@ -1,6 +1,7 @@ #lang racket/base (provide (all-from-out "dataspace.rkt") + (all-from-out "assertions.rkt") (all-from-out "syntax.rkt") (all-from-out "ground.rkt") (all-from-out "relay.rkt")) @@ -8,6 +9,7 @@ (module reader syntax/module-reader imperative-syndicate/lang) (require "dataspace.rkt") +(require "assertions.rkt") (require "syntax.rkt") (require "ground.rkt") (require "relay.rkt") diff --git a/syndicate/relay.rkt b/syndicate/relay.rkt index 71316d4..62fe108 100644 --- a/syndicate/relay.rkt +++ b/syndicate/relay.rkt @@ -11,13 +11,12 @@ ;; tuples themselves - right?? Oh, maybe observing the observers would ;; be an, er, observable difference.) -(provide (struct-out inbound) - (struct-out outbound) - quit-dataspace! +(provide quit-dataspace! dataspace) (require racket/match) (require racket/set) +(require "assertions.rkt") (require "dataspace.rkt") (require "syntax.rkt") (require "skeleton.rkt") @@ -28,9 +27,6 @@ (require (for-syntax syntax/parse)) (require "syntax-classes.rkt") -(struct inbound (assertion) #:prefab) -(struct outbound (assertion) #:prefab) - (struct *quit-dataspace* () #:transparent) ;; TODO: inbound^n, outbound^n -- protocol/standard-relay, iow diff --git a/syndicate/skeleton.rkt b/syndicate/skeleton.rkt index f025204..44eb615 100644 --- a/syndicate/skeleton.rkt +++ b/syndicate/skeleton.rkt @@ -18,6 +18,8 @@ (require racket/list) (require "bag.rkt") +(require "pattern.rkt") +(require "assertions.rkt") (module+ test (require rackunit)) diff --git a/syndicate/syntax.rkt b/syndicate/syntax.rkt index 1b39580..88b21f3 100644 --- a/syndicate/syntax.rkt +++ b/syndicate/syntax.rkt @@ -62,6 +62,7 @@ (require (for-syntax syntax/srcloc)) (require "syntax-classes.rkt") +(require "assertions.rkt") (require "dataspace.rkt") (require (submod "dataspace.rkt" priorities)) (require "event-expander.rkt")