core-async

André Oliveira 2020-05-27T13:07:51.329300Z

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

alexmiller 2020-05-27T13:10:40.329700Z

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

alexmiller 2020-05-27T13:10:57.330200Z

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

2020-05-27T13:13:05.330600Z

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

alexmiller 2020-05-27T13:15:36.331400Z

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

alexmiller 2020-05-27T13:16:58.333Z

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

2020-05-27T13:19:43.333200Z

Good to know

André Oliveira 2020-05-27T13:29:08.334Z

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

André Oliveira 2020-05-27T13:29:18.334200Z

Do we have something like that?

alexmiller 2020-05-27T13:34:47.334600Z

no, core.async predates spec by a couple years

alexmiller 2020-05-27T13:39:26.335700Z

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

jrychter 2020-05-27T13:42:33.336900Z

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.

2020-05-27T13:45:46.337300Z

There's discussion about it here: https://clojure.atlassian.net/browse/ASYNC-74

2020-05-27T13:46:17.337600Z

Oh wait, you commented there 🙂

André Oliveira 2020-05-27T14:07:48.339Z

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.

alexmiller 2020-05-27T15:47:06.339600Z

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

alexmiller 2020-05-27T15:47:55.340Z

until recently, that included core.async

alexmiller 2020-05-27T15:48:09.340400Z

but newest versions bumped minimum to 1.9