Fork me on GitHub

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


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


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


Can I leverage my sepcs in anyway whilst doing this?


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


can I not use the specs in someway here?


I guess I’m wondering how I might build functionality like SuperCollider’s ControlSpec( around Clojure’s spec...


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


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


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


ok more direct question now, if I have:


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


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


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?


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


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