This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-02
Channels
- # admin-announcements (1)
- # alda (3)
- # beginners (28)
- # boot (155)
- # braid-chat (8)
- # cider (22)
- # cljs-dev (46)
- # cljsrn (24)
- # clojure (94)
- # clojure-belgium (23)
- # clojure-czech (2)
- # clojure-germany (7)
- # clojure-greece (12)
- # clojure-india (1)
- # clojure-japan (1)
- # clojure-russia (118)
- # clojure-spain (18)
- # clojure-spec (40)
- # clojure-sweden (19)
- # clojure-taiwan (4)
- # clojure-uk (5)
- # clojurescript (185)
- # clojutre (10)
- # community-development (5)
- # core-logic (11)
- # css (5)
- # cursive (7)
- # datomic (5)
- # dirac (6)
- # emacs (2)
- # euroclojure (1)
- # events (5)
- # hoplon (355)
- # instaparse (3)
- # jobs-rus (5)
- # lein-figwheel (2)
- # leiningen (5)
- # mount (11)
- # off-topic (8)
- # om (20)
- # onyx (10)
- # other-languages (87)
- # perun (9)
- # proton (1)
- # re-frame (21)
- # reagent (16)
- # specter (28)
- # tmp-json-parsing (5)
- # untangled (19)
- # yada (43)
but as I expected, you lose conform
destructuring and explain
can't explain the problem anymore
...so different solutions would be welcome
Clojurescript is failing to compile my file if my fdefs
are located above their corresponding defns
. Is this the way things are intended?
I.E., you can't spec your function before you define it?
@george.w.singer: Yes. The var is not defined yet. You could declare
the var if you must write the spec above the function. I have just been writing my specs below my function definitions.
Ok, thanks.
Macro sugar needs to be added to spec IMO
Something like
(fn-spec
fn-name ::arg1, ::arg2 -> ::ret-spec
:such-that ::ret-value-greater-than-max-of-its-inputs)
This would at once declare
our fn-name
and annotate it with corresponding specs using intuitive Haskell-like syntax.@george.w.singer: you could write that macro 🙂
yea 😄
@george.w.singer: I think that’s a CLJS-impl bug, I’d report it
@george.w.singer: Does it work if you do
(s/fdef 'your-sym
:args ...
:ret ...)
It does sometimes but then the whole thing becomes buggy. Sometimes it doesn't compile. All tests pass
Really strange behavior is exhibited
The strange behavior goes away if put them before
I seem to be getting a strange error when creating a spec for a function with a type hinted argument. Error:
java.lang.ClassCastException: clojure.spec$spec_checking_fn$fn__11414 cannot be cast to clojure.lang.IFn$DO
Example:
(defn bar
[f]
(f 0.0))
(s/fdef bar
:args (s/cat :f fn?)
:ret number?)
(defn foo
[^double value]
(bar (fn [_] value)))
(s/fdef foo
:args (s/cat :v number?)
:ret number?)
(defn foo2
[value]
(bar (fn [_] value)))
(s/fdef foo2
:args (s/cat :v number?)
:ret number?)
(foo 1.0) => error
(foo2 1.0) => 1.0
(s/instrument-all)
Looks like primitive hinting encodes the argument and return type to be encoded in the underlying type (if you add ^double
as a return type hint, the cast is to IFn$DD
, for example).
Very surprised to see that calling an instrumented function can actually load and call clojure.test.check
to do generative testing as part of the conformance test, without explicitly calling clojure.spec.test/run-all-tests
etc.
is this a bug?
spec> (gen/sample (s/gen #{1 0}) 10)
(0 0 1 0 0 0 1 0 1 0)
spec> (gen/sample (s/gen #{false true}) 10)
(true true true true true true true true true true)
@hiredman: thanks for your explanation, but I still don't get how I would generate true/false randomly
(s/def ::point (s/cat :x number? :y number?))
(s/def ::body (s/+ ::point))
(s/conform ::point [2 3])
(s/conform ::body [[2 3]])
(s/explain ::body [[2 3]])
@slipset: (s/def ::point (s/spec (s/cat :x number? :y number?)))
The combination of s/+
and s/cat
means that body is defined as a series of :xs and :ys without nesting
for the record, I ended up with this for booleans:
(defn- boolean? [x] (instance? Boolean x))
(s/def ::boolean (s/with-gen boolean? #(gen/boolean)))
is there any way to make s/cat
specs generate a vector?
What @stathissideris said :)
This is a pretty minor note, but this appears to be one of the only channels with _
separation instead of -
. Any chance an admin could change that?
I see no stinkin’ underscores here...