diff --git a/rs.rkt b/rs.rkt index aa62ed5..9d85ed1 100644 --- a/rs.rkt +++ b/rs.rkt @@ -4,7 +4,7 @@ (require typed/graph "utils.rkt" "dynamics.rkt") (provide - Species (struct-out reaction) Reaction ReactionSystem + Species (struct-out reaction) Reaction ReactionName ReactionSystem make-reaction enabled? list-enabled) (module+ test @@ -18,6 +18,8 @@ #:transparent #:type-name Reaction) + (define-type ReactionName Symbol) + (: make-reaction (-> (Listof Species) (Listof Species) (Listof Species) Reaction)) (define (make-reaction r i p) (reaction (list->set r) (list->set i) @@ -41,9 +43,9 @@ (check-false (enabled? (make-reaction '(a b) '(c d) '()) (set 'b 'e))))) - (define-type ReactionSystem (HashTable Symbol Reaction)) + (define-type ReactionSystem (HashTable ReactionName Reaction)) - (: list-enabled (-> ReactionSystem (Setof Species) (Listof Symbol))) + (: list-enabled (-> ReactionSystem (Setof Species) (Listof ReactionName))) (define (list-enabled rs s) (for/list ([(name reaction) (in-hash rs)] #:when (enabled? reaction s)) diff --git a/scribblings/rs.scrbl b/scribblings/rs.scrbl index 05007e4..ad60f8a 100644 --- a/scribblings/rs.scrbl +++ b/scribblings/rs.scrbl @@ -47,6 +47,12 @@ The type of the instances of @racket[reaction]. } +@deftype[ReactionName]{ + +A reaction name is any @racket[Symbol]. + +} + @defproc[(make-reaction [r (Listof Reaction)] [i (Listof Reaction)] [p (Listof Reaction)]) @@ -75,12 +81,13 @@ reactants are in the set and none of its inhibitors are. @deftype[ReactionSystem]{ -A reaction system is a dictionary mapping reaction names -(@racket[Symbol]s) to @racket[Reaction]s. +A reaction system is a dictionary mapping @racket[ReactionName]s to +@racket[Reaction]s. } -@defproc[(list-enabled [rs ReactionSystem] [s (Setof Species)]) (Listof Symbol)]{ +@defproc[(list-enabled [rs ReactionSystem] [s (Setof Species)]) + (Listof ReactionName)]{ Returns the list of the names of reactions of @racket[rs] enabled on @racket[s].