This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-04
Channels
- # announcements (7)
- # babashka (32)
- # beginners (106)
- # bristol-clojurians (10)
- # cider (6)
- # clj-kondo (5)
- # cljdoc (10)
- # clojure (110)
- # clojure-australia (10)
- # clojure-dev (6)
- # clojure-europe (12)
- # clojure-nl (2)
- # clojure-norway (16)
- # clojure-spec (9)
- # clojure-uk (59)
- # clojurescript (105)
- # community-development (2)
- # conjure (46)
- # cursive (12)
- # data-science (1)
- # datalog (26)
- # datomic (37)
- # docker (4)
- # emacs (10)
- # events (1)
- # fulcro (8)
- # graalvm (2)
- # jobs (1)
- # jobs-discuss (1)
- # malli (24)
- # meander (13)
- # off-topic (52)
- # pathom (4)
- # polylith (17)
- # proletarian (4)
- # react (1)
- # rewrite-clj (4)
- # shadow-cljs (56)
- # sql (21)
- # xtdb (14)
@dennisa you can pass return values from one task to another like this:
{:tasks {a (+ 1 2 3) b {:depends [a] :task (+ a 2)}}}
aha, so the whole output of a
will be passed to b
? If b
has command line params as well they can be passed separately?
note that "return value" isn't the same as "output", as in text written to the console
I don't think this is possible right now, since the var named by the task isn't defined by then yet
else you could have done something like:
:leave (prn (deref (resolve (:name (current-task)))))
It does work for dependencies since they already defined:
{:tasks {:leave (prn (map (comp deref resolve) (:depends (current-task))))
a 1
b {:depends [a]
:task (+ a 1)}}}
This is powerful stuff. I'd update the bb book, because I saw the :depends section but it was not clear if the output is passed as well (vs only task a being called first)
Hi, I'm trying to use a library on Babashka that wraps some Java objects, and I'm having the following error:
Unable to resolve classname: java.util.function.Function
Is Function
not enabled on Babashka by default?
but Function
seems like a pretty useful thing to have, just curious about the application
Ah, right! Interesting! I was trying to make funcool/promesa
wok with bb
They import these libs:
java.util.function.Function
java.util.function.BiFunction
java.util.function.BiConsumer
java.util.function.Supplier
java.util.function.Consumer
I would suggest making a fork of bb and add these classes to babashka.impl.classes and see how far you would get
you can invoke bb via clojure CLI using clojure -M:babashka/dev
if you make some alias for it
bb doesn't support this, it could to a certain degree but not if deftypes implement Java interfaces since GraalVM doesn't support creating new classes at runtime
Yeah, it'll probably not be so simple to port then. Ok, thanks 🙂
Hi, I'm trying to rewrite a little babashka script (https://github.com/whatacold/babashka-tools/blob/master/illustrate.clj) using rewrite-clj to evaluate top-level forms and appends the result in comments for illustration purpose. For example, I want to transform below:
(defn my-function [a]
(* a 3))
(my-function 7)
to something like:
(defn my-function [a]
(* a 3))
;; => user/my-function
(my-function 7)
;; => 21
But I'm a little stuck that the last comment didn't show up, here is what I came up:
(require '[rewrite-clj.zip :as z]
'[rewrite-clj.node :as n]
'[rewrite-clj.parser :as p])
;; define some test data
(def data-string
"
(defn my-function [a]
(* a 3))
(my-function 7)
")
;; parse code to nodes, create a zipper, and navigate to the first non-whitespace node
(def zloc (z/of-string data-string))
(loop [cur zloc
left cur]
(println "current string {{" (z/string cur) "}}")
(if (z/end? cur)
(println "final string: {{" (z/root-string left) "}}") ; XXX it doesn't work as expected!!!
(recur (z/right (z/insert-right cur (p/parse-string ";; test\n"))) cur)
))
The output is like this:
current string {{ (defn my-function [a]
(* a 3)) }}
current string {{ (my-function 7) }}
current string {{ nil }}
final string: {{
(defn my-function [a]
(* a 3)) ; test
(my-function 7)
}}
What's the problem with my code?
Thanks.@whatacold if you don't get an answer here, you might also wanna try #rewrite-clj