News for hackers. Stuff that matters.
Re:What Clojure Spec is and what you can do with it by didibus on Thursday September 10, 2020 @02:04PM (#24434913)
I think all of those problems are only true when you try to do coercion with custom conformers. Which is not the intended use of conformers.

Conformers are meant to parse the data when there are multiple possibility of what something can validate against, the conformer will disambiguate and return a result that tells you which path was chosen.

Coercion is not supported as part of Spec, you're expected to do that seperatly either before or after validating/conforming.

Re:What Clojure Spec is and what you can do with it by jwr on Thursday September 10, 2020 @03:58PM (#24435961)
Yes, that was largely my point. Many people (me included) assume that s/conform is a kind of coercion, which it is not.

Not all of the above problems are due to coercion, but the majority are.

To be clear: I'm not complaining here, I find spec to be very useful and I like it, just pointing out traps for the unwary.

Re:What Clojure Spec is and what you can do with it by didibus on Friday September 11, 2020 @12:44PM (#24444585)
Ya fair enough, I've definitely seen a lot of people think conforming is meant for coercion. But it's not, it's only meant for disambiguating the chosen path (when multiple are possible) for validation.
Re:What Clojure Spec is and what you can do with it by zcam on Friday September 11, 2020 @12:36AM (#24439239)
There are a few libraries that make it possible without abusing conformers, one of which is https://github.com/exoscale/coax
Re:What Clojure Spec is and what you can do with it by didibus on Friday September 11, 2020 @12:48PM (#24444622)
Looks nice, I knew of spec-coerce, but not coax.