Fork me on GitHub
André Oliveira13:05:51

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


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


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


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


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

André Oliveira13:05:08

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

André Oliveira13:05:18

Do we have something like that?


no, core.async predates spec by a couple years


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 🙂

André Oliveira14:05:48

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.


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


until recently, that included core.async


but newest versions bumped minimum to 1.9