This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-04
Channels
- # announcements (1)
- # architecture (18)
- # aws (7)
- # babashka (63)
- # beginners (38)
- # bristol-clojurians (1)
- # circleci (1)
- # clj-kondo (10)
- # clojars (4)
- # clojure (159)
- # clojure-berlin (3)
- # clojure-europe (4)
- # clojure-italy (7)
- # clojure-losangeles (6)
- # clojure-nl (7)
- # clojure-spec (3)
- # clojure-uk (109)
- # clojurescript (54)
- # css (1)
- # cursive (38)
- # data-science (2)
- # datascript (3)
- # datomic (14)
- # docker (2)
- # duct (11)
- # fulcro (47)
- # jobs (8)
- # jobs-discuss (3)
- # kaocha (4)
- # malli (3)
- # nyc (2)
- # off-topic (30)
- # overtone (3)
- # re-frame (17)
- # reagent (33)
- # shadow-cljs (29)
- # spacemacs (3)
- # specter (4)
- # tools-deps (13)
- # xtdb (13)
is there a way to verify if something is a core async channel?
(satisfies? clojure.core.async.impl.protocols/ReadPort ...)
==> clojure.lang.ExceptionInfo: Could not resolve symbol: satisfies? [at /home/stijn/Documents/code/vouch/ops-tools/src/vouch/ops/run/main.clj, line 19, column 8]
(instance? clojure.core.async.impl.channels.ManyToManyChannel ...)
==> clojure.lang.ExceptionInfo: Unable to resolve classname: clojure.core.async.impl.channels.ManyToManyChannel
how does one do this normally with core.async? I should probably add satisfies?
to sci
what works is
(try (println (async/<!! result))
(catch IllegalArgumentException e
(println result)))
there is some discussion about how this should be done, currently the only way is to rely on the clojure.core.async.impl namespaces https://clojure.atlassian.net/browse/ASYNC-74
I'll take a look at sci this evening, might ask you some questions if I can't figure it out 🙂
ok, I added satisfies?
to bb master now. but I think we need something more than this
you can take a look at the commit how this is done, for next time if something is missing
but to make this work we also need to resolve clojure.core.async.impl.protocols/ReadPort
in bb and I'm not sure what this "thing" is, a var, a class?
(defprotocol ReadPort
(take! [port fn1-handler] "derefable val if taken, nil if take was enqueued"))
yeah, but when I evaluate that symbol, I get:
clojure.core.async.impl.protocols/ReadPort
{:on clojure.core.async.impl.protocols.ReadPort, :on-interface clojure.core.async.impl.protocols.ReadPort, :sigs {:take! {:name take!, :arglists ([port fn1-handler]), :doc "derefable val if taken, nil if take was enqueued"}}, :var #'clojure.core.async.impl.protocols/ReadPort, :method-map {:take! :take!}, :method-builders {#'clojure.core.async.impl.protocols/take! #function[clojure.core.async.impl.protocols/eval10217/fn--10218]}}
, so what is that?@stijn This now works on master:
$ ./bb '(satisfies? clojure.core.async.impl.protocols/ReadPort (async/chan))'
true
if you need to add more protocols, then I trust you can figure it out using the previous two commits. there are links to newly built binaries in #babashka_circleci_builds
@stijn should work with these from #babashka_circleci_builds : [linux - master@d3f1b051022e1979c9c25944c4374aa8f38622f0]:Â https://3997-201467090-gh.circle-artifacts.com/0/release/babashka-0.0.70-SNAPSHOT-linux-amd64.zip [12:46 PM] [macos - master@d3f1b051022e1979c9c25944c4374aa8f38622f0]:Â https://3996-201467090-gh.circle-artifacts.com/0/release/babashka-0.0.70-SNAPSHOT-macos-amd64.zip
are you ok with a PR with some additional class imports from Java > https://github.com/borkdude/babashka/blob/master/src/babashka/impl/classes.clj?
I'm reaching next level complexity with Sci and cljsjs interop 🙈
maybe i just thought it was easy and I need to be patient
I mean, cljsjs as in https://github.com/cljsjs?
Ah yeah, I'm trying this package now for http requests https://github.com/cljsjs/packages/tree/master/axios
@jeroenvandijkSo you are evaluating the CLJS code from that package in sci?
I'm not completely sure what I'm doing anymore. I'll break it down in smaller steps
My first approach didn't work unfortunately
I wanted to use two seperately compiled scripts (Sci and my Aws code) together
This works in normal mode, but in advanced compilation it fails (maybe obviously)
So now I'm trying to combine things from one script. I forgot why the npm request module didn't work. I need to take better notes 🙈
> > "my AWS code" is written in normal CLJS? > > Yeah I ported the signing part of https://github.com/cognitect-labs/aws-api/ to CLJS > >
if you compile that to advanced, then your functions will be renamed, so that might be the issue? if you add ^:export
metadata, those functions will not be renamed.
I'll prepare some examples of what doesn't work. It became a bit of a mess (in my head)
I've tried ^:export
in a few ways. Probably I've still missed a working combination
@borkdude ok I have it working https://gist.github.com/jeroenvandijk/c65dda62c086936704de657b2004eb8d
The trick was indeed the ^:export
, but I also have to require the libraries. E.g. global.request = require('request')
https://gist.github.com/jeroenvandijk/c65dda62c086936704de657b2004eb8d#file-node_test-js-L13
cljsjs doesn't seem to help much. I don't understand why not
I'm also wondering why you didn't have to ^;export
all the clojure functions for Sci. So still some unsolved riddles
Maybe it's because sci/eval-string
touches all those functions in the compilation and my new function is not part of this
@borkdude I was trying to use java.text.SimpleDateFormat and java.util.TimeZone, but it all works with java.time.
@jeroenvandijk: I actually have a slide about this in my upcoming presentation about babashka/sci:
I think I'm doing something similar. Apparantly not exactly the same 🙂
so even if CLJS advanced is going to rename things, this will still work, because we implement our own "resolve"
Smart 🙂