Skip to content

Instantly share code, notes, and snippets.

@ajchemist
Last active March 15, 2017 03:21
Show Gist options
  • Save ajchemist/93b5d5e8e40bde79c5a1d60da543910f to your computer and use it in GitHub Desktop.
Save ajchemist/93b5d5e8e40bde79c5a1d60da543910f to your computer and use it in GitHub Desktop.
(ns interface.a)
(defprotocol X
(x [this]))
(ns interface.b)
(defprotocol X
(x [this]))
(ns test.defrecord)
(defrecord Example []
interface.a/X
(x [_] :a)
interface.b/X
(x [_] :b))
(interface.a/x (->Example)) ; => :a
(interface.b/x (->Example)) ; => :a (not :b)
(defrecord Example [])
(extend-type Example interface.a/X (x [_] :a) interface.b/X (x [_] :b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment