Fork me on GitHub
Ben Sless08:05:12

What's the reason loop forms inside let bindings get compiled to a function + instantiation + call? Can't they be inlined?


wouldn't that mean reimplmenting binding, destructuring, etc.? as it is currently recur inside a function acts identically to a loop with the same binding list, in order to preserve that you'd need two different implementations agreeing on that behavior


With, can the be set via a Java system property (e.g.,, per It doesn’t look like it from some noodling, but perhaps I’m doing it wrong.


it asks for a function should return a logger factory when called with no args, you are providing the logger factory itself


try replacing with (constantly


that's a very weird API in a very java way, asking for a thunk that returns a factory


I figured this out from your error: it tried to call the factory (created via reify which means the message printed is a bit obfuscated) as if it were a function. the docs you linked to specify that it wants a function as well.


cheers. I was thrown by the name: the example in the docs uses, which indeed is a function with no args that returns a logger. As you rightly point out, disabled-logger-factory is not.


I’m getting a dependency error. Could not resolve namespace for "user/my-logger-factory". Either it does not exist or it has a (circular) dependency on I appreciate the help. I’m just placing this here in case someone else tries something naïve like this and assumes that what I did worked.


does it change if you add an ns declaration to the file? seems like this lib is doing some black magic with namespaces


also I see that you are still misconfiguring the logger in the quiet-log function by providing a factory instead of a function returning a factory


I think the binding in quiet-log is correct: (a) it’s working, and (b) *logger-factory* is an instance satisfying not a function.


I did get this working by adding a namespace.


Yeah, doesn’t seem to work if the factory is in the same namespace:

Ben Sless16:05:10

Today I realized eductions can be used to serialize directly to json

(defn iterduction
  [xf coll]
  (.iterator ^Iterable (->Eduction xf coll)))
Jackson ObjectMapper can take an iterator


I'm finally getting started using deps and I have a question: when invoking clj to start a REPL, is there a hook or configuration to invoke an arbitrary function as part of setup. In my case, I'd like to have a :pretty alias that adds Pretty to the classpath, and invokes io.aviso.repl/install-pretty-exceptions before the REPL starts accepting user input.


{:aliases {:pretty {:extra-deps {io.aviso/pretty {:mvn/version "1.1"}} :exec-fn clojure.main/repl :exec-args {:init io.aviso.repl/install-pretty-exceptions}}}


... is close, but fails (because clojure.main/repl is a varargs function). Also, what if I want multiple init functions? Is there an alternate repl starter for deps that supports this?


@U04VDKC4G -X only accepts functions that has a map argument (or in clojure 1.11 a keys-destructured args list)

Alex Miller (Clojure team)21:05:37

in the last part of that, you don't need the commas anymore, you can just use normal spaces


@U04VDKC4G This seems to do the trick as well:

 {:pretty {:main-opts ["-e" "((requiring-resolve 'io.aviso.repl/install-pretty-exceptions))"
                       "-e" "(clojure.main/repl)"]
           :extra-deps {io.aviso/pretty {:mvn/version "1.1"}}}}}

👍 3

clojure -M:pretty


This is cool ... to a point. For example, I like to have my pretty exceptions enabled when running tests but the above is only for starting a REPL; I'm either have to create my own test runner, or use one that makes use of Pretty as well.


Just feels like there's room for an idea of "Scafollding" the environment prior to the main execution (of a REPL, of a test runner, of an arbitrary function). But that brings in questions about ordering and such ...


I guess the user namespace is a spot where you can apply this kind of init code?

Adam Kalisz21:05:58

@hiredman @ptaoussanis I have closed the issue and submitted a PR (linked in the issue comment): this seems to enable a workaround for us.


Are there any illustrating examples of transit/write-handler that use a function for the tag and rep and some of the other options? Typically I see (write-handler "foo" (fn [o] ...)) which makes me wonder what other stuff you can do with it. The documentation is pretty terse in my opinion. In which cases do you need the tag arg to be a function?


I did read that, but it also doesn't show an example of "more advanced" usage


I guess the fn lets you decide the tag based on something other than the type because you can inspect the value before it's written


But I never saw an example of that so far


Perhaps this comes in useful in the :default-handler


which btw is not documented at all (or I didn't look hard enough)

Alex Miller (Clojure team)22:05:36

I don't have time to dig in or say more useful things right now, but I may have some time end of week to look at it


appreciate the help, thanks


it's a bit unfortunate that the API requires to repeat logic like (.isArray ...) twice, one for the tag and once for the value which I can imagine isn't so good for performance, but ah well


Is there something similar to Postman (or can Postman somehow be used) for testing requests to a Clojure web service that accepts/expects transit? For example, say my frontend and backend both use edn, but send transit+json over the wire. I'd like a tool that will: 1. Allow me to input edn and it will format and highlight it, as Postman does with json 2. Convert the edn to transit+json before sending the request 3. Read transit+json from the response and convert it to edn, and also prettify it as in step 1 I know I can write up some code to do this in a repl, and maybe that's even better (I've already done a bit of this), but I'm just wondering if some tooling around this exists.


@brandon.ringe This is pretty easy to do with babashka (can do http client + server, has transit, edn and json). There is also a puget CLI for colorization


You could even write a small web app which does this for you, to make a nice UI (not sure about the colorization in that case, I'm sure there is some JS plugin which can do basic highlighting)


Oh, interesting. Thanks.


@brandon.ringe There is also jet which can do EDN -> Transit and vice versa on the command line for you as well.

👍 3