Last active
December 15, 2015 00:49
-
-
Save mpenet/5175786 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(use 'clojure.core.typed) | |
;; I would like to only allow {:a 1} {:b 2} or {:a 1, :b 2} | |
(def-alias A '{:a '1}) | |
(def-alias B '{:b '2}) | |
;; naive version would be to use a Union | |
(ann foo [(U A B) -> (Value 1)]) | |
(defn foo [x] 1) | |
;; but this type checks :( | |
(cf (foo {:b 2 :a nil})) | |
;; I could create HMaps with all the possible k/v possible (and using :optional) for these | |
;; but I guess there is a better way (short of using macros). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment