Fork me on GitHub
#babashka
<
2020-05-23
>
David Pham07:05:39

Is there an alternative to deps.clj for making Uberscript?

borkdude07:05:06

Making an uberscript is not coupled to a build tool.

David Pham08:05:48

In the example of the documentation it uses deps.clj though. So the logic is to concatenation all the required files into a single one and append the main function in the user Ns?

borkdude08:05:28

well, the main function stays in the same namespace it was in, but the invocation of the main namespace is also going into the uberscript

David Pham08:05:22

I should write a bb script that does it :)

solf09:05:23

Before I dig more into it, does bb --nrepl-socket have support for eldoc when using it with cider? Might be a problem with my setup

borkdude09:05:52

@dromar56 Does that require a cider nrepl middleware thing? I don't think it's in there right now

solf09:05:31

I'm not sure, I think not but I'll investigate and come back

borkdude09:05:49

@dromar56 Maybe you could try it with normal Clojure and then inspect the *nrepl-messages* to see what gets sent back and forth.

solf09:05:06

Oh I didn't knew about that, yeah I'll try it

solf09:05:55

Seems like there's an eldoc op:

(-->
  id         "40"
  op         "eldoc"
  session    "52835e30-dd83-4092-adf6-4c529a995bb1"
  time-stamp "2020-05-23 17:39:41.254514485"
  ns         "user"
  symbol     "foo"
)

borkdude09:05:29

and what is the reply to that message?

borkdude09:05:10

@U051BLM8F can we find docs on this op somewhere?

solf09:05:20

(-->
  id         "40"
  op         "eldoc"
  session    "52835e30-dd83-4092-adf6-4c529a995bb1"
  time-stamp "2020-05-23 17:39:41.254514485"
  ns         "user"
  symbol     "foo"
)
(<--
  id         "40"
  session    "52835e30-dd83-4092-adf6-4c529a995bb1"
  time-stamp "2020-05-23 17:39:41.259135909"
  docstring  nil
  eldoc      (("x" "y"))
  name       "foo"
  ns         "user"
  status     ("done")
  type       "function"
)

borkdude09:05:04

so it only shows the arguments?

solf09:05:47

Seems like it returns the docstring too, here's a more complete one (used on defn):

(-->
  id         "46"
  op         "eldoc"
  session    "52835e30-dd83-4092-adf6-4c529a995bb1"
  time-stamp "2020-05-23 17:45:12.853910691"
  ns         "user"
  symbol     "defn"
)
(<--
  id         "46"
  session    "52835e30-dd83-4092-adf6-4c529a995bb1"
  time-stamp "2020-05-23 17:45:12.856334080"
  docstring  "Same as (def name (fn [params* ] exprs*)) or (def
    name (fn ([params* ] exprs*)+)) with any doc-string or attrs added
    to the var metadata. prepost-map defines a map with optional keys
    :pre and :post that contain collections of pre or post conditions."
  eldoc      (("name" "doc-string?" "attr-map?" "[params*]" "prepost-map?" "body")
 ("name" "doc-string?" "attr-map?" "([params*] prepost-map? body)" "+" "attr-map?"))
  name       "defn"
  ns         "clojure.core"
  status     ("done")
  type       "function"
)

borkdude09:05:11

Seems easy enough to support in babashka.nrepl. If you want, you can provide a PR with tests: https://github.com/babashka/babashka.nrepl

borkdude09:05:56

Would be good to also first make an issue about it with the above examples.

solf09:05:49

I'll make the issue and work on the PR over the week-end

solf09:05:27

good timing as I wanted to start learning about graalvm

borkdude09:05:45

the babashka.nrepl library can be tested entirely in the JVM which makes iterating on it go faster. but eventually the dep has to be updated in bb and then will be compiled with graalvm

borkdude09:05:54

and also spire, which is another CLI which uses it

borkdude10:05:28

it's really nice that these improvements will also benefit other CLIs. cc @U1QQJJK89

Crispin10:05:08

is this cider?

Crispin10:05:35

eldoc = emacs lisp doc?

Crispin11:05:08

we just need to make sure not to break other editors nrepls

borkdude11:05:25

it's the editors who issue an eldoc request, so it doesn't break anything if you implement additional ops

borkdude11:05:53

I guess editor like vim fireplace or conjure could also issue an eldoc command? @U38J3881W?

solf11:05:16

For those unfamiliar with eldoc, here's how it works on emacs

borkdude11:05:57

That's very cool

solf11:05:29

on the bottom line you can see the arguments of the function, and depending on where the cursor is the corresponding argument is bolded (in the screenshot the "x" is in bold, had my cursor been at "20" the "y" would be bold instead)

Olical15:05:30

Yep, i don't issue eldoc commands in Conjure but I probably will do at some point. I'll probably show the arg list in highlighted virtual text beside the line rather than at the bottom of nvim. Neovim doesn't really have the minibuffer sort of thing (I think that's what it is in emacs?)

borkdude12:05:06

Instructions how to build a sci-based GraalVM app with java11: https://github.com/borkdude/sci#java-11

👍 4
borkdude14:05:08

Upgraded bb to GraalVM java-11 20.1.0. Binaries in #babashka_circleci_builds. Would appreciate if you could try it out 🙂

🚀 4
nate14:05:21

Is 20.1.0 newly released?

borkdude14:05:43

recently yes

borkdude14:05:40

One issue that it should fix is this one: https://github.com/borkdude/babashka/issues/444

borkdude14:05:59

seems to work over here:

$ TZ=GMT+1 ./bb '(java.time.ZoneId/systemDefault)'
#object[java.time.ZoneRegion 0x197bd2b8 "GMT+01:00"]
$ ./bb '(System/setProperty "user.timezone" "GMT+3") (java.time.ZoneId/systemDefault)'
#object[java.time.ZoneRegion 0x76a3e81f "GMT+03:00"]

nate14:05:29

Is there a good test runner in bb? I know that clojure.test is there, but having some way of running all tests in the tests dir would be nice. I tried using the cognitect test runner, but it depends on tools.namespace, which has protocols.

borkdude14:05:48

ask in #kaocha if plexus wants to build one 😉

nate14:05:55

I've just been running my tests in clojure for the time being. Works well enough.

nate14:05:00

Oh cool. I'll try that out.

nate14:05:02

Thanks.

borkdude14:05:27

@nate To be honest, I think a little test runner script like this works in most cases: https://github.com/borkdude/babashka#running-tests

borkdude14:05:20

So just manually type the namespaces you want to test. It's usually a few anyway

borkdude14:05:16

(so the docs were there all along, I removed my previous comments)

nate14:05:30

Cool. Makes sense.

nate14:05:45

I agree that there are usually just a few.

borkdude14:05:12

hmm, adding bean to the next bb... 🙂

$ ./bb '(bean (java.time.ZoneId/systemDefault))'
{:class java.time.ZoneRegion, :id "Europe/Amsterdam", :rules #object[java.time.zone.ZoneRules 0x333fe8db "ZoneRules[currentStandardOffset=+01:00]"]}

👍 12
mbjarland04:05:03

Hmm, would you consider ??

mbjarland04:05:59

Not in core but more flexible, basically no deps and a single file namespace

mbjarland04:05:40

There is a comparison between bean and this at the bottom of the readme

borkdude07:05:31

Interesting

nate14:05:26

I wrote a bb script a couple of days ago and was showing it to someone. He commented on all the requires at the top and wondered where the deps.edn file was. I said that there wasn't one, all that is built into babashka. 🙂

😎 12
borkdude18:05:07

There is an amazing new pod coming up... stay tuned.

💯 28
🎉 8