Fork me on GitHub
#clojure-spec
<
2016-10-29
>
steveb8n02:10:49

I have zipper data structure using the techniques described in http://puredanger.github.io/tech.puredanger.com/2010/10/22/zippers-with-records-in-clojure but I’m finding it hard to write a spec that validates child nodes using the protocol. I can’t use a map key because different impls of TreeNode (Zippable in my case) may use different keys. I’ll paste an e.g. next....

steveb8n02:10:49

Any suggestions would be much appreciated

grant04:10:29

Is there an easy way to figure out which spec in a large nested spec that is causing "ExceptionInfo Couldn't satisfy such-that predicate after 100 tries." when using (s/exercise ...)?

jrheard04:10:43

not afaik but i’m not an expert

jrheard04:10:41

usually it’s down to a string or something that has lots of constraints put on it and is difficult to generate reliably, but you probably already know about that; one gotcha that i don’t think is as well-known is that if you have a coll-of that’s got a :kind set? but doesn’t have an into #{}, that can cause the same couldn’t-satisfy-after-100-tries behavior

jrheard04:10:02

might not be your issue, but i always feel compelled to mention it when people have this problem because it happened to me and took me a while to figure out

grant04:10:46

Ah, good tip on the set thing, I haven't run into that yet, but I could see making that mistake.

seancorfield04:10:14

It doesn't really help you but I highly recommend trying to s/exercise each spec as you write it and build up complex specs in terms of other specs (not just predicates).

seancorfield04:10:37

Predicates tend to be opaque when you combine them into specs. If you define specs for those predicates, when you combine the specs, you get better error reporting.