From 20a50967c52e74dedf42561fc2ecf6087669b380 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 27 Jun 2014 16:25:26 -0400 Subject: [PATCH] filter-event --- minimart/core.rkt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/minimart/core.rkt b/minimart/core.rkt index 05e321d..511d52a 100644 --- a/minimart/core.rkt +++ b/minimart/core.rkt @@ -35,6 +35,7 @@ sub pub gestalt-accepts? + filter-event send feedback @@ -131,6 +132,14 @@ (match-define (message b ml f?) m) (not (set-empty? (gestalt-match-value g b ml f?)))) +;; (Option Event) Gestalt -> (Option Event) +;; Returns a filtered version of e, narrowed to the perspective of g-filter. +(define (filter-event e g-filter) + (match e + [#f #f] + [(routing-update g) (routing-update (gestalt-filter g g-filter))] + [(? message? m) (and (gestalt-accepts? g-filter m) m)])) + ;; Behavior Any [Gestalt] -> Action ;; Constructs a spawn Action for a new process with the given behavior ;; and state. If a Gestalt is supplied, the new process will begin its