Fork me on GitHub
#clojure-spec
<
2016-09-06
>
noprompt17:09:58

are there any explanations of how to properly implement clojure.spec.Spec?

noprompt17:09:33

i ask because i'm interested in integrating a small parser combinator library i wrote with clojure.spec so i can hook into to the conform, explain, etc. goodness without having to do it manually post-hoc.

noprompt17:09:13

it seems like a useful thing since, on occasion, one might be interested in validating/conforming nested (or unnested) textual data.

Alex Miller (Clojure team)17:09:19

@noprompt for the moment, we’re considering all that to be implementation details

Alex Miller (Clojure team)17:09:33

and subject to change without notice

Alex Miller (Clojure team)17:09:21

in general, spec is designed to primarily be extensible via predicates (at the bottom) and wrapping with macros (at the top - particularly s/conformer and s/& are tools for this)

noprompt17:09:02

@alexmiller i see. well, i'll continue to hold out then for things to stabilize. i've at least familiarized myself a bit more with the internals (implementing Spec myself) so that can't be a bad thing. is there something similar to conformer for explain? that would be nice in my case because the parser combinators do produce failure data of where in the string the parse failed which could be appended to the path.

noprompt17:09:55

tl;dr explainer?

Alex Miller (Clojure team)18:09:09

although in next alpha, the explain-out fn is a dynvar you can swap

Alex Miller (Clojure team)18:09:32

that’s a bigger hammer though

noprompt18:09:10

yeah. that sounds like too big of a hammer. some way to implement an explain for a pred would be nice. i think i can get by with conformer for now. i hope in the future the protocols will stabilize for this kind of thing.