Fork me on GitHub

Hello everyone. Do you folks know any lib that provides clojure.specs for core.async?

Alex Miller (Clojure team)13:05:40

that's challenging in several different ways, so what exactly are you looking for?

Alex Miller (Clojure team)13:05:57

spec for the existing core.async api or the ability to use specs for your data flowing through channels?


(defn chan? [x] (instance? clojure.core.async.impl.channels.ManyToManyChannel x))
if you just want to check if something is a chan

Alex Miller (Clojure team)13:05:36

while that will kind of work right now, it's not really the right spec and is likely to eventually not work

Alex Miller (Clojure team)13:05:58

channels implements ReadPort and WritePort protocols and most core.async functions should be thought of as taking/returning one of those. It's possible to just implement one of those port contracts and not be an instance of channel and satisfy core.async


Good to know


That's cool, but I was thinking more about specs for the existing core.async api.


Do we have something like that?

Alex Miller (Clojure team)13:05:47

no, core.async predates spec by a couple years

Alex Miller (Clojure team)13:05:26

I'm not sure most of it would give you a lot of value by being spec'ed, and some of the ! /go stuff is probably interesting with respect to combination with specs


I would get a lot of value out of a chan? predicate that I could use in my :pre/:post -conditions in both Clojure and ClojureScript.


Oh wait, you commented there 🙂


I'm not actually missing it, I'm learning core.async and documentation and guides are fine. I was just wondering that since spec is becoming a "standard" in Clojure, every library would have it, but maybe that is not the case.

Alex Miller (Clojure team)15:05:06

a lot of libs still try to support older clojure versions pre-spec too

Alex Miller (Clojure team)15:05:55

until recently, that included core.async

Alex Miller (Clojure team)15:05:09

but newest versions bumped minimum to 1.9