Fork me on GitHub

I can't access the code standards for libraries in Clojure. There's any other link about that?


what do you mean code standards @iagwanderson


something like the clojure style guide but for building libraries


there is a link inside the clojure style guide for that documentation but it's not working right now


503: This site is currently undergoing maintenance. We apologize for the inconvenience.

Alex Miller (Clojure team)03:05:03

If it’s the contrib style docs, that’s moved


(that's the broken link i mean)


I edited the page with their web UI and now there's a "proposed file change" somewhere ¯\(ツ)


yeah i did my ui change and came back to see you had done it as well 🙂 except you used the anchor tag as well


so its better


i just don't know how to rescind mine lol


thanks for the directions


I find myself traveling without internet access - are there any downloadable documentation resources? I’m thinking api doc, cheat sheet, etc. I’m learning 😅


Looks fantastic, I’ll give it a go 😀


Very cool functionality. I’m confused on as how to download the Clojure 10.0 docs, any specific help there? 😋


Better to go with Dash then,


also clojure.repl/doc clojure.repl/apropos clojure.repl/find-doc clojure.repl/source are all very useful - much of clojure and its library ecosystem are self-documenting in a repl

Jivago Alves09:05:57

Greetings, folks!

Jivago Alves09:05:34

Just curious about what’s the usual libs you use for mocking if any. I’m asking in the context of testing side-effects of code in an isolated manner (writing to DB or making http reqs). I found which seems what I was looking for (not sure if it’s in active dev). Any other recommendations? Thanks!

Jivago Alves09:05:47

Please feel free to reply here. It’s easier to concentrate the answers.


Not sure if you even need stubs. I simply reify what’s needed.

(defprotocol IDescriptive
  (-describe [this id]))

(defn describe
  [impl id]
  (-describe impl id))

  (reify IDescriptive
      [this id]
      {:user/id "foo"
       :user/email ""})))

Jivago Alves12:05:44

@UBUSQN7RQ Nice. I have used reify before for stubbing too but I’m interested in mocking in the sense I’d like to set expectations on fn calls and its args.


is there an easy way to interrogate a dependency library for its namespaces, from the REPL? I just realised I've been going and looking it up the long way


(System/getProperty "java.class.path") gives a string with all the currently available jars, a jar is a zip file that you can unpack and examine, many editors (arguably all ones worth using for code) can directly open a zip file and let you browse it like a directory


from there you can find all the .clj files etc. in the artifact


you can also use interop to get a stream of resource names that are in a jar; this isn't even complete because namespaces don't have to match up 1:1 with resources, but they should


I'm using lein if that matters


^ Unfortunately no. There is no reliable way to get namespaces from artefacts. Rich even joked about it in Spec-ulation, "Somebody on the street tells you, did you try this jar? I has fred in it" There may be some programmatically accessible API somewhere that gives you this information but ultimately a human has to put it in.


that's a shame but thanks for your help

Alex Miller (Clojure team)11:05:49

Rich and I have talked about this issue at length. I think it is one of the biggest gaps in the Maven repository story. At some point we may try to do something about it for Clojure but we have not found any easy answers.


So I'm trying to access a var in the namespace backend.core from a different namespace backend.routes.config but for some reason I get the error java.lang.RuntimeException: No such var: backend.core/config


presumably backend.core starts with a (ns backend.core ...) form. Are you requiring [backend.core :as backend.core] in backend.routes.config?


no, and I can't either. It would cause a cyclic dependency


maybe pull the config out into its own ns and have core and routes.config both depend on it?


I think I might have to intern the var instead


i'm not sure i follow


ok, so I'm reading in cli options in -main and I need to expose that config file to other parts of the system. A way I could do that is by interning the var to backend.routes.config from -main


(intern 'backend.routes.config 'global-cfg cli-cfg) like this


this doesn't seem like a good way to go


what should I do instead then


make a separate ns with that info and have whichever namespaces depend on it do so


ok, I'll try that


It worked, thanks!

Alex Miller (Clojure team)12:05:58

I think it’s confusing to have aliases with .’s in them


it looks like a fully qualified var at that point?

Kari Marttila12:05:08

I guess there is no way to add environment variables to aliases in deps.edn as you can do in Leiningen since I didn't find anything like that in the deps.edn documentation? Can you recommend some Clojure library that reads configuration from some file (edn, properties...) and I can ask certain property and the library first checks if the environment variable exists, and if yes returns the value, if not then tries to read the property from the file.

Kari Marttila12:05:46

Thanks. I read the README. How is maailma different from aero?


No idea, I’ve never used aero myself. It looks like almost every “bigger author” have their own environment variable lib. 😅

Kari Marttila13:05:11

Environ README says nothing about reading config from file and merging it with environment variables.


Yep, sorry I remembered wrong that environ could read EDN config files as well. My bad.


iirc, luminus uses cprop for this:

(ns my-project.config
  (:require [cprop.core :refer [load-config]]
            [cprop.source :as source]
            [mount.core :refer [args defstate]]))

(defstate env

Kari Marttila13:05:21

Thanks. Maybe I check cprop as well.


Stupid question. Using CLJS i'm trying to send a file to my server using transit. I'm getting the following error:

Uncaught Error: Cannot write File
Cannot write File
    at Object.writer.marshal (writer.js:447)
    at Object.writer.emitMap (writer.js:319)
    at Object.writer.marshal (writer.js:439)
    at Object.writer.marshalTop (writer.js:471)
    at Transit$Writer.writer.Writer.write (writer.js:501)
    at cognitect$transit$write (transit.cljs?rel=1557151648550:278)
    at ajax$transit$transit_write_fn_$_transit_write_params (transit.cljc?rel=1557151648575:17)
    at ajax$interceptors$apply_request_format (interceptors.cljc?rel=1557151648359:150)
    at Object.ajax$protocols$Interceptor$_process_request$arity$2 (interceptors.cljc?rel=1557151648359:161)
    at ajax$protocols$_process_request (protocols.cljc?rel=1557151648127:32)
I think its down to how the file object is being encoded but I cannot find much information around this


transit doesn't know how to encode the File object you are passing it

hiredman17:05:45 are the types transit-cljs knows how to encode out of the box


@hiredman: thank you. I did actually see that, essentially I'd need to figure out my own way of encoding/decoding this?


I would start by not trying to serialize a File


a file is sort of a pair of some data and some name for that data on some filesystem


the place when you send the data likely doesn't have the filesystem context there, so sending a file is kind of meh


so instead send a pair of a name and some data (maybe some kind of array, I don't really do much js or cljs so I don't know what the best type for a collection of binary data is)


Oh man, I had expected that this would be a pretty typical usecase. I'm surprised at how much is about to be involved


I don't think you'd serialize a file in the JS either though. Just send it off as binary.


I mean, I'm not suggesting serialization. Binary makes more sense. I think lots of objects wouldn't have serialization methods. I think I am more disappointed that it doesn't come out of the box with support for a really common usecase

gklijs17:05:14 has a websocket allowing text or binary, was real easy to set up, and get images from the front-end to the back end.

Kari Marttila18:05:47

I used mount ( and cprop ( to implement the application state and configuration handling in my new Clojure study project. I was amazed how incredibly easy and clean the implementation was. I can strongly recommend both libraries for beginners. I only now realized that both libraries are made by the same person. Thanks @tolitius!


just realized that mount and cprop have the same author. I use them, too. thanks 🙂


Hi, I have what should be a fairly simple macro question (man I really struggle to actually understand how to construct macros…). I have the following code:

(defmacro defx
  [id form]
  `(defmethod x ~id [_]
     (quote ~form)))

(defx "foo" (s/keys :req-un [::a ::b]))
;; Call to clojure.core/fn did not conform to spec (reason: "Extra input")
The macro is silly for now, but I’m going to extend it. I believe the error is due to the _ in the arglist, but I can’t seem to make it work. Can anyone see what I’m doing wrong here?


i think you might need _# for the arg in your macro


I believe that something like that is true for any parameters inside of a syntax-quoted expression -- if you do not do something like name# it will be qualified with the name of the current namespace, e.g. , and I don't think Clojure supports that for a parameter name.


name# is shorthand for gensym, and is almost always what you want (so you don’t shadow or redef any existing vars). however you can explicitly specify a symbol if you really want to (e.g. ~'_)


Yep, that did the trick! Thanks 🙂


can't you do '_ as well?


that gives you (defmethod x id [(quote _)] ...) which is an error


nested quotes are not idempotent, thus the quote/unquote combo


Generally you can always use macroexpand to see the expanded form, that usually gives a better clue of what the error is


user=> (macroexpand '(defx "foo" (s/keys :req-un [::a ::b])))

(. user/x clojure.core/addMethod "foo" (clojure.core/fn [user/_] (quote (s/keys :req-un [:user/a :user/b]))))


(defmacro defx
  [id form]
  `(defmethod x ~id [~'_]
     (quote ~form)))
~'_ will macro-expand to the raw _ symbol.


Oh, hah... @matt.kipps already edited his answer to mention that.


What I saw in Zulip:

**matt.kipps:** not necessarily. `name#` is shorthand for gensym, and is almost always what you want (so you don’t shadow or redef any existing vars). however you can explicitly specify a symbol if you really want to…

😁 4