On Thursday, February 22, 2018 at 12:58:00 AM UTC+1, Sean Corfield wrote: > > Looking around I see lots of cases where people do use conformers for > coercion. > > > > That doesn’t make them right 😊 >
Oh, I agree, I'm just being realistic. The cat is out of the bag. I just googled for 's/conformer' and found an entire library of conformers that do various data conversions. > At a first glance it seems very natural, and warnings not to do it are not > easily found. > > > > Every single time coercion comes up anywhere in the context of spec, > someone says “don’t do that”, and they’ve been saying it since the earliest > alpha versions of spec. You would be correct to point out that nothing in > the spec overview or spec guide on clojure.org carries this caution, > however (and I think it’s a reasonable “ask” for the guide to be updated to > include such a caution). > > > > My recommendation is to have a strictly non-coercive spec for the target > data “type” / shape you want, and to have a second spec that combines the > coercion you want with that spec. That way you have a way to tell if your > uncoerced data conforms to the spec, as well as a way to do coercion in > s/conform. They are – and should be – two separate specs and two separate > operations. They represent different layers of abstraction inside your > application (so “of course” they should be two separate specs, one built on > top of the other). > Also agree. I think coercion and conformance verification are two separate concepts and should not be conflated. I like the idea with two specs, as this lets me get some reuse. > Given that the overview and the guide don’t even mention s/conformer, I’m > not sure where that recommendation should live. Alex, any thoughts on this, > since you seem to be the one most often making the recommendation? > As a spec user, I would expect to learn about this from the spec guide. Also, I still believe that in the short term a function that validates a spec without calling conformers would be useful. best regards, --Jan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to email@example.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.