Fork me on GitHub
Calle Kabo00:09:38

ok, so if I got this right - comp given only transducers returns a transducer - comp given only functions does function composition - comp given a mixture of transducers and regular functions doesn't work

Calle Kabo00:09:37

Now I don't understand why the code above with ->> works... I just saw it as doing the same as comp but in reverse.

Calle Kabo00:09:12

because ->> is a macro, does it take the forms given to it and actually "physically" put the output of the previous line as the last argument in the next form?

Calle Kabo00:09:24

sort of runs partial on all the forms?


Comp composes functions full stop


Transducers are functions that take and return reducing functions


->> is purely syntactic rewriting. There's no semantics involved. (->> (+ a b) (let [a 1 b 2])) => (let [a 1 b 2] (+ a b))

Calle Kabo00:09:56

I need to remember that (= ((comp (partial map inc)) [1 2]) (->> [1 2] (map inc)))


comp with a single argument is identity


((partial f a) b) => (f a b) by definition


And as hiredman said @calle ((comp f g h) x) is (f (g (h x)))

Calle Kabo01:09:54

I think it's this non-currying that's tripping me up

Calle Kabo01:09:31

I'm so used to ((f a) b) being the same as (f a b)

Calle Kabo01:09:11

that's basically the only way I use map


just want to shout out #practicalli. truly an amazing resource for getting up and running with ring + compojure

Calle Kabo01:09:41

I think I'm going to use ->> a lot...

Calle Kabo01:09:47

What I'm saying is that when I see (map my-fn) in a comp and in a ->> I need to remember that they mean completely different things.

Calle Kabo01:09:28

->> is not comp but reversed.

Calle Kabo01:09:46

thanks for clearing things up, see you later 🙂


I wanted to change the path that aot dumps to ... seems like it doesn't like the following -- any suggestions?

{:aliases {:aot {:extra-paths ["target/classes"]
                 :main-opts ["-e" "(set! *compile-path* \"target/classes\") (compile,')"]}}}


@johnjelinek Did you make sure target/classes exists before you run that?


ya, it throws an exception


 "Execution error at clojure.main/main (\nEOF while reading, starting at line 1\n",
 {:clojure.error/class java.lang.RuntimeException,
  :clojure.error/line 40,
  :clojure.error/cause "EOF while reading, starting at line 1",
  :clojure.error/symbol clojure.main/main,
  :clojure.error/source "",
  :clojure.error/phase :execution},
  [{:type clojure.lang.LispReader$ReaderException,
    "java.lang.RuntimeException: EOF while reading, starting at line 1",
    :data {:clojure.error/line 1, :clojure.error/column 1},
    :at [clojure.lang.LispReader read "" 314]}
   {:type java.lang.RuntimeException,
    :message "EOF while reading, starting at line 1",
    :at [clojure.lang.Util runtimeException "" 221]}],
  [[clojure.lang.Util runtimeException "" 221]
   [clojure.lang.LispReader readDelimitedList "" 1405]
   [clojure.lang.LispReader$ListReader invoke "" 1243]
   [clojure.lang.LispReader read "" 285]
   [clojure.lang.LispReader read "" 216]
   [clojure.lang.LispReader read "" 210]
   [clojure.core$read invokeStatic "core.clj" 3766]
   [clojure.core$read invokeStatic "core.clj" 3741]
   [clojure.main$eval_opt$fn__9100 invoke "main.clj" 487]
   [clojure.main$eval_opt invokeStatic "main.clj" 487]
   [clojure.main$eval_opt invoke "main.clj" 482]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$script_opt invokeStatic "main.clj" 533]
   [clojure.main$script_opt invoke "main.clj" 530]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "" 137]
   [clojure.lang.Var applyTo "" 705]
   [clojure.main main "" 40]],
  :cause "EOF while reading, starting at line 1"}}


What exception?


I think it doesn't like my \ in there


You probably need , instead of space in that string


"(set!,*compile-path*,\"target/classes\") (compile,')"


Does that work?


needs , between forms


but then that works, except -- the clojure.core stuff doesn't get into the directory


Ah yes. That too.


not sure why the clojure.core stuff is missing

Alex Miller (Clojure team)01:09:36

it's already been compiled


nvm ... ran -A:aot again and it got it into the directory now


AOT is evil 🙂


(we do not use AOT at work ever)

😆 8

unfortunately, I need it for my stuff


Sorry man. We rely on one library that has a single namespace AOT'd. Other than that, we avoid it at all costs.


I don't know how to transpose the following without aot:

package com.myorg;


public class HelloStack extends Stack {
    public HelloStack(final Construct parent, final String id) {
        this(parent, id, null);

    public HelloStack(final Construct parent, final String id, final StackProps props) {
        super(parent, id, props);

        Queue queue = new Queue(this, "MyFirstQueue", QueueProps.builder()


Concrete inheritance? Ugh 😞


To be fair, I haven't yet figured out how to transpose this in general, but I feel like my options are either proxy, reify, or gen-class

David Pham07:09:13

Why is AOT evil?


Others with more experience can give more full answers, but I believe the gist of it is that even experienced Clojure developers can have a difficult time diagnosing subtle problems that can occur in some situations when AOT is used.


e.g. .class files that were compiled from different versions of Clojure source code being used, leading to code execution behavior from source code that is not what you are looking at in your editor.


I am having the most frustrating experience with ring ... I have a compojure POST route, that just pprints the request from a client I wrote. My handler is

(def app  (-> routes  wrap-json-body wrap-reload))
But wrap-json-body leads to the body always being nil. Without it its a HttpInputOverHTTP. I don't know what to do about it, it seems like noone had this problem with wrap-json-body, at least I can't find it. Content-type is application/json.


how would i go about writing a macro that can be called like this:

  [+ 1 1]
  [str "hello " 123]
  [inc 5])
and return the following structure:
['(+ 1 1)
 '(str "hello " 123)
 '(inc 5)]
(take vecs that would be valid forms if they were lists, and return quoted, unevaluated "eval-able" lists) (i know i can use [+ 1 1] directly using (apply (first [+ 1 1]) (rest [+ 1 1]), which is what i'm currently doing, but this stores the functions as function-objects, which isn't directly a problem, but it makes debugging these structures extremely hard, especially when everything gets wrapped with spec instrumentation stuff and is as such turned into some unreadable spec function-object thing)


Now I have slurped my input-stream manually and it yields "{\"date-range\":{\"from\":\"2019-09-10\",\"to\":\"2019-09-19\"}}" which at least according to is valid JSON. Still when I don't slurp it (so it is not gone) and use wrap-json-body it is nil. Also wrap-json-request works fine. Can anyone help me understand this?


it works, i just needed to remove that little ' in the last line to remove double-non-evaluation ;D thanks, person who removed his/her message ^^


@lkowarschick Why not just use a function?

(defn to-lists [& forms]
  (map (partial apply list) forms))


I removed it because I believe this is the easier solution 😉


that doesn't fully fulfill my requirements, as it results in the following:

(([clojure.core$_PLUS_ 294690511 "clojure.core$_PLUS_@11909ecf"] 1 1)
 ([clojure.core$str 439674431 "clojure.core$str@1a34e63f"]
  "hello "
 ([clojure.core$inc 1883794397 "clojure.core$inc@70486bdd"] 5))
(it stores function-objects instead of symbols)


the first solution works however ;D


I see, ok 🙂


(defmacro foo [& forms]
  (let [lists# (for [form# forms]
                 (list 'quote (apply list form#)))]
gonna use this ;D




I don't think the generation of special names is necessary here though as the code doesn't make its way in the macro at all


better be safe than sorry i guess ;D


i've got a function that can take any type of collection (it handles maps seperately, so were talking sets, lazySeq, list, vector, etc) it does stuff to that collection and should then return the modified version as the same type as it got it. how can i achieve this? map and such turn everything into a lazySeq, so i need to somehow (into (type input) output) my result.. (<- i know that doesn't work)


I recommend Specter for this, it is specifically designed to address this issue (changing the type of the container)


really? do i actually need a additional dependency for that? then i'd rather just (cond) it on the type..


you don’t need it, it’s just an option that’s available 🙂


so is my simplest option to write this function

(defn map-keep-type [fun coll]
  (let [mapped (map fun coll)]
    (condp #(%1 %2) coll
      vector? (vec mapped)
      set? (set mapped)
      list? (apply list mapped)
      map? (zipmap (map first mapped) (map second mapped))
      seq? (seq mapped)


something like that, except it doesn’t cover sorted-set, sorted-map etc


thats why i hoped there would be some kind of into that takes types and not empty collections...


nothing like that in clojure core afaik

Jack Westmore15:09:42

Hey there, would anybody be willing to help meet out setting out Emacs with Cider? Completely new to this thing and encountering a bug...


I can help you out. What’s up

Jack Westmore15:09:05

I'm using cider version 2019090

Jack Westmore15:09:04

When I try and do cider-jack-in, I get this error:

Could not find artifact cider:cider-nrepl:jar:0.22.1 in clojars ()
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable

Jack Westmore15:09:38

Pretty sure the issue is that nrepl version 0.22.1 does not exist on Clojars

Jack Westmore15:09:48

Latest stable version is 0.22.0, from what I can see on the web page


ah understood. There was a bug in the 22.0 release and the intention was to release on clojars. But it looks like that hasn't happened yet. CIDER injects its dependencies based on its version.

Jack Westmore15:09:56

I tried changing cider-required-middleware-version in cider.el to 0.22.0 (according to the Cider docs, "any nearby version will work"...). But after making this changing, restarting emacs, and running cider-jack-in, I still get the error message about 0.22.1


this is set in a var cider-required-middleware-version.


how did you change that var?

Jack Westmore15:09:19

I edited the file

Jack Westmore15:09:32

I just changed the argument to defconst from 0.22.1 to 0.22.0


did you restart emacs?


and that didn't work?




so one easy thing you can do. Normally you jack in with C-c M-j


if you use a prefix C-u C-c M-j you can directly edit the jack in command and rewrite the version of the cider-nrepl version that's injected

Jack Westmore15:09:13

Ah, OK. How exactly do I rewrite the command?

Jack Westmore15:09:17

(Sorry, I'm completely new to this...)

Jack Westmore15:09:53

OK, I can see how to do this


if you try it you'll see. The prefix arg will put the jack in command in the minibuffer and you can just edit it directly

Jack Westmore15:09:10

It's working now, with a warning


what kind of project is this? lein or clj?


you can probably ignore the warning. its just saying a mismatch but that's what we are intending to do right now

Jack Westmore15:09:44

Odd that changing the argument to defconst in cider.el didn't fix this, right? I just assumed that I didn't know enough about emacs/clojure and was missing something else...


i'm confused why editing cider-required-middleware-version didn't work


correct. i'm gonna look into that but this should get you working until the newer artifact is released

Jack Westmore15:09:48

thank you, this is really helpful

Jack Westmore15:09:21

FYI I just checked cider.el after editing and restarting -- argument to defconst is still 0.20.0 (it didn't revert to anything else). So not sure where it's reading 0.20.1 from


i think you're safest bet is 0.21.1 while we wait on the 0.22.1


there's a clojurescript completion bug in 0.22.0 that's fixed by the .1 point fix but its not out yet

👍 4
Jack Westmore15:09:47

sorry, typo: I'm using 0.22.0, not 0.20.0


that should be fine too but if you're doing cljs probably better for 0.21.1


but to summarize the strange behavior: You edited cider.el in your elpa directory to make cider-required-middleware-version have the value "0.22.0". You restarted emacs but this version was still "0.22.1". Is this correct?

Jack Westmore15:09:32

No, not quite; I edited the version number to "0.22.0", restarted emacs, the version number is still listed in cider.el as "0.22.0", but I still see the bug described above

Jack Westmore15:09:06

The error message still complains about not being able to find cider-nrepl version 0.22.1


hmm. I edited cider.el to "0.14.0", restarted and it was correctly seen. can you walk me through how you changed things?


couple things i can think: 1) are you sure you edited the correct cider.el file? It should be ~/.emacs.d/elpa/[cider-version]/cider.el 2) Are you sure you actually restarted emacs. There's a server that can keep running and its important that you actually kill emacs rather than just kill the client connected to an emacs server

Jack Westmore18:09:39

Hey -- sorry for the delay, was away from my machine for a couple of hours

Jack Westmore18:09:58

Here's some terminal output in response to your questions:

Jacks-MBP:.emacs.d jackie$ rg "0\.22\.1"
Jacks-MBP:.emacs.d jackie$ rg "0\.22\.0"
56:  :package-version '(cider . "0.22.0"))

14:;; Version: 0.22.0
90:(defconst cider-version "0.22.0"
407:(defconst cider-required-middleware-version "0.22.0"
1189:  :version '(cider . "0.22.0"))

150:  :package-version '(cider . "0.22.0"))

Jack Westmore18:09:22

i.e. no reference anywhere in .emacs.d/ to the incorrect version number (`0.22.1`)

Jack Westmore18:09:06

running cider-jack-in still produces the error above i.e. unable to find an artifact for cider-nrepl version 0.22.1

Jack Westmore18:09:28

What is even more curious, is that if I then run cider-jack-in as you described (using the C-u optional argument), and set the version number to 0.21.1, I get a REPL with this warning message:

WARNING: CIDER 0.22.0 requires cider-nrepl 0.22.1, but you're currently using cider-nrepl 0.22.0. The version mismatch might break some functionality!
i.e. it reports that I am using cider-nrepl version 0.22.0, as defined in my cider.el, and not 0.21.1, which I passed in to the command "by hand"

Jack Westmore18:09:30

Very strange...


can you evaluate cider-required-middleware-version?


and also cider-jack-in-lein-plugins

Jack Westmore21:09:39

cider-required-middleware-version -- "0.22.1"

Jack Westmore21:09:52

cider-jack-in-lein-plugins -- (("cider/cider-nrepl" "0.22.1"))


there's your problem. where did you make your changes?

Jack Westmore21:09:33


Jack Westmore21:09:49

should I be making the changes somewhere else?


i don't think so. I mentioned it earlier but are you sure you are restarting emacs as opposed to just closing the open windows?

Jack Westmore21:09:11

What key command would I use to restart it? I've been doing C-x C-c


“M-x kill-emacs”

Jack Westmore21:09:20

Thanks -- I tried that, restarted emacs, ran cider-jack-in and still get the error!


@lkowarschick I’m also a beginner so take with a grain of salt but maybe this will work nicely for you?

user=> (defn map-keep-type [fun coll] (into (empty coll) (map fun coll)))
user=> (map-keep-type #(+ % 1) [1 2 3])
[2 3 4]
user=> (map-keep-type #(+ % 1) #{1 2 3})
#{4 3 2}
user=> (map-keep-type #(+ % 1) '(1 2 3))
(4 3 2)


Only problem is that Lists will be backwards 😕


uhh i didn't know emptyexists, that shouuuld work (i'll reverse lists manually)... ill do some testing, thanks ;D


I can't send my pacakge to Clojars


@jiyinyiyong some others with issues with clojars. perhaps related?


turned out they didn't figure out a solution. And the problem is not Meyvn specific.


@jiyinyiyong for what it's worth, my issue with Clojars was resolved


also saw this,


how did you fix that

Gustavo Isidio22:09:18

In Haskell we only need to type :t function_name on GHCI to see the type of output and inputs of this function. Can we do the same in Clojure’s repl? I only could do this with types like String, Long by (type 10) or (type "aa") but it doesn’t work with functions.


clojure doesn't have a static type system you can query type information from, what the type function returns is the runtime jvm type of a thing


you may want to use doc

Alex Miller (Clojure team)22:09:45

On the cli, rebel-readline can do that. Other tools (Emacs CIDER, IntelliJ Cursive) can provide this

❤️ 4

user=> (doc +)
([] [x] [x y] [x y & more])
  Returns the sum of nums. (+) returns 0. Does not auto-promote
  longs, will throw on overflow. See also: +'

❤️ 4

as @alexmiller suggests there are some extra tools that you can use that will do things like displaying arglists for functions as you type

Gustavo Isidio23:09:14

Just searched rebel-readline on github and looks great. Thanks! And i love this (doc ) will help me a lot!