Fork me on GitHub
#clojure-spec
<
2018-03-21
>
gfredericks00:03:17

@alexmiller sorry, meaning that spec would, e.g., require test.check >= 0.10.0

gfredericks00:03:37

you made a comment a few weeks back that implied that wouldn't be acceptable

alexisvincent00:03:45

@misha 🙂 Thanks. Im just concerned about the name explosion when composing up the tree

Alex Miller (Clojure team)00:03:15

@gfredericks I wouldn’t make a range version but we could certainly bump the requirement

gfredericks00:03:46

the difference between those two things is whether a max version is specified?

Alex Miller (Clojure team)00:03:48

I just don’t like version ranges

seancorfield00:03:07

No one likes version ranges 🙂

Alex Miller (Clojure team)00:03:31

The only people that like version ranges are people that haven’t used them :)

gfredericks00:03:31

đź‘Ť thanks

kahunamoore01:03:06

I'm looking to do some visualization of specs and by default would think using the reader would be the most straight forward way to consume/read the specs. Is there a better way? A library perhaps that produces a higher level representation? Thoughts?

andy.fingerhut02:03:32

@kahunamoore I have not used this tool, and not sure if it is what you are looking for, but it sounds at least related: https://github.com/jebberjeb/specviz

đź‘Ť 4
seancorfield03:03:38

Oh, I didn't know there was a transcript of that! Cool!

đź‘Ť 4
taylor11:03:28

yesterday I helped a coworker spec some financial calc functions, then we immediately found some bugs by checking them đź‘Ź

taylor11:03:04

aside: will the default generator for number? predicate generate all/most numeric types (like ratios)?

taylor11:03:38

doesn’t seem like it generates ratios

borkdude11:03:36

Would it make sense if Spec could aid in producing human readable errors? https://gist.github.com/borkdude/89799a764a89af5c0be1a5745be58b4d

hkjels14:03:12

the above obviously does not work

hkjels14:03:58

I could use this and digg into the meta, but I’d prefer not to

Alex Miller (Clojure team)14:03:45

what problem are you trying to solve?

hkjels14:03:24

I output form-controllers based on the type of a specification. So for simple spec definitions like (spec/def ::placeholder string?) I can output a textfield because I know it’s a string with (type the-def), but for definitions that use with-gen; type returns nil

bbrinck14:03:30

@hkjels Can you talk more about how you determine the type in the simple case? Are you inspecting the spec itself, or an example generated value?

bbrinck14:03:17

Also, that generator above doesn’t generate valid values: (fn? nil) is false

bbrinck14:03:17

If you want a “maybe-fn”, perhaps s/nilable would help?

Alex Miller (Clojure team)14:03:30

he’s returning (constantly nil), which is a function

Alex Miller (Clojure team)14:03:09

I feel like you should still be driving from the spec, not the generator

hkjels14:03:08

yeah, not sure how though

Alex Miller (Clojure team)14:03:15

(you should also be using ifn?, not fn? btw)

bbrinck14:03:24

Agreed, @hkjels if I were trying to generate forms based on the spec, I’d look at introspecting the specs using s/form. Obviously it’s be hard with all possible specs

bbrinck14:03:50

but if you have a subset of forms in your app, you could reasonably inspect them and generate the cases that interest you

Alex Miller (Clojure team)14:03:10

well in this case, s/form doesn’t currently work on predicates

Alex Miller (Clojure team)14:03:20

(pending patch to fix that)

đź‘Ť 4
bbrinck14:03:52

But s/form returns something sensible for ::placeholder, yes?

bbrinck14:03:58

And ::maybe-fn

bbrinck14:03:29

You could parse those (probably using specs!!) and then build cases based off that

Alex Miller (Clojure team)14:03:54

you could use spec specs for that :) (CLJ-2112)

bbrinck14:03:00

🙂

hkjels14:03:00

🙂

hkjels14:03:33

here you see what I’m trying to achieve for all kinds of elements

hkjels14:03:03

it currently works for buttons, since there’s no atoms etc in use

hkjels14:03:39

Ohh, shoot. I got to run

kahunamoore17:03:44

@andy.fingerhut Thanks! I remember reading/hearing about it but Google failed me - too many spec tutorials, docs and other misses.

hkjels19:03:56

ohh, that nonconforming is just some cruft left there from trial and error

gfredericks23:03:27

@hkjels would (spec/* (s/alt string? ::hiccup)) work?

ghadi23:03:38

Need to label the branches @gfredericks ^

gfredericks23:03:58

yeah that sounds truthful