technically, it is the clojure.core/and function in both spec 1 and 2
not really going to do anything with it as the plan is for s/keys and and/or to go away in spec 2 anyways
Ah, that’s good to know. Thanks!
@alexmiller I tried the following example from spec 2 wiki page but it fails with “Couldn’t satisfy such-that predicate after 100 tries”. Is this a known issue?
(gen/sample (s/gen (s/select {:a int? :keyword?} [:a])) 5)
@alexmiller I tried to find a smaller failing case.
(require '[clojure.alpha.spec :as s] '[clojure.alpha.spec.gen :as gen])
;; => nil
(s/def :wf/S
(s/schema {:s/i-001 string?
:s/i-002 string?}))
;; => :wf/S
(s/def :wf/S1
(s/select :wf/S [:s/i-001]))
;; => :wf/S1
(s/valid? :wf/S {:s/i-001 "1"})
;; => true
(s/valid? :wf/S {:s/i-001 1})
;; => false
(s/valid? :wf/S1 {})
;; => false
(s/valid? :wf/S1 {:s/i-002 "1"})
;; => false
(s/valid? :wf/S1 {:s/i-001 "1"})
;; => true
(s/valid? :wf/S1 {:s/i-001 1})
;; => true
(gen/sample (s/gen :wf/S1) 1)
;; Caused by clojure.lang.ExceptionInfo
;; Couldn't satisfy such-that predicate after 100 tries.)
The result of the last 2 expressions is not expected (to me).I’m using this version:
{:git/url "<https://github.com/clojure/spec-alpha2>"
:sha "8498f9cb352135579b6d3a0a5d15c40e5c2647ce"}
I would like to use select with unqualified keys for schema name and select keys. Something like the following:
(s/def :foo/bar
(s/schema {:a int? :b keyword?}))
(gen/sample (s/gen (s/select :foo/bar [:a])) 5)
used to work, prob broken by later changes
(gen/sample (s/gen (s/select [{:a int? :b keyword?}] [:a])) 5)
should work as an alternate right now
That works. Thank you. Any suggestions for this? It fails with “Couldn’t satisfy such-that predicate after 100 tries”.
(s/def :foo/bar
(s/schema {:a/b string? :b keyword?}))
(gen/sample (s/gen (s/select :foo/bar [:a/b])))
sorry, not sure off the top of my head