Fork me on GitHub
#clojure-spec
<
2016-08-03
>
scriptor03:08:20

right, def doesn't exist in clojure.core, it's part of the base language

gfredericks03:08:07

You could imagine a not-too-different clojure where special forms are namespaced and excludable

rickmoynihan12:08:18

I'm curious what people think about the differences/benefits/relationships between: - Generative Property Based Testing - Pairwise Testing In particular is anyone combining the two... It seems to me that you could/should use generative tests to provide instance data within certain equivalence classes of values and then use pairwise testing to generate arguments as test pairs to apply to the function under test.

borkdude13:08:32

clojure.spec and music generation - has anyone tried it ? 😉

eggsyntax13:08:46

@borkdude: not I, but I've written some evolutionary music programs, and I think that'd be a really cool approach -- evolve organisms whose phenotype is a spec & generate music from the spec.

eggsyntax13:08:37

Carin Meier has already some genetic programming w/ spec.

borkdude13:08:52

@eggsyntax: thanks for the read!

lopalghost14:08:33

Anyone using spec to parse and validate tabular data?

mpenet15:08:49

@alexmiller: Should I fill a ticket to have :conform-keys be turned into :conform-keys? (option in map-of), also :distinct-> :distinct?, there are possibly other bool options like these in spec, didn't check all of them

rickmoynihan15:08:17

lopalghost: not yet - but I totally plan too

rickmoynihan15:08:55

lopalghost: I think specs and their regexes etc are a natural fit for validating columns/rows of data

lopalghost15:08:03

@rickmoynihan: I've been using it to read unfriendly excel spreadsheets, it's really helpful Was wondering what sort of approaches people might be taking

Alex Miller (Clojure team)15:08:37

@mpenet you can, not sure on the likelihood of that changing

rickmoynihan15:08:00

lopalghost: I plan on doing the same thing - as it seems a natural fit... curious to hear about your experiences though

thegeez18:08:20

is clojure.spec/conform meant to be used in production code (and not only when developing/testing/instrumenting)? For spec/assert it is mentioned explicitly that is should be a no-op and disabled in production, same as with instrumenting and such. Does the same hold for spec/conform? Will the run-time impact be to high to use spec/conform generously everywhere?

lvh19:08:15

my understanding is that conform is expected at the edges where you take input

lvh19:08:34

it has the benefit of e.g. automatically classifying multiple options for you (s/or) via a map key

lvh19:08:02

also, you don’t care about expensive there because a) you’re doing it once b) the alternative is potentially consuming random garbage and having it break somewhere down the road

thegeez19:08:06

thanks, I hadn't considered the "one time" aspect of using conform. I was thinking of using conform multiple times on the same value but that doesn't work as conform will most likely transform the value

donaldball19:08:46

For a couple of maps I want to specify, there are some derived values therein which I’d like to specify (and generate) correctly. For example {:a 1 :b 2 :a+b 3}. This is easy to express with (s/and (s/keys …) #(some-predicate)) but of course the generator essentially never passes the such-that filter

donaldball19:08:05

Has anyone found any good patterns for this situation?

gfredericks20:08:13

donaldball: running the default generator through gen/fmap would make it easy enough to overwrite key like the one you showed

gfredericks20:08:20

I don't think clojure.spec makes it easy to modify a generator though

donaldball20:08:40

I’ve kinda settled on having two specs, one which specifies the map with only independent values, and another which specifies the map including derived values

gfredericks21:08:44

gen/fmap should help in that case too

donaldball22:08:25

Yea, it’s not hard to add on, I’m just wondering if anyone else has been writing specs for maps with internal value consistency requirements and, if so, if there’s a declarative approach to expressing them