Fork me on GitHub
#core-async
<
2020-05-27
>
André Oliveira13:05:51

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

alexmiller13:05:40

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

alexmiller13:05:57

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

jjttjj13:05:05

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

alexmiller13:05:36

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

alexmiller13: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

jjttjj13:05:43

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?

alexmiller13:05:47

no, core.async predates spec by a couple years

alexmiller13: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

jrychter13:05:33

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.

jjttjj13:05:17

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.

alexmiller15:05:06

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

alexmiller15:05:55

until recently, that included core.async

alexmiller15:05:09

but newest versions bumped minimum to 1.9