Factor out assertion structure definitions

This commit is contained in:
Tony Garnock-Jones 2018-05-03 16:14:30 +01:00
parent fecd2f9787
commit 00d50e6700
6 changed files with 31 additions and 25 deletions

24
syndicate/assertions.rkt Normal file
View File

@ -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)

View File

@ -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`.

View File

@ -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")

View File

@ -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

View File

@ -18,6 +18,8 @@
(require racket/list)
(require "bag.rkt")
(require "pattern.rkt")
(require "assertions.rkt")
(module+ test (require rackunit))

View File

@ -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")