This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-03
Channels
- # announcements (11)
- # atom-editor (8)
- # aws (16)
- # babashka (34)
- # beginners (59)
- # calva (32)
- # cider (8)
- # clj-kondo (43)
- # cljs-dev (52)
- # clojure (26)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-spec (16)
- # clojure-uk (44)
- # clojurescript (5)
- # core-async (21)
- # cursive (14)
- # datomic (53)
- # figwheel-main (4)
- # fulcro (5)
- # graphql (6)
- # java (3)
- # kaocha (5)
- # leiningen (6)
- # local-first-clojure (1)
- # malli (25)
- # off-topic (40)
- # other-languages (1)
- # pathom (5)
- # pedestal (3)
- # re-frame (4)
- # reitit (2)
- # reveal (8)
- # rum (21)
- # sci (16)
- # shadow-cljs (90)
- # spacemacs (8)
- # tools-deps (10)
- # vrac (6)
- # xtdb (12)
Is there any way to extend fipp’s IEdn protocol in babashka, to control pretty printing?
Currently fipp is used as a stand-in for clojure.pprint because clojure.pprint didn't work well with GraalVM at the time. I'm not sure if we expose fipp itself as well
What I naively tried was
(extend-protocol fipp.ednize/IEdn
java.util.regex.Pattern
(-edn [x]
(tagged-literal "regex" (pr-str x))))
I have an aero reader for a #regex
tag, but need to be able to round trip values.user=> (defmethod print-method java.util.regex.Pattern [v ^java.io.Writer w] (.write w (pr-str (tagged-literal 'regex (.pattern v)))))
#object[clojure.lang.MultiFn 0x6aef4eb8 "clojure.lang.MultiFn@6aef4eb8"]
user=> (clojure.pprint/pprint #"foo")
#regex "foo"
You can also postwalk your data first and turn it into a tagged literal maybe, since overriding print-method for core types might not be a good idea. But it might be OK for scripts
postwalk is certainly a viable workaround. ednize isn’t working as it refers to ThreadLocal.
This could be useful for preserving the old behavior in all other cases:
(def ^:dynamic *print-config* nil)
(def old-method (get-method print-method java.util.regex.Pattern))
(defmethod print-method java.util.regex.Pattern [v ^java.io.Writer w]
(if *print-config*
(.write w (pr-str (tagged-literal 'regex (.pattern v))))
(old-method v w)))
(prn #"foo")
(binding [*print-config* true]
(prn #"foo"))
hey @borkdude. Babashaka rocks! Thanks!
might be a trap, but it feels like with a shockingly small amount of work this could be a monster alternative to Ansible. I tried it today but I don't know enough about executing remote ssh commands effectively, but I'm absolutely gonna check it out
although I suppose if I start going down that rabbithole I should probably just use clojure hmmm
but it's sooo tempting
@goomba i don't know what ansible does in detail, but perhaps there is some effort that addresses some of the functionality here? https://github.com/lread/clj-graal-docs/blob/master/doc/external-resources.md may be https://github.com/epiccastle/spire ?
awesommmmeee resources!
wooo okay spire was probably what I was looking for. I was using babashka today to provision about a dozen machines
The tempting part from an enterprise perspective is I can sneak babashka even onto a pretty locked down redhat where they might not be crazy about JVM (for whatever reason)
Enterprise is so weird