Fork me on GitHub
#clojure-spec
<
2018-08-10
>
ackerleytng00:08:41

What's a good way to kind of namespace specs internal to a file? So the issue is that s/keys needs to have a spec named, say foo

ackerleytng00:08:28

So I would do ::foo. However, my function returns a modified map, hence the :ret also has to be something that has s/keys with ::foo

ackerleytng00:08:51

And many functions in that file return modified maps

ackerleytng00:08:18

So I kind of want to namespace the spec for this function

ackerleytng00:08:03

I'm now doing :function-name-pre/foo

ackerleytng00:08:30

Anyone has a better solution?

taylor00:08:16

do you need qualified keys in the map? or are you going to have multiple */foo keys?

taylor00:08:35

if not, why not use unqualified keys?

taylor00:08:28

or maybe I misunderstand the question

ackerleytng00:08:21

The s/keys already spec it as unqualified

ackerleytng00:08:27

Because of that

ackerleytng00:08:50

The actual key has to have a name that matches the key in the map that is specced

taylor00:08:38

sorry, not sure I understand what the question is then

ackerleytng00:08:31

Maybe in short it's "how do you group specs for a function?"

seancorfield00:08:19

@ackerleytng I'm not sure I understand the problem you think you have... why does :ret come into this and cause you a problem?

seancorfield00:08:50

Perhaps if you shared a concrete example?

ackerleytng00:08:06

Sure hmm I'll work one out and post it later

bja17:08:32

is ::s/invalid part of the public api?

seancorfield17:08:22

I don't believe so but there's a function s/invalid? you can use to test for that value.

seancorfield17:08:07

(that said, I've written conforming predicates that return either an updated value or ::s/invalid a few times so...)

4
dadair17:08:13

I have a spec that checks that one of the keys is a core.async channel; I’d like to write a custom generator for that specific key spec, but I can’t seem to determine how to write a generator that returns a channel; I feel like I’m missing something obvious here

dadair18:08:29

Hmm that would probably work! Thanks!

👍 4
Alex Miller (Clojure team)20:08:14

yes, ::s/invalid is part of the public api @bja @seancorfield

seancorfield21:08:36

Thanks for the clarification @alexmiller!

bbrinck23:08:10

I’ve created a new channel for expound-related questions - #expound