simplest way to add a type to a map in clojure

clojure

Solution

You could attach some metadata:

(defn person [first-name last-name]
      (with-meta {:first-name first-name :last-name last-name}
                 {:type 'Person}))

(def wayne (person "Wayne" "Shorter"))

(type wayne) ;; Person

Problem

I'm searching for the lightest way to add a type to a clojure map I know i could use records for doing that but i'm wondering if i can do it with regular maps i've got a function to create a map that represent a person: ``` (defn person [first-name last-name] {:first-name first-name :last-name last-name}) ``` i would like to be able to do something like that: ``` (def wayne (person "Wayne" "Shorter")) .... (type wayne) => person ```

Original source