Fork me on GitHub
#clojure-spec
<
2017-12-11
>
genec10:12:19

(doc s/merge) returns nil, are there docs for spec?

Alex Miller (Clojure team)13:12:31

It shouldn’t be if you load clojure.spec.alpha :as s

guy10:12:58

but you also have https://clojure.org/guides/spec#_entity_maps and its got s/merge inside of it too

guy10:12:30

at the bottom of this entity map part

ikitommi11:12:53

@gfredericks @mpenet bumped into the need of bijections too: In routing, if a path-parameter is declared as keyword? we can easily coerce it from string with string->keyword. But with reverse-routing, we need to turn that keyword param back to string to create a path. I seem to have resolved that earlier by using a json-encoder to write things to string-like, but this can’t be the right way to do this.

ikitommi11:12:52

I guess a simple (and fast) way would be to introduce a IntoString Protocol. But I guess there can be N different formats to read from and same N formats to write to. Hmm.

ikitommi11:12:48

Actually, I think I can just introduce a new type-conformer for spec-tools for the opposite direction type->string.

ikitommi11:12:09

No, using the conform requires the end value to be valid. This would require something like the CLJ-2251 with a “just transform without validating” options. Or something totally different.

gfredericks12:12:11

so would still be a good use case for a bijections library?

ikitommi18:12:58

@gfredericks Would be best if spec itself provided the needed hooks to implement the bijections, but not likely to happen. I need something now, so will hack something. If you have good ideas how to do this properly, I’m all ears!

misha11:12:16

@alexmiller when will clojure.core/long? be released? it is in master, but is not in clojure 1.9.0 as I expected (or am I missing something?). Thanks https://dev.clojure.org/jira/browse/CLJ-1298

misha12:12:49

is there out of the box generator for System.currentTimeMillis? (apart from clojure.test.check.impl/gen-current-time-millis) opieop

gfredericks12:12:29

@misha how is what you're describing different from generating a long?

misha12:12:52

far greater than 0? :D

gfredericks12:12:12

they weren't far greater than 0 in 1970

misha12:12:22

honestly, I did not think it through yet

misha12:12:36

pos-int? then?

gfredericks12:12:53

they were negative in 1969

gfredericks12:12:18

is there a (not clojure) spec for these numbers? I've never heard of one

misha12:12:25

oh, okay.

misha12:12:17

I think the "much greater than zero" part of a spec – is a specialization for my case.

gfredericks12:12:41

anyhow, with time generators you have three options A) make a generator that is not focused on your current now (cleanest if you can get away with it) B) call (time/now) somehow before constructing your generators and pass that in (lots of boilerplate potentially) C) make a nondeterministic generators (with associated damage to reproducibility and shrinking)

gfredericks12:12:09

for B) you'd want to log the time you're using, for reproducibility

misha12:12:51

thank you. at this point I think I might just use int? with s/with-gen, and supply (System.currentTimeMillis) as a generator, as my only goal (so far) with this particular value - is plausible human-readable exercise data.

misha12:12:55

(to the extent time-millis could be "human-readable")

gfredericks12:12:24

converting to/from time-mills would be a cool savant mental trick

misha12:12:54

doubt I would want to master it opieop

tjtolton12:12:14

Is there a megathread somewhere about 1.9 discussions? Did spec get pulled from the release as a finished product? Are macros using spec in the stable release? what's going on?

bronsa13:12:26

spec got pulled out, it's still alpha but no major breaking API changes are expected, currently there's specs for ns, let, fn, defn

tjtolton14:12:32

Thanks @alexmiller, I'll bet that was a bummer of an internal conversation 😕