I’m a pretty heavy user of spec including a lot of coercion. The way I’ve
always done coercion is to enumerate all accepted shapes first and do coercion
last. For your example this would be:
(s/def ::foo (s/and (s/or :string string?
:kw keyword?)
I've been using the macro below to make "types" in the context of
clara-rules, where "type" has a specific semantic. If you're going to do
something like this, you definitely should have a very well-defined notion
of what "type" means.
(defmacro def-derive
"Macros to wrap useful pattern
Nice!
On Monday, February 26, 2018 at 8:47:38 AM UTC-6, Wilker wrote:
>
> I've written a library that tries to solve this, instead of making
> conforms that do coercion, it uses the spec and a separated registry to
> conform the value (similar to what spec does to find the generators for a
>
I've written a library that tries to solve this, instead of making conforms
that do coercion, it uses the spec and a separated registry to conform the
value (similar to what spec does to find the generators for a given spec).
You can find the library at:
>
> Map specs are about attribute aggregation, not about types.
>
I understand the design philosophy. I think that's great. What I meant I
guess is that it would be nice to also have a declarative way to relate
Types to Specs, for when Specs fall short of types. Then you'd have the
best of
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
On Wednesday, February 21, 2018 at 7:34:00 PM UTC-6, Didier wrote:
>
> I would actually love it if Spec was extended to have the concept of types.
>
Map specs are about attribute aggregation, not about types.
https://clojure.org/about/spec#_map_specs_should_be_of_keysets_only
> Something
I would actually love it if Spec was extended to have the concept of types.
Something where every spec could be tied to a Type, and types could be
constructed to have Hierarchies.
Not sure what the syntax would be like, but say:
(s/def :String ::name string?)
(s/def :String ::address (s/and
Looking around I see lots of cases where people do use conformers for coercion.
That doesn’t make them right
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
On Tuesday, February 20, 2018 at 4:53:33 PM UTC+1, Alex Miller wrote:
>
> This is exactly why we recommend that you not use conformers for coercion.
> Conformers were added primarily as a tool for building custom composite
> spec types (for example, we used it to build keys* from keys).
>
I am
tiistai 20. helmikuuta 2018 19.05.55 UTC+2 Alex Miller kirjoitti:
>
>
> On Tuesday, February 20, 2018 at 10:28:12 AM UTC-6, Erik Assum wrote:
>>
>> FWIW, I’ve been using https://github.com/metosin/spec-tools
>> on a couple of projects lately, which helps nicely with
>> conformance and coercion.
Calling s/valid? will tell me if the data is valid *if it has been conformed*.
But what if it hasn't? Can I use the data? Is it "valid" according to the spec
I wrote?
If your spec includes coercions, you have inherently made the “is valid?”
question include the coercion. Your ::test-spec
On Tuesday, February 20, 2018 at 11:24:19 AM UTC-6, Erik Assum wrote:
>
> Out of curiosity, are you at liberty to discuss how Cognitect solves the
> problem of validating/coercing values at the edges of the application when
> you (Cognitect) are doing consulting?
I'm not involved with those
Out of curiosity, are you at liberty to discuss how Cognitect solves the
problem of validating/coercing values at the edges of the application when you
(Cognitect) are doing consulting?
Erik.
--
i farta
> 20. feb. 2018 kl. 18:05 skrev Alex Miller :
>
> I do see the
On Tuesday, February 20, 2018 at 10:28:12 AM UTC-6, Erik Assum wrote:
>
> FWIW, I’ve been using https://github.com/metosin/spec-tools
> on a couple of projects lately, which helps nicely with
> conformance and coercion. The main devs are very helpful on #ring-swagger
> on the Clojurians slack.
FWIW, I’ve been using https://github.com/metosin/spec-tools
on a couple of projects lately, which helps nicely with
conformance and coercion. The main devs are very helpful on #ring-swagger on
the Clojurians slack.
Alex, how does spec-tools measure up to your thoughts on conformance/coercion?
This is exactly why we recommend that you not use conformers for coercion.
Conformers were added primarily as a tool for building custom composite
spec types (for example, we used it to build keys* from keys).
This is a common need though and I would be happier if spec did more to
help you
I've been using spec for a while now, in a reasonably large code base (>30k
lines of Clojure and ClojureScript) and there is an issue that bit me
several times.
I use conformers for coercing data that is *almost* what I need, usually
when reading from JSON (RethinkDB). Common conformers are
18 matches
Mail list logo