This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-25
Channels
- # announcements (6)
- # asami (1)
- # babashka (80)
- # beginners (89)
- # bitcoin (1)
- # calva (30)
- # cider (33)
- # clj-kondo (1)
- # cljsrn (45)
- # clojars (5)
- # clojure (60)
- # clojure-australia (1)
- # clojure-dev (9)
- # clojure-europe (133)
- # clojure-italy (7)
- # clojure-nl (6)
- # clojure-uk (44)
- # clojurescript (11)
- # conjure (1)
- # data-oriented-programming (2)
- # datahike (13)
- # datascript (4)
- # datomic (19)
- # deps-new (29)
- # depstar (5)
- # duct (39)
- # fulcro (8)
- # girouette (1)
- # helix (10)
- # honeysql (17)
- # jobs (5)
- # jobs-discuss (2)
- # leiningen (6)
- # lsp (51)
- # malli (60)
- # meander (37)
- # membrane (8)
- # off-topic (31)
- # overtone (3)
- # pathom (36)
- # re-frame (8)
- # reagent (30)
- # remote-jobs (2)
- # sci (1)
- # sql (32)
- # startup-in-a-month (3)
- # testing (3)
- # tools-deps (7)
- # xtdb (7)
Is there a recommended way to provide auto-completion in inf-clojure
, when using babashka?
I see the default config currently doesn't define the completion
feature:
https://github.com/clojure-emacs/inf-clojure/blob/master/inf-clojure.el#L131-L141
but after seeing https://www.youtube.com/watch?v=TvBmtGS0KJEΒ i have the suspicion that nowdays it's possible to do define it in some reasonable way, even if it involves pulling in the clj-kondo pod.
Having malli to be bb compatible would be very nice, imho. Even a subset of that, which allows for validation and value transformations. I could see that very useful for command line validation or API validation.
@ikitommi @steveb8n I have a feature-malli
branch pushed to babashka repo.
$ ./bb -e "(require '[malli.core :as m]) (m/validate [:and int? [:> 6]] 7)"
true
$ ./bb -e "(require (quote [malli.core :as m])) (m/validate [:and [:fn '(fn [x] (int? x))] [:> 6]] 7)"
true
@ikitommi It seems the borkdude.dynaload setting really helps, it shaves almost 40mb of the binary size
I guess if malli would end up in bb, then we would need some kind of cli-matic like library which is not based on spec, but on malli ;)
$ ./bb -e "(malli.error/humanize (malli.core/explain [:map [:x string?] [:y int?]] {}))"
{:x ["missing required key"], :y ["missing required key"]}
(ns foo
(:require [clojure.tools.cli :as cli]
[malli.core :as m]
[malli.transform :as mt]))
(def cli-options
[["-n" "--number NUM" "A number"
:parse-fn (m/decoder int? mt/string-transformer)
:validate [(m/validator [:< 100])]]])
(prn (cli/parse-opts ["-n" "99"] cli-options))
;; =>
;; {:options {:number 99}, :arguments [], :summary " -n, --number NUM A number", :errors nil}
(prn (cli/parse-opts ["-n" "100"] cli-options))
;; =>
;; {:options {}, :arguments [], :summary " -n, --number NUM A number", :errors ["Failed to validate \"-n 100\""]}
@ikitommi Is it possible to get the humanized error for [:< 100]
? tools.cli expects a hard-coded string that is not dependent on the input :/
@ikitommi To clarify: If a lib works in Clojure and with GraalVM, it will also work with bb if it's included as a built-in library. But it's another story when you try to run this lib from source with bb itself
damn, you are a fast worker. being locked inside by winter must be good for productivity π
Dear bb community. Consider leaving feedback in this issue about adding malli: https://github.com/babashka/babashka/issues/737
does babaksha supports transients? got bitten by missing dissoc!
:
wilkerlucio@Wilkers-MacBook-Pro-2 babashka-experiments % bb
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: dissoc!
Location: com/fulcrologic/guardrails/utils.cljc:85:89
Phase: analysis
----- Context ------------------------------------------------------------------
81:
82: (defn map-vals [f m] (if (nil? m) {} (reduce-kv (fn [m k v] (assoc m k (f v))) m m)))
83: (defn map-keys [f m] (if (nil? m) {} (reduce-kv (fn [m k v] (assoc m (f k) v)) {} m)))
84: (let [p! persistent!, t transient] ; Note `mapv`-like nil->{} semantics
85: (defn filter-vals [pred m] (if (nil? m) {} (p! (reduce-kv (fn [m k v] (if (pred v) m (dissoc! m k))) (t m) m)))))
^--- Could not resolve symbol: dissoc!
@wilkerlucio It should be added here: https://github.com/borkdude/sci/blob/043f5e60d674f5aeee0866e427cef58812ad5547/src/sci/impl/namespaces.cljc#L877
you pointed to dissoc
, the missing one is dissoc!
(with exclamation mark)
ah, ok, so a simple add there will fix it?
I can send a PR for that if you want
I'm excited to maybe see Pathom running inside Babashka, that will be awesome π
was just trying that spartan spec hack to get though spec (that was the blocker)
macros, I use the spec regex to parse custom macro syntax
Merged, and I pushed the new sci to bb master. Binary will appear in #babashka-circleci-builds soon
awesome! π
is there a proper way to make this portable with Babashka?
wilkerlucio@Wilkers-MacBook-Pro-2 babashka-experiments % ~/Local\ Files/bb
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: clojure.lang.Atom
Location: com/fulcrologic/guardrails/utils.cljc:88:31
Phase: analysis
----- Context ------------------------------------------------------------------
84: (let [p! persistent!, t transient] ; Note `mapv`-like nil->{} semantics
85: (defn filter-vals [pred m] (if (nil? m) {} (p! (reduce-kv (fn [m k v] (if (pred v) m (dissoc! m k))) (t m) m)))))
86:
87: #?(:clj
88: (defn atom? [x] (instance? clojure.lang.Atom x))
^--- Could not resolve symbol: clojure.lang.Atom
89: :cljs
90: (defn ^boolean atom? [x] (instance? Atom x)))
@wilkerlucio I think clojure.lang.IAtom
works
this seems to say true for everything:
wilkerlucio@Wilkers-MacBook-Pro-2 babashka-experiments % ~/Local\ Files/bb -e "(satisfies? clojure.lang.IAtom {})"
true
wilkerlucio@Wilkers-MacBook-Pro-2 babashka-experiments % ~/Local\ Files/bb -e "(instance? clojure.lang.IAtom {})"
true
wilkerlucio@Wilkers-MacBook-Pro-2 babashka-experiments % ~/Local\ Files/bb -e "(instance? clojure.lang.IAtom (atom {}))"
true
wilkerlucio@Wilkers-MacBook-Pro-2 babashka-experiments % ~/Local\ Files/bb -e "(satisfies? clojure.lang.IAtom (atom {}))"
true
For now you can use this workaround:
$ bb -e '(= "clojure.lang.Atom" (.getName (class (atom nil))))'
true
Note that you can use reader conditionals, :bb
should go before :clj
gotcha, thanks, about making (instance? clojure.lang.Atom x)
works, its out of scope for babashka?
I found interesting that the class type is correct, but I dont understand why the instance check doesn't work
(or why it can't find a class by name, but can by inspecting the atom)
@wilkerlucio This has to do with how sci works. You have to explicitly add classes by name in order for them to get resolved.
But IAtom
is basically a hack to make it work with defrecord
and defprotocol
and this is probably related to the instance?
bug, I'll check
I see. In bb/sci IAtom is implemented as a protocol and this protocol has a default dispatch and this is why satisfies? returns true for all object. This is the root cause of this bug.
no worries, just experimenting at this point, no impact π
The root cause is that IAtom is implemented using multimethods under the hood and we have a default, so basically everything returns true for this particular hack ;)
I am trying to implement this now without a default multimethod, but this doesn't work in CLJS :/
@wilkerlucio The bug should be fixed on master now
you are awesome man! π
This might be a little niche, but I just released a pod that can format T-SQL using the vendor library (on .NET): https://github.com/xledger/pod_tsql_scriptdom
@isak Are you aware that there is now also a native mssql pod? You can talk directly to mssql from a pod, from the pod registry
This one? https://github.com/xledger/pod_sql_server yea I use it for scripting
@isak no this one:
(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/mssql "0.0.1")
https://github.com/babashka/babashka-sql-pods/oh sweet, I'll give it a shot. Usually the problem is integrated security, but maybe they figured it out.
ah hm, not sure. @jvtrigueros is the guy who did the work on that, he might know
I guess it's not much different from connecting from a regular Clojure program via JDBC
For normal JDBC, it is a little tedious, because you need a special dll for that to work, and it doesn't seem to come packaged properly with the rest of the driver deps
I think it would be good to add a link to your pod in section with related sql pods. Feel free to PR with some details (I don't know enough about mssql)
Hmm, I'm getting this error:
Type: java.lang.IllegalArgumentException
Message: No executable found for pod org.babashka/mssql (0.0.2) and OS Windows Server 2016/x86_64
from this:
(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/mssql "0.0.2")
Ok just tested it. Unfortunately I get this error when adding :integratedSecurity true
to the db spec:
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: This driver is not configured for integrated authentication. ClientConnectionId:889ad681-4fdf-409c-b12c-9eef93129023