Fork me on GitHub

Scratch that "both ways" thing for my Linux results -- no user.clj only took about 15 seconds. (I forgot to remove user.clj the first time I tried requiring from clojure command line)


Interesting, so perhaps this is a bug in later linux JDK releases?


Perhaps. I don't have much of a clue what is going on there.

Alex Miller (Clojure team)01:02:51

They’ve been adding guards in the recent Linux builds


Just like 'foo can be written in EDN like (quote foo), can ` and ~ be represented in EDN?


~ seems to be clojure.core/unquote. Can't find a clojure.core/syntax-quote though.

Alex Miller (Clojure team)06:02:54

they are instructions to the Clojure reader itself (which the edn reader does not understand)

👍 5
Alex Miller (Clojure team)06:02:13

unquote (and unquote-splicing) are just unbound symbols defined in clojure.core

Alex Miller (Clojure team)06:02:02

user=> ``(foo ~a)
(clojure.core/seq (clojure.core/concat (clojure.core/list (quote user/foo)) (clojure.core/list user/a)))

👍 5
Ian Fernandez13:02:03

(defn camelCase-map [item]
    (fn [m k v]
      (assoc m (csk/->camelCase k)
             v)) {} item))
I have this to convert keys from a map to camelCase

Ian Fernandez13:02:21

But sometimes I have values that are lists of maps too

Ian Fernandez13:02:46

how can I apply this to nested maps?

Ian Fernandez13:02:10

{:a-b 1 :a-c ({:a_d 3 :a_b 4} {:d_a 1 :c-a 3})}

Ian Fernandez13:02:50

giving me:

{:aB 1 :aC ({:aD 3 :aB 4} {:dA 1 :cA 3})}


@d.ian.b You might take a look at clojure.walk

Ian Fernandez13:02:21

what about specter?

Ian Fernandez13:02:14

i'm using this one but I need for nested maps

Ian Fernandez13:02:25

to convert keyword in nested maps


Snippet from our codebase:

(defn transform-keys
  "Given a map m and a function a-fn1, will apply that function to all
  keys in the map, recursively (unless non-recursive? is true). Returns
  modified map."
  ([a-fn1 m]
   (transform-keys a-fn1 m true))
  ([a-fn1 m non-recursive?]
   (let [rf (fn [tm [k v]] (assoc! tm (a-fn1 k) v))]
     ;; only apply to maps
     (if non-recursive?
       (treduce rf {} m)
       (postwalk (fn [x] (if (map? x) (treduce rf {} x) x)) m)))))

(defn snake_casify
   (snake_casify m false))
  ([m non-recursive?]
   (let [kf (fn [k]
              (if (namespace k)
                (keyword (->snake_case (namespace k))
                         (->snake_case (name k)))
                (->snake_case_keyword k)))]
     (transform-keys kf m non-recursive?))))


but Specter may work too 😉


this is basically postwalk from clojure.walk doing the work

Ian Terrell16:02:38

Can anyone offer a pointer on how to create a command line REPL for a Clojurescript project that can access installed node_modules? All in the same directory I have a src folder, a deps.edn that includes src in :paths, package.json and node_modules with installed modules. I can boot a REPL with clj -m cljs.main -re node, and it can find my code. But it can't find the installed Node modules.

ClojureScript 1.10.439
cljs.user=> (require '[db.etl.staging])
    throw err;

Error: Cannot find module 'aws-sdk'
    at Function.Module._resolveFilename (module.
Any pointers?


Any idea how to update/manipulate primitive with meta, without losing its meta. Eg. => (def a (with-meta [1 2 3] {:my "meta"})) => (def b (remove #{3} a)) => ;; now b losing its meta.

Lennart Buit17:02:34

that makes sense right, because you are producing a new value


so you'll need some way of copying the meta to the new value

Lennart Buit17:02:10

haha, teamwork 😛


So, how do I copy the meta?


(def b (with-meta (remove #{3} a) (meta a)))

👍 5
Lennart Buit17:02:24

well, you can use meta to get the metadata, so if you would change your b def to ^

Lennart Buit17:02:31

drone beat me to it

👍 5

not sure what you’re trying to do though, may not be best use of metadata


thanks guys!, I am just tooling around


@ian451 I’ve heard good things about shadow-cljs, though haven’t had a chance to use it yet.


It was created, so I understand, to make npm interaction as simple as possible (among other things, I’m sure)


I’m not sure how to do it with just a deps file; maybe the clojure script channel knows?


Hellow Clojurians, is there a way to represent namespaced keyword ? Like :module-a/list/current-display


namespaced keywords are a native concept to clojure. however they don't allow multiple slashes


Wouldn't it be :module-a.list/current-display?


nested namespaces should be represented by a period, right?


that's techically multi segmented and not meaningfully nested, but yes


Yes. So for the above, you'd have (ns module-a.list ...) which would be src/module_a/list.clj and :module-a.list/current-display would match that namespace.

👌 5

Oh ok thank you


But namespaced keywords don't need an actual code namespace behind them, so would be just fine.

Lennart Buit20:02:47

(if there is a ns backing them, you can require/as them tho)

Lennart Buit20:02:50

(mighty useful)


Aye... And calling ::current-display will expand into, as a shorthand


and commonly {:user/name "bob" :organization/name "clojurians"} etc.


You don't "import" keywords tho', but (require [module-a.list :as mlist]) and then ::mlist/current-display saves typing 🙂

Lennart Buit20:02:06

right, I ninja’edited my message 😛

simple_smile 5
Lennart Buit20:02:57

typing before thinking sometimes gets the better of me


Aye, @seancorfield's example explains @lennart.buit's reference to :as


Also, you can create aliases for namespaces that have no code: (alias 'mstuff (create-ns 'module-a.mstuff)) as I recall.


From our codebase

(alias 'm  (create-ns 'ws.domain.member))
(alias 'mu (create-ns 'ws.domain.member.update))
(alias 'mv (create-ns 'ws.domain.member.validation))
so we can do ::m/email, for example.

Lennart Buit20:02:54

oh thats pretty cool!


(now, it just happens that we actually do have code namespaces that match those, but this allows us to refer to keywords in them without actually requiring the namespaces -- because in some parts of our code we don't need to load that stuff, just use the keywords)

Lennart Buit20:02:53

Where do you have these aliases defined then, if I may ask


@lennart.buit Those aliases are in any file where we need only the keywords, not the code behind them.

Lennart Buit21:02:47

right, thanks!


that could lead to weird results if you have tooling that uses eg. all-ns in an automated way


hypothetically - I don't know of anything it actually breaks


@noisesmith that's some good out-of-the-box, systems thinking there. nice.


Though it feels like all-ns shouldn't be tied too much to app logic. Feels like a repl tool.


right - or a refactor tool


ns's aren't immutable things in clojure, after all... yea, testing maybe too


it wouldn't be out of the question to do something like (->> (all-ns) (filter contains-multimethod-impl?) (run! load-for-multi)) as a DI approach to multimethod extension


for repling


right - that would be a repl thing


Is this a good channel for questions/issues with Leiningen?


If you can't get an answer in #leiningen, probably @tramsey


Thanks @john #leiningen was what I was looking for

👍 5

how can I clean all built dependencies for a deps.edn clj project?


getting weird dependencies errors


deps.edn doesn't build dependencies


I guess my question is, how can I get a clean state of dependencies loaded via classpath (using cursive)

Alex Miller (Clojure team)22:02:59

there are several caches - /m2/repository caches jar files, /.cpcache caches classpaths, ~/.gitlibs caches git deps


@pvillegas12 removing the .cpcache folder in your project should be sufficient -- we've found that changes to transitive dependencies via :local/root don't seem to be detected so we've had to delete .cpache in each sub-project as part of our build pipeline.

👍 5
Alex Miller (Clojure team)22:02:28

that is definitely a known issue