Fork me on GitHub
#clojure-spec
<
2016-11-19
>
triss10:11:35

ok so I’ve got some specs for params of my system...

triss10:11:57

they specify the range of valid values for each of them.

triss10:11:23

I’d like to map values between 0-127 to values with in those ranges.

triss10:11:41

Can I leverage my sepcs in anyway whilst doing this?

triss10:11:30

currently I’m using this map of fns to coerce values in to the required ranges:

triss10:11:03

can I not use the specs in someway here?

triss11:11:35

I guess I’m wondering how I might build functionality like SuperCollider’s ControlSpec(http://doc.sccode.org/Classes/ControlSpec.html) around Clojure’s spec...

triss11:11:58

any thoughts? sorry for the brain dump. hope that’s ok in here

Alex Miller (Clojure team)12:11:49

Aside - swap the order of the preds in ::sample

Alex Miller (Clojure team)12:11:04

There are lots of ways to either use custom generators or to each piece or to create a generator that applies a function to the default generator for the overall structure (with gen/fmap)

Alex Miller (Clojure team)12:11:27

Not sure what's best here but lots of options

Alex Miller (Clojure team)12:11:35

There's a talk at the conj in a couple weeks about making music with spec

triss14:11:56

many thanks @alexmiller… looking forward to music talk (sadly will be digesting via youtube)

triss14:11:30

I think I need to familiarise my self with generators before I’ll understand what you’ve just suggested! many thanks though - I know what to read up on next

triss14:11:38

ok more direct question now, if I have:

triss14:11:13

how can I find ::every‘s minimum and maximum? is it possible?

Alex Miller (Clojure team)15:11:54

so there is intent to make this more visible but things are not quite in place yet

Alex Miller (Clojure team)15:11:19

specifically, you can call s/form on a spec to retrieve the original form and then grab the 2nd and 3rd values in the list

Alex Miller (Clojure team)15:11:47

however, these compound specs (int-in, double-in, and inst-in) do not have the original form atm

Alex Miller (Clojure team)15:11:07

there are several paths towards that and I’ve been discussing with Rich the best one to take but it’s not implemented yet

triss16:11:36

ah. ok that seems simple enough for an integer range… a lot more complex for a range of doubles...

Alex Miller (Clojure team)20:11:10

If you write a spec for the double-in form, then it's just a conform away

twashing21:11:35

I’m not sure if this is a dumb question. But Is there anyway to include clojure.spec'd functions in a generalized test suite?

twashing21:11:48

Adding spec’d functions to your running test suite, is sort of discussed in this Google Group thread. But I can’t figure how stest/instrument is used outside of the repl, in a test suite.

Alex Miller (Clojure team)21:11:06

check the pinned items here

twashing23:11:51

@alexmiller Lol!! Too right. Ok, let me have a play.