This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-10
Channels
- # adventofcode (54)
- # announcements (30)
- # asami (13)
- # aws (10)
- # babashka (16)
- # babashka-sci-dev (44)
- # beginners (95)
- # calva (63)
- # clara (10)
- # clj-kondo (3)
- # cljfx (6)
- # cljs-dev (7)
- # cljsrn (1)
- # clojure (68)
- # clojure-europe (59)
- # clojure-nl (7)
- # clojure-norway (12)
- # clojure-spec (6)
- # clojure-uk (6)
- # clojurescript (4)
- # component (4)
- # conjure (5)
- # datomic (3)
- # deps-new (1)
- # events (4)
- # exercism (1)
- # figwheel-main (1)
- # fulcro (33)
- # gratitude (1)
- # improve-getting-started (3)
- # jobs (3)
- # lsp (5)
- # malli (10)
- # membrane (5)
- # music (3)
- # nextjournal (6)
- # off-topic (42)
- # pedestal (2)
- # polylith (14)
- # portal (11)
- # re-frame (42)
- # releases (3)
- # reveal (4)
- # shadow-cljs (62)
- # tools-build (1)
- # tools-deps (3)
- # web-security (1)
- # xtdb (3)
Watch a script and run tests while developing. Maybe something for #adventofcode? https://github.com/babashka/babashka/discussions/1102
In the babashka script that I'm writing, I want to optionally process input from stdin. That is, both git diff a..b --name-only | components
as well as components a b
are valid invocations of the command. My problem is that if I use (slurp *in*)
to read the input, then the components a b
version of the command hangs forever waiting for input on the in pushbackreader.
What's the right way to deal with this?
@h0bbit Not really sure how reliable this is, but you can try .available
:
$ bb -e '(.available System/in)'
0
$ echo 'hello' | bb -e '(.available System/in)'
6
@h0bbit usually command line applications do this with an explicit arg like --stdin
or just -
@borkdude yeah, that makes sense. I think I'll put in an explicit argument --stdin
. I don't think -
is an acceptable input for cli-opts
.
Babashka 0.7.0 (2021-12-10)
• Add compatibility with `clojure.spec.alpha`. See https://github.com/babashka/spec.alpha.
• Add `to-array-2d`, `aclone`, `areduce` and `amap` (https://github.com/MrEbbinghaus)
• Add `inst-ms`
• Add `java.util.StringTokenizer`
• clojure.core/read
 can read with `PushbackReader` that is not `LineNumberingPushbackReader`
• Allow macroexpand on `for` and `doseq` (https://github.com/erdos)
• Add `clojure.instant/read-instant-date`
• Add `StackTraceElement->vec`
• Add `memfn`
• Implement Java field access (for `clojure.spec.alpha`)
• Warn on requiring `clojure.spec.alpha`, suggesting to use https://github.com/babashka/spec.alpha
• Warn on requiring `clojure.core.specs.alpha`, suggesting to explicitly add it to deps
• Deprecate `$` in babashka.process (still available, but no longer recommended)
New blog post! Using `clojure.spec.alpha` with babashka: https://blog.michielborkent.nl/using-clojure-spec-alpha-with-babashka.html

The reason for deprecation was that threading didn't work properly and I don't think the fancy syntax really added any value. But if enough people convince me otherwise and want to fix an issue with it, I may un-deprecate it in the future :).
i've ran into some issues with it too, like lsp formatter will try to add a space
($ script param=~p1) -formater-> ($ script param= ~p1)
and that breaks that scriptAfter evaluation param=
and ~p1
are two different token anyway, so this isn't something that can be fixed in the macro either. But I undeprecated it now again.
A spec demo using the core specs.
$ neil add dep :lib babashka/spec.alpha :latest-sha true :deps-file bb.edn
$ neil add dep :lib org.clojure/core.specs.alpha :deps-file bb.edn
$ bb -e "(require '[clojure.spec.alpha :as s] '[clojure.core.specs.alpha :as cs])
(s/conform ::cs/defn-args '[foo [x] x])"
{:fn-name foo, :fn-tail [:arity-1 {:params {:params [[:local-symbol x]]}, :body [:body [x]]}]}
$ bb -e "(require '[clojure.spec.alpha :as s] '[clojure.core.specs.alpha :as cs] '[clojure.test.check.generators :as gen]) (gen/sample (s/gen ::cs/defn-args))"
((_ ([] {} nil)) (j {} [] ()) (R [] {} [false] nil)
I guess y'all know how spec works, but I'm just excited that pretty much all of it works in bb now ;)Today's Advent of Code puzzle was babashka-shaped again in terms of performance. https://twitter.com/borkdude/status/1469434518624948224