Replying to myself : )

My "good enough" solution, in case it's of use to others, is

(defn set-hierarchy-root! [x root]
  (if-let [p (-> x parents first)]
    (set-hierarchy-root! p root)
    (derive x root)))

(defn with-root [x root]
  (when-not (isa? x root)
    (set-hierarchy-root! x root))
  x)

Then the dispatch function looks like:

(defmulti combine (fn [x y] [(with-root (:type x) ::shape) (with-root (:type y) 
::shape)]))

So, at the cost of an extra call to isa? on every dispatch, any newly seen 
values (or their final ancestor already in the hierarchy, if any) are 
automatically declared as being derived from ::shape.

Not pretty, but it has the benefit of not needing to know the full set of 
possible values in advance.

T

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to