Closed se-neaxplore closed 10 months ago
Sure, PR welcome. It's been a long time since I've looked at this code, so I don't recall if this is feasible, but perhaps we could drop the default any?
when extending instead of always and
ing.
Aside, do you know why (clojure.spec.alpha/and clojure.core/any? clojure.core/inst?)
is not satisfiable? That is surprising to me.
Removing (clojure.core/any?)
would solve it directly.
The (s/and)
generator uses the first generator to generate a value which is than passed to the next spec. any?
generates a lot of different values but never an Inst
.
(gen/sample (s/gen (s/and clojure.core/any? string?)))
this expression works sometimes, because any?
generates String
.
Using a custom scalar
scalar Timestamp
generates a specclojure.core/any?
. Extending this scalar withclojure.core/inst?
results in(clojure.spec.alpha/and clojure.core/any? clojure.core/inst?)
Which is still not satisfiable by clojure spec.Swapping the clauses
(clojure.spec.alpha/and clojure.core/inst? clojure.core/any?)
solves this problem.Proposal: Change the generated spec to put the extended spec first.
I think the change should be introduced here defmethod compiler/transducer :extend
Let me know what you think and if you would like to move forward with this, I will make a PR.