Fork me on GitHub
#clojure-spec
<
2016-08-17
>
stathissideris10:08:03

@seancorfield: (require instead of (:require also breaks tools.namespace

stathissideris10:08:13

or makes it unreliable

alexmiller12:08:20

I actually found a case of it in an old version of tools.namespace too (long since fixed)

ikitommi14:08:17

Hi. Back trying to integrate spec into http api-libs for (border) runtime validation, but need to figure out how to do selective conforming based on runtime parameters (which is needed to do this right). Wrote a small gist of how this is done with Schema - https://gist.github.com/ikitommi/17602f0d08f754f89a4c6a029d8dd47e. Any clues how to do this with spec? Writing conformers that read dynamic vars? Wait for the next alpha? 😉

dave.dixon16:08:22

Short of writing a custom generator, is there a way to limit the depth of a generated tree from a recursive spec?

gfredericks17:08:09

@dave.dixon why do you need to limit it?

gfredericks17:08:22

there might be a var for that actually

gfredericks17:08:32

but I'm still curious why that need comes up

dave.dixon17:08:47

@gfredericks: I'm getting stack overflow exceptions. Actually not sure if that's the real issue anyway, since I only get the when I wrap the spec in with-gen to try and limit the number of entries.

dave.dixon17:08:09

@gfredericks: Come to think of it, they way I'm specifying the tree probably isn't right, since there's an additional restriction on the leaves. Guessing that means I need to write my own generator anyway.

gfredericks17:08:54

test.check has a helper for recursive generators

gfredericks17:08:02

you have to be careful with sizing though :/

gfredericks17:08:14

sizing and recursion have a weird relationship

dave.dixon17:08:35

@gfredericks: using clojure.spec/*recursion-limit*. Sometimes I get answer from exercise, sometimes a stack overflow.

gfredericks17:08:45

the *recursion-limit* var and the test.check recursion helper are mutually exclusive

gfredericks17:08:03

the former only applies to the built-in generator clojure.spec gives you for for recursive specs

gfredericks17:08:20

I need to write some documentation on sizing in test.check

ikitommi18:08:01

related to my runtime-coercion question. did a spike about using dynamic var to define the environment for the conformations: * specs define a special “type” predicate as a first predicate. Allows type-based conformations & allows easy generation of api-docs (we are doing the spec->swagger, https://github.com/metosin/ring-swagger/issues/95) * type predicates know how to conform value in different environment (should be recursive): string, json & edn formats get all different treatment. Using a dynamic var sounds like a bad idea, but coudn’t figure out any other way to do this. Any comments?