babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-01-20T08:53:30.078300Z

Welcome @slack1304 and @seminioni!

2021-01-20T08:54:55.079400Z

thank you @borkdude im newcomer in clojure(script) world, so hope will find a lot of interesting here 🙂

2021-01-20T11:29:54.081500Z

Hi all. Is it possible to extend protocols to clojure maps and functions with bb? I'm having a look at getting tick library working and it does

(extend-protocol Foo
  clojure.lang.Fn
  ...
in a few places

borkdude 2021-01-20T11:35:26.082400Z

@henryw374 Do you have an isolated small example for me?

borkdude 2021-01-20T11:38:24.083100Z

@henryw374 This works in bb:

(defprotocol Foo
  (foo [_]))

(extend-protocol Foo
  Number
  (foo [x] (prn :x x)))

(foo 1)

borkdude 2021-01-20T11:38:41.083500Z

But some classes aren't available (yet) which can be potentially fixed in the next version

2021-01-20T11:42:58.084900Z

ok so I found clojure.lang.IFn is there, so tick could use that instead of clojure.lang.Fn I think, but for maps,

#!/usr/bin/env bb

(defprotocol Foo
  (bar [_] ))

(extend-protocol Foo 
  clojure.lang.IFn
  (bar [f] (f))
  clojure.lang.APersistentMap
  (bar [x] x))

(bar (fn [] "yay!"))
(bar {})

2021-01-20T11:43:31.085400Z

so I guess clojure.lang.APersistentMap would need adding, unless there's an alternative

borkdude 2021-01-20T11:43:47.085900Z

a map is also an IFn, so not sure which one would take priority there

2021-01-20T11:44:02.086100Z

interesting!

2021-01-20T11:44:29.086800Z

yeah good point, I'll dig in. thanks

borkdude 2021-01-20T11:45:01.087Z

there is IPersistentMap in bb btw

2021-01-20T11:45:24.087200Z

:thumbsup:

borkdude 2021-01-20T11:47:29.087700Z

@henryw374 This works:

#!/usr/bin/env bb

(defprotocol Foo
  (bar [_] ))

(extend-protocol Foo
  clojure.lang.IPersistentMap
  (bar [x] [:map x])
  clojure.lang.IFn
  (bar [f] [:fn (f)]))

(prefer-method bar clojure.lang.IPersistentMap clojure.lang.IFn)

(prn (bar (fn [] "yay!")))

(prn (bar {}))
but it leaks the implementation detail that bb uses multi-methods to implement protocols ;P

2021-01-20T11:48:09.088Z

🙂

2021-01-20T11:48:43.088800Z

cool. I'm fairly sure I can get tick working then

borkdude 2021-01-20T11:50:25.089500Z

if we added clojure.lang.Fn to bb then you could leave out the impl detail

2021-01-20T11:51:22.089800Z

hmm, that'd be nicer for sure

borkdude 2021-01-20T11:53:28.090400Z

ok, I'll include that in 0.2.7, let me know when you want to release tick for bb, so I can push a new release

2021-01-20T11:57:52.091200Z

great thanks. no great hurry really 🙂

borkdude 2021-01-20T20:41:32.091700Z

Babashka 0.2.7 released We are re-introducing Alpine images along with the main Ubuntu image (thanks @rahul080327) https://hub.docker.com/repository/registry-1.docker.io/babashka/babashka/tags?page=1&ordering=last_updated And various other small improvements (like the one discussed earlier today).

🎉 2
borkdude 2021-01-20T22:13:26.092300Z

Someone got babashka to work on Raspberry: https://github.com/babashka/babashka/issues/241#issuecomment-763976749

💯 1
🎉 10
isak 2021-01-21T17:07:32.001Z

@franquito the default rasberry pi OS, or something else like the post?

frankitox 2021-01-21T17:09:29.001200Z

It's the Raspberry Pi OS, but a 64 bit beta, I downloaded based on what I read https://www.raspberrypi.org/forums/viewtopic.php?t=275370

1
isak 2021-01-21T17:33:58.001400Z

perfect

frankitox 2021-01-20T23:06:31.092700Z

Nice, works fine on my Pi 🙂 (And I'm using the 64 bit version of the OS)

👍 1