On Sat, Aug 14, 2010 at 5:32 AM, Matthew Phillips <mattp...@gmail.com> wrote: > > One idea that I tried was to use extend-type on a protocol, say to > extend any Node to be a PrettyPrintableNode. Obviously this didn't > work, and I'm not sure it actually makes semantic sense, but it's > interesting that was my intuitive action. > I played with that kind of things a bit and come up with a - very alpha - library some time ago.
I called it type classes because it does a part of what Haskell's type classes do. You can define a rule: Node => PrettyPrintableNode (implementation of PrettyPrintableNode using Node) And it extends Object with a default implementatiuon of protocol PrettyPrintable, that just takes the object it is called on, looks at its type, and try to apply the rules it can apply to it (You could have a rule NodeV2-25 => PrettyFormatable and another PrettyFormatable, ... => PrettyPrintable). If it finds a non-cyclic path to construct a PrettyPrintable instance, it extend the types with the right protocols implementation, and recalls the function. I planned to improve on it, but it seems there were a really low interest for this kind of thing on the list when I posted. I wouldn't recommand to use it in this state, but if you want to have a look at the code: https://nicolasoury.repositoryhosting.com/trac/nicolasoury_type-classes Best, Nicolas. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en