This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-26
Channels
- # aleph (4)
- # announcements (3)
- # babashka (31)
- # beginners (74)
- # bitcoin (7)
- # calva (11)
- # cider (17)
- # clj-kondo (5)
- # clojars (11)
- # clojure (81)
- # clojure-australia (3)
- # clojure-dev (73)
- # clojure-europe (136)
- # clojure-nl (5)
- # clojure-spec (10)
- # clojure-uk (41)
- # clojurescript (30)
- # core-async (1)
- # cursive (19)
- # data-oriented-programming (4)
- # datascript (5)
- # datomic (6)
- # docker (6)
- # emacs (1)
- # figwheel-main (1)
- # fulcro (6)
- # jobs (1)
- # jobs-discuss (17)
- # lsp (23)
- # malli (6)
- # off-topic (35)
- # pathom (2)
- # re-frame (56)
- # reitit (2)
- # rewrite-clj (3)
- # shadow-cljs (10)
- # spacemacs (6)
- # sql (11)
- # vim (16)
- # xtdb (3)
Is there a way to gt bb to report in a way that refactor-nrepl undersands?
I RTFM. Sorry about the noise.
Made this experimental malli pod. https://github.com/babashka/pod-babashka-malli
(prn (m/validate [:cat 'int? 'int?] [1 1]))
;; => true
(prn (me/humanize [:cat 'int? 'int?] [1 :foo]))
;; => [nil ["should be an int"]]
$ time bb test.clj
true
[nil ["should be an int"]]
bb test.clj 0.01s user 0.01s system 51% cpu 0.049 total
@borkdude next one
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: force
Location: /Users/wilkerlucio/Development/guardrails/src/main/com/fulcrologic/guardrails/core.cljc:49:8
Phase: analysis
----- Context ------------------------------------------------------------------
45: (let [{:keys [level ?err msg_ ?ns-str ?file hostname_
46: timestamp_ ?line]} data]
47: (str
48: (string/upper-case (name level)) " "
49: (force msg_)
^--- Could not resolve symbol: force
50: (when-let [err ?err]
51: (str "\n" (utils/stacktrace err))))))
52:
53: (defn now-ms [] #?(:clj (System/currentTimeMillis)
54: :cljs (inst-ms (js/Date.))))
That's also a case of juts adding to https://github.com/wilkerlucio/sci/blob/master/src/sci/impl/namespaces.cljc?@wilkerlucio Already pushed to sci and bb master
thanks, was about to make it, but you got there faster 🙂
humm, this time I got an error, but that's not pointing to where it happens:
----- Error --------------------------------------------------------------------
Type: java.lang.UnsupportedOperationException
Message: nth not supported on this type: Symbol
Can you make a repro repo for me where I can test this out locally? Usually I discover this by bisecting the code
I'm not sure why the location is missing here. Could be the result of a macro-expansion that is failing to execute
I'm doing that bisect myself, find the file already at least 🙂
@borkdude I believe I found in something related to spartan, this code breaks:
(ns demo
(:require [babashka.deps :as deps]))
(deps/add-deps
'{:deps {borkdude/spartan.spec {:git/url ""
:sha "bf4ace4a857c29cbcbb934f6a4035cfabe173ff1"}}})
;; Loading spartan.spec will create a namespace clojure.spec.alpha for compatibility:
(require 'spartan.spec)
(alias 's 'clojure.spec.alpha)
(s/def ::args+gspec+body
(s/&
(s/cat :args ::arg-list)
(fn arg-specs-match-param-count? [{:keys [args gspec]}]
true)))
something about using s/&
with a pred
I can reproduce this with:
$ bb -e "(defmacro foo [] \`(do [(nth (symbol :dude) 0)])) (foo)"
----- Error --------------------------------------------------------------------
Type: java.lang.UnsupportedOperationException
Message: nth not supported on this type: Symbol
I mean, the location issue. This is a general problem with macro generated code, there are no locsFixed by removing an old hack and replacing it with spec's original code because things have been improving ;)
is there a verbose/debug way to run to get more details?
Should rewrite-clj
work in babshka?
(deps/add-deps '{:deps {borkdude/rewrite-edn {:mvn/version "0.0.1-alpha.2"}}})
(require '[borkdude.rewrite-edn :as r])
results in an error - seems like .cljc
files are not supported?
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Could not find namespace: rewrite-cljc.node.
Location: borkdude/rewrite_edn/impl.cljc:3:3
----- Context ------------------------------------------------------------------
1: (ns borkdude.rewrite-edn.impl
2: (:refer-clojure :exclude [assoc update assoc-in update-in])
3: (:require [rewrite-cljc.node :as node]
^--- Could not find namespace: rewrite-cljc.node.
4: [rewrite-cljc.zip :as z]))
5:
6: (defn maybe-right [zloc]
7: (if (z/rightmost? zloc)
8: zloc
@nha - rewrite-clj itself doesn't work with babashka. - .cljc files are supported To manipulate code with babashka I recommend using: - https://github.com/babashka/pod-registry/blob/master/examples/parcera.clj
rewrite-clj is quite convenient, maybe one day we could have a sci-based CLI dedicated to it :)
it is 🙂 parcera looks overkill for me as I am just doing some light editing of deps.edn
files
I ended up hacking something with parcera btw:
(defn replace-version
"for deps.edn files
ex.
(replace-version \"com.turtlequeue/java-sdk\" \"(str root-dir \"/quickstart/clj/deps.edn\")\" \"1.0.0\")"
[artefact file-path version]
;;
(let [parsed (parcera/ast (slurp file-path))
zloc (zip/zipper (fn [obj]
(and (seq? obj)
(some-> obj second first keyword?)))
rest
(fn [node children]
(list* (first node) children))
(second parsed))
res (loop [zloc zloc
st {:name-found? false
:mvn-version-found? false}]
(if-not (zip/end? zloc)
(let [node (zip/node zloc)]
#_(when-not (= :whitespace (first node))
(prn node)
(prn (parcera/code node))
(println "STATE " st))
(cond
(= (list :symbol artefact) node)
(recur (zip/next zloc)
(assoc st :name-found? true))
(and
(:name-found? st)
(= '(:keyword ":mvn/version") node))
(recur (zip/next zloc)
(assoc st :mvn-version-found? true))
(and (:name-found? st)
(:mvn-version-found? st)
(seq node)
(= :string (first node))
(string? (second node))
(= 2 (count node)))
(parcera/code (zip/root (zip/replace zloc (list :string (str "\"" version "\"")))))
:default
(recur (zip/next zloc) st)))
(do
(warn "Version not found for " artefact " " file-path " " version)
(parcera/code (zip/root zloc)))))]
(spit file-path res)))
good enough for what I’m doingcan I do this with babashka? https://github.com/wilkerlucio/cljc-misc/blob/73844cee606e5fe22f7ab24b7100415090bd5a1d/src/main/com/wsscode/misc/refs.cljc#L29-L44 if I can, how can I reference the Atom class to extend it?