Skip to content

Instantly share code, notes, and snippets.

@bcambel
Created June 6, 2016 12:10
Show Gist options
  • Select an option

  • Save bcambel/0d8a26c5a9a822a9828d1bebecefae7f to your computer and use it in GitHub Desktop.

Select an option

Save bcambel/0d8a26c5a9a822a9828d1bebecefae7f to your computer and use it in GitHub Desktop.
(def transform-keys (keys transformators))
(defmacro defvariant [name]
` (defmulti ~name
(fn [structure#]
(:f structure#))))
(defmacro defcase [name field ]
`(defmethod ~name ~field [structure#]
((~field transformators) (:data structure#))))
(defvariant transformer-func)
(mapv
(fn[field]
(defcase transformer-func field)) transform-keys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment