Fork me on GitHub
#clojure-spec
<
2020-01-27
>
favila21:01:00

is there any advice for speccing containers, e.g. atoms or delays?

vemv16:01:39

Say you have a check! function. I normally hook up the :validator to it, but only on *assert*

favila17:01:22

I went with an fspec instead

favila17:01:59

Most ref types have validators, I forgot about those. you could use s/assert in there

favila17:01:20

doesn’t help with generation, but there’s manual intervention for generation all the time anyway

favila17:01:32

delays however don’t have validators

vemv17:01:36

> doesn’t help with generation, yeah it's a tradeoff :) > delays however don’t have validators yup, as you may know though a custom IDeref impl can be quite thin

favila21:01:25

I’d like to say “takes a delay that returns a thing satisfying some predicate when derefed”

seancorfield21:01:32

@favila There's no way to do that. You can spec around the code that processes what's inside the container, but you can't spec the container itself.

lilactown21:01:08

atoms do have validator functions that you can pass in on instantiation I think?

Alex Miller (Clojure team)21:01:47

but carefully consider the costs there