This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-14
Channels
- # aleph (1)
- # announcements (1)
- # beginners (59)
- # boot (2)
- # calva (5)
- # cider (8)
- # clj-kondo (6)
- # cljdoc (5)
- # cljsrn (11)
- # clojure (123)
- # clojure-dusseldorf (1)
- # clojure-europe (4)
- # clojure-italy (22)
- # clojure-losangeles (4)
- # clojure-nl (10)
- # clojure-spec (18)
- # clojure-uk (22)
- # clojurescript (103)
- # cursive (32)
- # data-science (1)
- # datomic (21)
- # events (2)
- # figwheel (1)
- # fulcro (12)
- # graalvm (3)
- # graphql (8)
- # jobs (2)
- # kaocha (4)
- # klipse (2)
- # lein-figwheel (4)
- # leiningen (23)
- # off-topic (11)
- # planck (11)
- # re-frame (8)
- # reagent (2)
- # reitit (3)
- # rewrite-clj (1)
- # ring (1)
- # ring-swagger (31)
- # schema (2)
- # shadow-cljs (66)
- # spacemacs (3)
- # specter (16)
- # sql (9)
- # tools-deps (16)
- # vim (26)
just trying to understand why does a empty seq satisfy this spec (s/valid? (s/every integer?) [])
, shouldn’t it fail ?
because every element in the collection is an integer
for all none elements
(s/every? integer?) specifies a collection where each element is an integer. In this case []
meets that spec, there just happen to be no elements.
thanks @U064X3EF3 that explains it
When I run (stest/summarize-results (stest/check))
, I see the following error printed in my repl -
No implementation of method: :specize* of protocol: #'clojure.spec.alpha/Specize found for class: nil
all the tests are passing and the :sym
names are being printed correctly, however at the end it prints the above too.
don't know, can't tell from just that
There was a typo in my s/fdef
association with the sym, once that was corrected, the error disappeared
(s/every? integer?) specifies a collection where each element is an integer. In this case []
meets that spec, there just happen to be no elements.
if you require a non-empty collection, you can use (s/every? integer? :min-count 1)
don't know, can't tell from just that
conformer
doc states:
> takes a predicate function with the semantics of conform i.e. it should return either a (possibly converted) value or :clojure.spec.alpha/invalid
And yet defining such a function gives me an error (minimal reproducible example):
user=> (defn f [] :clojure.spec.alpha/invalid)
Syntax error macroexpanding clojure.core/defn at (/private/var/folders/m9/5hxwnkyj0bxf6plprrbf5vzw0000gn/T/form-init9446902011342467351.clj:1:1).
:clojure.spec.alpha/invalid - failed: map? at: [:fn-tail :arity-1 :body :prepost+body :prepost] spec: :clojure.core.specs.alpha/defn-args
:clojure.spec.alpha/invalid - failed: any? at: [:fn-tail :arity-1 :body :body] spec: :clojure.core.specs.alpha/defn-args
Am I missing something silly?defining that function fails the spec for defn itself
as it has the magic "invalid" value
a workaround is
user=> (def i :clojure.spec.alpha/invalid)
#'user/i
user=> (defn f [] i)
#'user/f