This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-02
Channels
- # aleph (1)
- # announcements (1)
- # babashka (4)
- # beginners (89)
- # calva (3)
- # chlorine-clover (18)
- # cider (33)
- # clj-kondo (27)
- # cljdoc (4)
- # cljsrn (2)
- # clojure (248)
- # clojure-europe (7)
- # clojure-italy (15)
- # clojure-nl (7)
- # clojure-norway (10)
- # clojure-poland (1)
- # clojure-spec (12)
- # clojure-sweden (5)
- # clojure-uk (57)
- # clojured (4)
- # clojuredesign-podcast (1)
- # clojurescript (55)
- # core-async (14)
- # core-logic (3)
- # cursive (10)
- # datomic (38)
- # figwheel-main (8)
- # fulcro (23)
- # graalvm (126)
- # hoplon (59)
- # jobs (1)
- # kaocha (3)
- # malli (30)
- # meander (17)
- # off-topic (32)
- # pathom (19)
- # pedestal (4)
- # re-frame (12)
- # reagent (2)
- # reitit (3)
- # shadow-cljs (81)
- # sql (9)
- # tools-deps (34)
- # vim (20)
- # vscode (7)
- # xtdb (5)
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
@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)
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
@alexmiller I was able to find the reported error (outside of the generator). The last s/def below fails with the following error:
1. Unhandled java.lang.AssertionError
Assert failed: (every? (fn* [p1__18963#] (not (select?
p1__18963#))) unq-specs)
impl.clj: 423 clojure.alpha.spec.impl/schema-impl
(s/def :foo/bar
(s/schema {:a/b string? :b keyword?}))
(s/def :foo/baz
(s/select :foo/bar [:a/b]))
(s/def :foo/buz
(s/schema
{:z :foo/baz}))
@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).