Fork me on GitHub
#clojure-spec
<
2017-10-23
>
Drew Verlee00:10:44

@alexmiller in the clojure spec workshop you said you wouldnt use constantly with with-gen in this example:

(def id-gen
  (gen/fmap #(str "ID-" %)
    (s/gen (s/int-in 100000 999999))))

(s/def ::id
  (s/with-gen (s/and string? #(re-matches id-regex %))
    (constantly id-gen)))
what was your advice on that?

Alex Miller (Clojure team)19:10:07

Well first, nothing actually wrong with this example. But I think I would prefer (fn [] id-gen) now.

Drew Verlee00:10:57

ugh, i shouldn't ping ppl at 8pm on sunday. got excited.

seancorfield02:10:34

@drewverlee It's OK to be excited at weekends 🙂 Just needs to be tempered with a little patience until most folks get to their desks on Monday morning 🙂

mmer15:10:20

Issues with : Call to clojure.core/let did not conform to spec: In: [0] val: () fails spec: :clojure.core.specs.alpha/bindings at: [:args :bindings :init-expr] predicate: any?, Insufficient input - Should I be using clojure.spec or clojure.spec.alpha in my namespace?

taylor15:10:33

if you’re using the latest version, the namespace is clojure.spec.alpha

mmer15:10:34

Thanks - but ...why am I seeing this error?

taylor15:10:35

can you post a code snippet of your let?

mmer15:10:53

Thanks Taylor - I had been getting errors all the time just when I added the clojure.alpha module to my project that I assumed the spec error was in spec not my code! But of course it was my code!

hiredman17:10:44

I am using spec as a parser, and have just noticed that when I parse a seq with 40 entries (all already realized in memory) I get out of memory errors, any ideas how to avoid this?

bfabry17:10:27

seems weird, lots of alternates?

hiredman17:10:32

2 alternates with 2 and 4 cases

hiredman17:10:28

I haven't played with changing how the spec is structured yet to see if that improves things

hiredman17:10:11

I do use s/& a few times, which I can imagine being expensive for backtracking

ghadi18:10:09

@hiredman any way you can file an issue?

Alex Miller (Clojure team)19:10:52

don’t know that I can help without a repro case or more info

Drew Verlee22:10:53

Any idea how you can get the keys from a spec?

(s/def ::foo (s/cat :name ::name))

(??? ::foo)
=> [:name]

bfabry22:10:07

@drewverlee there's a few different options. s/form will give you the spec definition as data that you could walk

Alex Miller (Clojure team)22:10:08

Spec form specs will eventually make this easier to answer (see clj-2112)

hiredman22:10:14

while I was fiddling with coming up with a minimal test case, I realized I could change the format slightly to have an explicit delimiter instead of an (s/& ...) check, which seems to have solved my performance issues