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

Attachment: signature.asc
Description: OpenPGP digital signature

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to