Last active
July 13, 2017 17:04
-
-
Save moxaj/1b0b824e90abf777950ce710861624eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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