babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-02-27T09:16:06.127900Z

@wilkerlucio Should now work on master :)

./bb -e '(defprotocol Foo (foo [_])) (extend-protocol Foo clojure.lang.Atom (foo [this] @this)) (foo (atom 1))'
1

borkdude 2021-02-27T09:17:14.128100Z

Wish me luck :) https://twitter.com/borkdude/status/1365589675335962626

10
🤞 1
1
wilkerlucio 2021-02-27T11:22:19.128700Z

good luck! 👍

wilkerlucio 2021-02-27T11:27:09.128900Z

seems like my utils are compiling fine now!

borkdude 2021-02-27T11:35:33.129400Z

Can you make a repro?

borkdude 2021-02-27T11:37:27.129600Z

If you will push your dev branch, I will try locally

borkdude 2021-02-27T11:40:14.129800Z

E.g. this works:

$ ./bb -e '(ns p) (defprotocol Foo (foo [_])) (ns r (:require p)) (defrecord Bar [x] p/Foo (foo [this] x)) (p/foo (->Bar 1))'
1

borkdude 2021-02-27T11:40:37.130Z

so I'm not sure what edge case you're hitting here

wilkerlucio 2021-02-27T11:43:17.130200Z

working on the repro

wilkerlucio 2021-02-27T11:45:43.130400Z

got it:

(ns pathom
  (:require [babashka.deps :as deps]))

(deps/add-deps
  '{:deps {borkdude/spartan.spec      {:git/url "<https://github.com/borkdude/spartan.spec>"
                                       :sha     "ef1fd1564d559dd446b3c11a35674eb9531e73b2"}
           com.wsscode/cljc-misc      {:git/url "<https://github.com/wilkerlucio/cljc-misc>"
                                       :sha     "bd48f6d1643a76db0d7046b5a007dfe77850e3db"}
           com.wsscode/pathom3        {:git/url "<https://github.com/wilkerlucio/pathom3>"
                                       :sha     "d0ef2f59dd9a83ddb4130cb7898926670ce89be9"}
           com.fulcrologic/guardrails {:git/url "<https://github.com/wilkerlucio/guardrails>"
                                       :sha     "b777e4244f9b608d5f4de0d74296ce3bb1ed732c"}}})

;; Loading spartan.spec will create a namespace clojure.spec.alpha for compatibility:
(require 'spartan.spec)
(alias 's 'clojure.spec.alpha)

; Expound expects some vars to be there, like `with-gen`. Spartan prints warnings that these are used, but doesn't implement them yet.
(require '[com.wsscode.pathom3.connect.operation :as pco])

wilkerlucio 2021-02-27T11:50:39.130600Z

ok, got it simpler

wilkerlucio 2021-02-27T11:50:50.130800Z

its about trying to extend clojure.lang.IFn

wilkerlucio 2021-02-27T11:50:53.131Z

(ns repro
  (:require [babashka.deps :as deps]))

(defrecord FnExtender
   clojure.lang.IFn
  (invoke [_this] nil)
  (invoke [_this input] nil)
  (invoke [_this env input] nil))

borkdude 2021-02-27T11:52:33.131400Z

This is a nasty edge case in babashka: reify works on protocols OR classes, but not both at the same time. This is a limitation related to not being able to define new classes in a graalvm native image

wilkerlucio 2021-02-27T11:55:53.131600Z

gotcha, gonna try to ignore the FN extension at definition on babashka

wilkerlucio 2021-02-27T11:56:06.131800Z

this is not required for pathom to work, is more a user convenience

wilkerlucio 2021-02-27T12:01:05.132Z

just got my first pathom output in babashka! 😄 🎉

borkdude 2021-02-27T12:01:10.132200Z

w000w!

wilkerlucio 2021-02-27T12:03:55.132400Z

just the defresolver macro still doesn't work

wilkerlucio 2021-02-27T12:04:23.132600Z

when I try to use that, I get:

----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Parameter declaration missing.
Phase:    analysis

borkdude 2021-02-27T12:04:37.132800Z

OK, repro would be nice

wilkerlucio 2021-02-27T12:04:43.133Z

ok, one moment

wilkerlucio 2021-02-27T12:07:44.133200Z

(ns pathom
  (:require [babashka.deps :as deps]))

(deps/add-deps
  '{:deps {borkdude/spartan.spec      {:git/url "<https://github.com/borkdude/spartan.spec>"
                                       :sha     "ef1fd1564d559dd446b3c11a35674eb9531e73b2"}
           com.wsscode/cljc-misc      {:git/url "<https://github.com/wilkerlucio/cljc-misc>"
                                       :sha     "bd48f6d1643a76db0d7046b5a007dfe77850e3db"}
           com.wsscode/pathom3        {:git/url "<https://github.com/wilkerlucio/pathom3>"
                                       :sha     "ef871acc1e3302f95aae404369d0fdd50ccd9b63"}
           com.fulcrologic/guardrails {:git/url "<https://github.com/wilkerlucio/guardrails>"
                                       :sha     "b777e4244f9b608d5f4de0d74296ce3bb1ed732c"}}})

;; Loading spartan.spec will create a namespace clojure.spec.alpha for compatibility:
(require 'spartan.spec)
(alias 's 'clojure.spec.alpha)

; Expound expects some vars to be there, like `with-gen`. Spartan prints warnings that these are used, but doesn't implement them yet.
(require '[com.wsscode.pathom3.connect.operation :as pco])

(pco/defresolver foo [] {})

borkdude 2021-02-27T12:08:54.133400Z

Can you maybe look at the macro expansion of this, to see if there's anything weird?

wilkerlucio 2021-02-27T12:09:33.133600Z

I'm guessing now its about a unform usage inside of it

wilkerlucio 2021-02-27T12:10:04.133800Z

and parameter declaration missing makes sense to me in this case

wilkerlucio 2021-02-27T12:10:12.134Z

because the args parts are coming from unform

borkdude 2021-02-27T12:10:17.134200Z

Maybe we can support this in spartan, I just haven't implemented it yet

wilkerlucio 2021-02-27T12:12:00.134400Z

you think its an easy one to get in?

wilkerlucio 2021-02-27T12:12:58.134700Z

I'm taking a look, its seems mostly about having that interface implemented for different types from spec

borkdude 2021-02-27T12:13:17.134900Z

I think so. We just need to add :unform to all the specs and copy it from spec.alpha proper

wilkerlucio 2021-02-27T12:20:18.135100Z

cool, but no big priority on it, for me at least, I can make my thing work easely without that 🙂

wilkerlucio 2021-02-27T12:28:50.135400Z

but thinking here, would be cool and better to have that, more reach, I was looking in spartan code, not sure how to add the unform, if you can kick it out, I can fill in the implementation for others, should I open an issue for that?

borkdude 2021-02-27T12:32:32.135600Z

please do. just check all the places where :cform occurs, we should add something like :unform there. Instead of reify spartan.spec just uses maps to implement all the spec stuff

wilkerlucio 2021-02-27T12:35:15.135800Z

gotcha 👍

wilkerlucio 2021-02-27T12:44:49.136Z

I'm working on it now

wilkerlucio 2021-02-27T13:17:16.136300Z

https://github.com/borkdude/spartan.spec/pull/21

borkdude 2021-02-27T13:30:27.136800Z

That's fast :)

borkdude 2021-02-27T13:30:50.137Z

I'm looking into .dispatchFn if there is a core fn for this like get-method, etc

borkdude 2021-02-27T13:31:06.137200Z

It seems CLJS has dispatch-fn

borkdude 2021-02-27T13:31:59.137400Z

user=&gt; (def mm (defmulti foo identity))
#'user/mm
user=&gt; @mm
#object[clojure.lang.MultiFn 0x27b000f7 "clojure.lang.MultiFn@27b000f7"]
user=&gt; (.dispatchFn @mm)
#object[clojure.core$identity 0xde88ac6 "clojure.core$identity@de88ac6"]

borkdude 2021-02-27T13:35:03.137600Z

@wilkerlucio I merged

wilkerlucio 2021-02-27T13:35:34.137800Z

cool! with that my defresolver works without changes 🙂

wilkerlucio 2021-02-27T13:38:01.138Z

here is some code affected by this whole process we are doing here 🙂 - https://github.com/fulcrologic/guardrails/pull/21 - https://github.com/wilkerlucio/pathom3/pull/19 - https://github.com/wilkerlucio/cljc-misc/pull/1/files

borkdude 2021-02-27T13:46:08.138200Z

Cool! I left a few remarks, some of them should not be necessary anymore on bb master

wilkerlucio 2021-02-27T13:46:36.138400Z

fixed that one 👍

wilkerlucio 2021-02-27T15:11:37.138900Z

nice! is there gonna be a video available of the talk?

borkdude 2021-02-27T15:23:30.139300Z

It is recorded, but I don't know if it and when will be publicly available

wilkerlucio 2021-02-27T16:11:41.139600Z

cool, and how was it? had fun doing it?

borkdude 2021-02-27T16:12:37.139900Z

It's always a bit weird to speak before non-Clojure community about Clojure, but I think it went well

borkdude 2021-02-27T16:19:33.140100Z

There are several talks going on now how they are using GraalVM at Facebook, Shopify, etc.

👀 1
borkdude 2021-02-27T16:19:45.140300Z

Also academic talks about comining machine learning with compiler optimizations