Skip to content

Instantly share code, notes, and snippets.

@moxaj
Last active July 13, 2017 17:04
Show Gist options
  • Save moxaj/1b0b824e90abf777950ce710861624eb to your computer and use it in GitHub Desktop.
Save moxaj/1b0b824e90abf777950ce710861624eb to your computer and use it in GitHub Desktop.
(require '[clojure.spec :as s])
(derive ::x ::x-or-y)
(derive ::y ::x-or-y)
(defmulti multifn first)
(defmethod multifn ::x-or-y [_]
(s/tuple keyword? number?))
(defmethod multifn ::z [_]
(s/tuple keyword? string?))
(s/def ::my-spec
(s/and (s/multi-spec multifn (fn [value tag]
(assoc value 0 tag)))
#(empty? (descendants (first %)))))
(s/exercise ::my-spec) ;; Only generates ::z :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment