Skip to content

Instantly share code, notes, and snippets.

@bhb
Created June 26, 2017 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhb/c8d01c455494921a3698a9cf951272ff to your computer and use it in GitHub Desktop.
Save bhb/c8d01c455494921a3698a9cf951272ff to your computer and use it in GitHub Desktop.
An example of map-of and `in`
;;[org.clojure/clojure "1.9.0-alpha17"]
;;[org.clojure/clojurescript "1.9.542"]
;;[org.clojure/spec.alpha "0.1.123"]
(s/def :foo/user-map (s/map-of string? int?))
(s/explain-data :foo/user-map {"hi" "foo"})
;; Actual value:
;; #:cljs.spec.alpha{:problems
;; ({:path [1],
;; :pred int?,
;; :val "foo",
;; :via [:foo/user-map],
;; :in ["hi" 1]})}
;; Expected: the `:in` value to be ["hi"] ?
(s/explain-data :foo/user-map {:hi 2})
;; Actual value:
;; #:cljs.spec.alpha{:problems
;; ({:path [0],
;; :pred string?,
;; :val :hi,
;; :via [:foo/user-map],
;; :in [:hi 0]})}
;; Expected: I'm not sure. I can see the trouble with identifying the key itself.
;; Perhaps `[:hi 0]` indicates something like "find the key-value pair for :hi, then
;; get the 0th element of that key-value pair (i.e. the key)" ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment