This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-05
Channels
- # beginners (53)
- # boot (6)
- # braveandtrue (12)
- # cider (50)
- # cljs-dev (24)
- # clojure (60)
- # clojure-finland (1)
- # clojure-ireland (1)
- # clojure-italy (50)
- # clojure-kc (1)
- # clojure-nl (20)
- # clojure-norway (1)
- # clojure-portugal (1)
- # clojure-russia (2)
- # clojure-sanfrancisco (1)
- # clojure-sweden (1)
- # clojure-uk (176)
- # clojurescript (58)
- # cursive (14)
- # datomic (23)
- # emacs (4)
- # events (16)
- # fulcro (35)
- # graphql (48)
- # hyperfiddle (9)
- # jobs (5)
- # mount (4)
- # onyx (13)
- # overtone (1)
- # play-clj (2)
- # re-frame (91)
- # reagent (9)
- # reitit (9)
- # shadow-cljs (102)
- # sql (3)
- # testing (3)
- # tools-deps (3)
I’m trying to setup expound when running a REPL with CIDER. Even when I do the recommended (alter-var-root #'s/*explain-out* (constantly expound/printer))
, *cider-error*
gives me the original spec error. In the actual repl output, I see the exception as formatted by pretty
, but still no expound formatting. Any pointers?
Does using set! work? I think the Clojure REPL sets up an outer binding for s/explain-out
I’ll warn you that expound errors sometimes print weirdly in CIDER due to incompatibilities with new lines. I’ve opened a Github issue in CIDER.
FWIW, when using expound for instrumentation, consider using ‘custom-printer’ with “print-specs?” set to false and “show-valid-values?” set to true. The output is little more helpful with those settings.
Thanks — I’ll also ask in #cider — I think I might need to do something more specific there.
OK, FWIW, I use expound with CIDER by doing “lein repl” in terminal then “cider-connect” and using “set!” it works for me. But I haven’t tried letting CIDER set up the REPL via “cider-jack-in”
Hm, I’m AFK so I can’t try ‘cider-jack-in’ here but I can try later. Maybe try with a normal “lein repl” outside of emacs?
I wouldn’t expect “pretty” to interfere - I’ve used it in projects with expound - but I’ve been wrong before
I created a new project with lein new
and then used cider-jack-in
. The following worked for me with that REPL:
(require '[expound.alpha :as expound]
'[clojure.spec.alpha :as s]
'[clojure.spec.test.alpha :as st])
(set! s/*explain-out* expound/printer)
(st/instrument)
(defn) ; gives expound error
(of course, my project.clj needed to be changed to use:
[[org.clojure/clojure "1.9.0"]
[expound "0.7.1"]]
I tried using [io.aviso/pretty "0.1.34"]
as well, it still seems to work for me. So I’m unfortunately not sure what’s different. Good luck and let me know if you figure it out 😄 !
Sure, that’s fine, although I’m not sure expound can do much here, unless I’m misunderstanding your use case. Perhaps I just need to clarify how to do this in the docs?
The README suggests using set!
(except in specific cases like a non-REPL environment) but I’m happy to clarify if the instructions were confusing
I’m sure I misunderstand something 😄 I thought alter-var-root
should be more generic than set!
?
Do try a custom-printer with the options I mentioned above and let me know if you have any trouble. I think it makes the output much more readable for instrumentation
I did some experiments with the REPL. Keep in mind that at the REPL, all code is run within a top-level binding
call that sets up default values for s/*explain-out*
: https://github.com/clojure/clojure/blob/2a08ef40018f1b504602545603eec840b05b33b1/src/clj/clojure/main.clj#L85
In this context, you can call alter-var-root
, but the value set up by binding
always takes precedence. Here’s an example with another dynamic var https://gist.github.com/bhb/d82fcf0f80f555c28afa8db320be16c8
Wow, thanks for that — it seems that’s the problem. I’ll do another experiment on Monday to see what actually happens when code running inside a threadpool (e.g. Jetty handlers) encounters a spec error.
Is there a canonical way to edit an xml tree in multiple locations using zippers? I am trying to edit the content of multiple nodes and end up with multiple trees each containing one edit.
Can I merge these into XML tree?
@andreasklein are you chaining your transformations with ->
?
or ->>
, can’t remember
I am using data.zip.xml/xml->
sorry, I’ve only used vanilla zippers 🙂
how I can check if catched exception is ex-info
?
I have one catched already I just need to interpret in different
I think if it is not ex-info ex-data just returns nil
would this work?
k, thanks for help!
clear 🙂
Is it possible to use Reitit with Pedestal? There are mentions of interceptors in Reitit, but I’m not sure if they are meant to be used by Pedestal or if there is just a similar concept?
@orestis Reitit supports both mw & interceptors, but the interceptor-http module is not public yet. Goal is to publish it out after vacations, we could cook up a Pedestal example, as people have been asking for it. There is #reitit too.
I'm feeling a bit stupid, can't figure out how to elegantly traverse vector of maps and make a new map with keys being values of a selected property of each map and number of records... e.g. if I have:
[{:type "foo"}, {:type "bar"}, {:type "foo"}, {:type "foo"}]
I should get something like:
{"foo" 3 "bar" 1}