a common question for spec-tools has been how to create custom specs that coerce correctly and emit valid JSON Schema (for web-stuff). I though of pasting a sample here too for adding support for ZonedDataTime
would be happy to throw away the custom wrappers for adding meta-data for specs in favour of core spec supporting that.
can I re-use a matched value within the body of spec/cat
for further pattern matching later on by referring to its key? I'm trying something like:
(def lookup {:a 1 :b 2 :c 3})
(s/cat :key keyword?
:contents (spec/* (spec/or :string string? :matched (get lookup :key))))
Is this possible?no
you can s/& at the top level and check constraints with any arbitrary predicate inside the container
ok, thanks! I think the space of possible keys in the lookup
map I'd be relying on is small enough to fully enumerate using individual specs, so I think I'll just do that instead (probably what I should have been doing from the start, but I wanted to see if I could save myself some typing 😂)
is it possible to define a spec for a function in a namespace that one doesn't control?
yes
how?
the same way?
so like
(s/fdef the-ns/the-func ...) ?
yep
ah cool. thx!
fdef always takes fq symbols and those are just keys in the registry
👍
Anyone know whether spec2 is informed by SHACL? https://youtu.be/apG5K3zc4V0
FYI there is also a #rdf channel on here, it has infrequent but good discussions on it when they occur
Thanks. Good to know :)
while I find it's usually a bad bet to say that Rich is not aware of something, as far as I know he is not aware of that. certainly a lot of the design work precedes that talk
from a quick skim of the video, both Rich and are I well-versed in RDF and OWL and that inspired many things in the design of both Clojure and Datomic (this is covered in some more detail in the History of Clojure paper https://clojure.org/about/history). I'm not sure that SHACL has anything particularly novel in it and it also makes a closed world assumption that's actually intentionally absent from spec to a large degree
I actually started using Clojure at the semweb startup Revelytix about 10 years ago and wrote a commercial federated SPARQL engine there
all in Clojure, sadly, no code survives from the company dying :(