Fork me on GitHub

In spec 1 keywords are privileged with regards to s/keys. I’d love for spec 2 to let me define other types of values to name key specs… e.g. (s/defkey "foo" integer?) (s/keys :req-key ["foo"]) I’m not actually so bothered by string keys, as what I’d really like to do is use URI’s as keys. My use case is that we work with RDF, and it’s really annoying having to convert between URI predicates and clojure keywords… I’d like to essentially do: (def rdfs:label (URI. "http://,,,,#label")) (s/defkey rdfs:label (s/or :xsdstring string? :langstring langstring?) (s/def ::resource (s/keys :req-key [rdfs:label])) Any ideas on whether this sort of thing might be possible in spec2?


implementing my own s/keys seems like it’ll be hard work


might there be an easy way to do it that can leverage stuff in spec?

Alex Miller (Clojure team)17:10:16

the idea of keywords as names for specs is deeply embedded

Alex Miller (Clojure team)17:10:34

not just s/keys but every spec impl relies on that


I wouldn’t mind having a layer of indirection between the name of the spec and the URI/key

Alex Miller (Clojure team)17:10:55

we have no plans to make that


so would doing: (s/def :rdfs/label (URI. ""http://,,,,#label")) (s/def ::resource (rdf/keys :req [:rdfs/label])) not be feasible?

Alex Miller (Clojure team)17:10:55

it is possible that we might allow arbitrary metadata for specs. if we did that (and I'm not committing to it yet), then you could hang your mapping to a uri on that.

👍 4
Alex Miller (Clojure team)17:10:03

in the meantime you could create such a mapping outside spec if desired