@wilkerlucio Should now work on master :)
./bb -e '(defprotocol Foo (foo [_])) (extend-protocol Foo clojure.lang.Atom (foo [this] @this)) (foo (atom 1))'
1
Wish me luck :) https://twitter.com/borkdude/status/1365589675335962626
good luck! 👍
seems like my utils are compiling fine now!
Can you make a repro?
If you will push your dev branch, I will try locally
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
so I'm not sure what edge case you're hitting here
working on the repro
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])
ok, got it simpler
its about trying to extend clojure.lang.IFn
(ns repro
(:require [babashka.deps :as deps]))
(defrecord FnExtender
clojure.lang.IFn
(invoke [_this] nil)
(invoke [_this input] nil)
(invoke [_this env input] nil))
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
gotcha, gonna try to ignore the FN extension at definition on babashka
this is not required for pathom to work, is more a user convenience
just got my first pathom output in babashka! 😄 🎉
w000w!
just the defresolver
macro still doesn't work
when I try to use that, I get:
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Parameter declaration missing.
Phase: analysis
OK, repro would be nice
ok, one moment
(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 [] {})
Can you maybe look at the macro expansion of this, to see if there's anything weird?
I'm guessing now its about a unform
usage inside of it
and parameter declaration missing makes sense to me in this case
because the args parts are coming from unform
Maybe we can support this in spartan, I just haven't implemented it yet
you think its an easy one to get in?
I'm taking a look, its seems mostly about having that interface implemented for different types from spec
I think so. We just need to add :unform
to all the specs and copy it from spec.alpha proper
cool, but no big priority on it, for me at least, I can make my thing work easely without that 🙂
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?
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
gotcha 👍
I'm working on it now
That's fast :)
I'm looking into .dispatchFn
if there is a core fn for this like get-method
, etc
It seems CLJS has dispatch-fn
user=> (def mm (defmulti foo identity))
#'user/mm
user=> @mm
#object[clojure.lang.MultiFn 0x27b000f7 "clojure.lang.MultiFn@27b000f7"]
user=> (.dispatchFn @mm)
#object[clojure.core$identity 0xde88ac6 "clojure.core$identity@de88ac6"]
@wilkerlucio I merged
cool! with that my defresolver
works without changes 🙂
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
Cool! I left a few remarks, some of them should not be necessary anymore on bb master
fixed that one 👍
nice! is there gonna be a video available of the talk?
It is recorded, but I don't know if it and when will be publicly available
cool, and how was it? had fun doing it?
It's always a bit weird to speak before non-Clojure community about Clojure, but I think it went well
There are several talks going on now how they are using GraalVM at Facebook, Shopify, etc.
Also academic talks about comining machine learning with compiler optimizations