Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stuarthalloway
Created June 17, 2017 14:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuarthalloway/ac16b8120e7a266e330d5fb456735e6e to your computer and use it in GitHub Desktop.
Save stuarthalloway/ac16b8120e7a266e330d5fb456735e6e to your computer and use it in GitHub Desktop.
(require '[clojure.spec.alpha :as s])
(s/def ::coord nat-int?)
(s/def ::x ::coord)
(s/def ::y ::coord)
(s/def ::xy (s/keys :req-un [::x ::y]))
(s/def ::point (s/map-of #{:point} ::xy))
(s/def ::username (s/and string? seq))
(s/def ::user (s/map-of #{:user} ::username))
(s/def ::vector-entry (s/or :point ::point :user ::user))
(s/def ::my-vector (s/coll-of ::vector-entry :kind vector))
(s/valid? ::point {:point {:x 0 :y 0}})
(s/valid? ::my-vector [{:point {:x 0 :y 0}}])
(s/valid? ::my-vector [{:point {:x 0 :y 0}} {:user "joe"}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment