Created
October 2, 2013 20:47
-
-
Save nathanic/6800305 to your computer and use it in GitHub Desktop.
Nathan fails to understand something about assoc'ing onto an HMap with :optional keys
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
(ns example.typetest | |
(:use [clojure.core.typed])) | |
; using [org.clojure/core.typed "0.2.13"] | |
(def-alias House "a House has some :people in it and maybe a :mortgage." | |
(HMap :mandatory {:id String | |
:people (Coll String) | |
} | |
; comment out this :optional line and it all works | |
:optional {:mortgage Number} | |
)) | |
(ann my-house House) | |
(def my-house {:id "foo", :people ["Larry" "Curly" "Moe"]}) | |
(comment | |
(check-ns) ;=> success | |
(cf (assoc my-house :people ["Shemp"]) House) | |
;; this will return `House` if the :optional field above is commented out. | |
;; | |
;; but if the :optional field is left in the def-alias above, I get: | |
;Type Error (...) Cannot assoc args `[(Value :people) {:then tt, :else ff}] [[(Value "Shep")] {:then tt, :else ff}]` on typetest/House | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment