[racket] representing delta blue's relations in typed racket
I'm implementing the delta blue algorithm in TR. Delta blue creates a
graph of variables connected by (a hierarchy of) constraints (relations
among variables). The algorithm adjusts the variables' values as you add
and remove the constraints.
Here is some fake code that shows (partially) the data structures in
delta blue's pseudo code:
;; The Variables are the nodes in the constraint graph:
(struct (Tv T ...) Variable
((value : Tv)
(constraints : (Listof (Constraint T ...))))
#:mutable
#:transparent)
;; The Consraints connect the nodes:
(struct (T ...) Constraint
((variables : (List (Variable T T ...) ...))
(methods : (List (Method T T ...) ...))
)
#:transparent
#:mutable)
;; Each Constraint comes with a set of Methods for adjusting each
;; Variable in terms of the others:
(struct (Tout T ...)
Method
((code : (-> (Constraint T ...) Tout))
(index : Natural)))
Is it possible to capture this kind of polymorphism in TR? Do I have to
give up on typing the Variables? Could I do it with macros?
--
Anthony Carrico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20150111/dfc4a34a/attachment.sig>