This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-08
Channels
- # announcements (12)
- # aws (4)
- # beginners (92)
- # calva (2)
- # cider (28)
- # clara (11)
- # clj-kondo (5)
- # cljdoc (9)
- # cljs-dev (195)
- # cljsjs (1)
- # clojure (82)
- # clojure-italy (18)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-spec (10)
- # clojure-uk (51)
- # clojurescript (40)
- # cursive (7)
- # datomic (19)
- # duct (9)
- # emacs (2)
- # figwheel (3)
- # fulcro (56)
- # graphql (8)
- # jobs (3)
- # luminus (2)
- # off-topic (15)
- # re-frame (5)
- # reitit (3)
- # ring (5)
- # shadow-cljs (22)
- # slack-help (2)
- # sql (51)
- # test-check (9)
- # vim (64)
- # yada (1)
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
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.
What link?
If it’s the contrib style docs, that’s moved
https://clojure.org/community/contrib_howto - under Coding Guidelines
I edited the page with their web UI and now there's a "proposed file change" somewhere ¯\(ツ)/¯
my pr is at https://github.com/bbatsov/clojure-style-guide/pull/174
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
I find myself traveling without internet access - are there any downloadable documentation resources? I’m thinking api doc, cheat sheet, etc. I’m learning 😅
Would that work https://github.com/cljdoc/cljdoc/blob/master/doc/userguide/for-users.md#offline-docs ?
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, https://kapeli.com/dash
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
Greetings, folks!
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 https://github.com/bguthrie/shrubbery which seems what I was looking for (not sure if it’s in active dev). Any other recommendations? Thanks!
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))
(describe
(reify IDescriptive
(-describe
[this id]
{:user/id "foo"
:user/email ""})))
@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
^ 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.
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?
maybe pull the config out into its own ns and have core and routes.config both depend on it?
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
I think it’s confusing to have aliases with .’s in them
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.
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. 😅
Yep. 🙂
https://github.com/weavejester/environ is a popular alternative
Environ README says nothing about reading config from file and merging it with environment variables.
How about aero? https://github.com/juxt/aero
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
:start
(load-config
:merge
[(args)
(source/from-system-props)
(source/from-env)]))
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 thishttps://github.com/cognitect/transit-cljs#default-type-mapping 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?
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)
http://blog.cognitect.com/blog/2015/9/10/extending-transit might be useful to you
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
Thanks @hiredman and @alexmiller
https://github.com/nginx-clojure/nginx-clojure has a websocket allowing text or binary, was real easy to set up, and get images from the front-end to the back end.
I used mount (https://github.com/tolitius/mount) and cprop (https://github.com/tolitius/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 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. ~'_
)
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…
🙂