Fork me on GitHub
#clojure-spec
<
2020-05-11
>
braai engineer09:05:57

How do I use Spec with core.async? E.g. how do I spec a function that returns a channel where I'll put! another spec on? Or do I need to wrap it in some kind of record for this?

jkxyz16:05:21

you can spec that something is a Channel, but that’s not very useful, so you probably want to spec the values at the points where you put/take them

braai engineer20:05:17

Yes, I realized that I could spec the channel transducers that interpret incoming values on put!.

rafael22:05:11

I'm seeing strange behavior in spec alpha2 (latest github commit). If I define a schema using the map form, to specify non-namespaced keywords, refer to it from another schema, and later try to generate data from a selection of latter schema, I get an "Unable to resolve spec" exception:

; Context
  (s/def ::foo int?)
  (s/def ::inner (s/schema {:foo ::foo}))
  (s/def ::outer (s/schema [::inner]))

  ; Works as expected:
  (s/exercise ::outer)
  (s/exercise (s/select ::inner [*]))


  ; Fails with "Unable to resolve spec: :foo"
  (s/exercise (s/select ::outer [*]))

rafael22:05:34

Is this expected, should I change something in my code, or is it a bug that I should report somewhere?

seancorfield23:05:05

Spec 2 is very much a work in progress and isn't ready for folks to use -- and, yes, it has numerous bugs in it @rafael

rafael23:05:58

Yeah, so far I'm finding workarounds. I think I can work around this one as well with s/keys