clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
Petrus Theron 2020-05-11T09:50:57.333200Z

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?

jkxyz 2020-05-11T16:45:21.333500Z

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

rafael 2020-05-11T22:44:11.337500Z

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 [*]))

rafael 2020-05-11T22:44:34.338Z

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

seancorfield 2020-05-11T23:15:05.338700Z

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

rafael 2020-05-11T23:25:58.339500Z

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