clojurealgebraic-data-typesclojure-contrib

Where did defadt go in new clojure contrib?


So digging around trying to figure out how to do ADTs in Clojure I run into the old clojure-contrib which is well and good except that it's been replaced. Ok no big deal, just go look through the replaced clojure-contrib's catalog of broken apart libraries, but for the life of me I cannot find where defadt was migrated in the new clojure-contrib broken up libraries.

So where has it migrated to?

I've been looking around http://dev.clojure.org/display/doc/Clojure+Contrib+Libraries but can't figure it out.

bonus points if you can give me the string to hand to alembic.still/distill to get it to plug it in for me.


Solution

  • The usual style in Clojure isn't to define ADTs. I'd regard the defadt functionality as old / deprecated.

    Instead, consider defining your data structures using regular Clojure maps or vectors.

    Alternatively you could use deftype or defrecord if you want a named type which can be used for polymorphic dispatch using protocols. This is a flexible and fast way of getting ADT-like behaviour.