This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-03
Channels
- # adventofcode (6)
- # bangalore-clj (1)
- # beginners (15)
- # boot (4)
- # cider (14)
- # clara (1)
- # cljs-dev (1)
- # clojure (115)
- # clojure-art (1)
- # clojure-france (1)
- # clojure-greece (1)
- # clojure-korea (9)
- # clojure-russia (1)
- # clojure-spec (62)
- # clojure-taiwan (1)
- # clojure-uk (18)
- # clojurescript (5)
- # component (1)
- # cursive (3)
- # datascript (2)
- # datomic (17)
- # devcards (2)
- # editors (4)
- # emacs (65)
- # events (2)
- # funcool (4)
- # hoplon (92)
- # jobs (6)
- # london-clojurians (1)
- # luminus (1)
- # midje (2)
- # mount (1)
- # off-topic (1)
- # onyx (51)
- # protorepl (6)
- # re-frame (116)
- # reagent (7)
- # ring (2)
- # spacemacs (2)
- # specter (4)
- # untangled (1)
- # yada (1)
the go type system has “struct embedding” which i fell in love with when working in go - lets you accomplish something similar by merging struct fields
is the general idea to use coll-of and map-of by default and only switch to every if your specs are too slow and you don’t need conformance
also - i’m now running in to a situtation where a spec is not-conforming and it’s just consuming a ton of memory producing the explanation data
yeah, i get the feeling explain needs to become lazy somehow - not necessarily with thunks, but maybe with something like a …
that you can ask it to expand further
hmm, yeah - i have a structure with LOTS of structural sharing and a ton of redundant data - not unlike the clojurescript ast
You can set a custom explain printer if that becomes useful
Just setting print-length will affect the default one though
In case that helps
Re your collection question, yes that's a good first approximation
You can also set coll-check-limit to further tweak what every and every-kv check
if that first-approximation is true, that you should default to coll-of or map-of, then it seems like the more informative doc-strings should be on those, rather than every and every-kv
Rich always thought people should default the other way
But in general most people seem to disagree :)
seeming like sampling is the right thing if the specs are not intended to be used for contract-style checks
I would actually prefer that the doc for both covered all the details, but you know
Rich isn't big on duplication like that
I have a spec reference page in the works for the docs which will help too
If wishes were fishes something something
Later, shutting down for takeoff
How do you spec a multi-method? Multi-spec seems like it should do it, but it only talks about spec’ing a hash with types. More specifically I have the following - but it never validates the :box
parameter.
(s/fdef colliding?
:args (s/cat :invader map? :box ::box/box)
:ret boolean?)
(defmulti colliding? :character)
(defmethod colliding? ::small [invader box]
You can't right now
Probably fixable but I haven't looked at it yet
Oh really?
Kinda shocked - I had assumed it was me the whole time.
Might wanna make it clearer in the docs that it’s not supported. All I could find was some confusion on multi-spec.
Thanks for the help tho!
Yeah, multimethod, protocols, primitive typed fns, and inlined fns will not work right now
Inlined and protocols are probably not easily fixable
user=> (binding [s/recursion-limit 1 s/coll-error-limit 1 s/coll-check-limit 1] (clojure.test/run-tests ‘ambiparse.calc-test)) That normally returns in ~1 second, but when instrumented, it seems to be infinitely looping. jstack says: https://gist.github.com/brandonbloom/dfa559f81ad1b6d0980c120d86a2e18e
amusingly, i’m working on a parser, soooo i’m running in to exactly the same kinds of infinite loop problems in the program i’m trying to debug 😉
Hi - I'm experimenting with spec and am getting an error that I'm not understanding
RuntimeException Var clojure.test.check.generators/large-integer is not on the classpath clojure.spec.gen/dynaload (gen.clj:21)
. Any tip as to what could be the problem? This is happening when I'm trying to exercise a simple spec I've written.looking at the spec impl, it seems like there isn’t on spec checking level/depth - which might be what i want/need, not sure tho
It's entirely possible some spec impl is not respecting the limit
@derwolfe: you need test.check on your classpath
@alexmiller thanks!