beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
Oliver 2021-04-25T06:36:54.074800Z

Any recommendations for good reads how to build a (simple) application with Clojure? I understand the basics for data manipulation, but I struggle with control flow, user interface and working with immutability in practice.

Ben Sless 2021-04-25T07:16:43.075100Z

desktop? web app? CLI?

Oliver 2021-04-25T07:21:44.077100Z

Web app would be the target, but I am happy to start with some simple desktop apps if that is easier to start.

Ben Sless 2021-04-25T09:23:27.077700Z

Web app would be easier, actually, take a look at https://github.com/seancorfield/usermanager-example/

πŸ™ 1
practicalli-john 2021-04-26T10:08:56.132800Z

This may be of interest too https://practicalli.github.io/clojure-webapps/

1
Eric Ihli 2021-04-25T12:46:38.081100Z

Are there any gotchas or concerns about putting side-effects in a transduction? I searched and found https://groups.google.com/g/clojure/c/SVaFtQgtolc and my understanding is that what the original asker is doing should be fine since transduce/reduce is non-lazy. But the first line of the answer that says "Transducers are a new feature and best practices are still emerging" make me wonder if the best practice that has emerged may be that it's a bad idea for some reason.

kennytilton 2021-04-25T13:12:13.082900Z

Just inherited ` (some->> (get-in db [:hi :mom]) (into [])) Curious about (into []). Why not just a literal []? Thx!

2021-04-25T13:26:53.083Z

(let [res '(:a :b :c)]
   (into [] res))
=> [:a :b :c]

(let [res '(:a :b :c)]
  [res])
=> [(:a :b :c)]
With the literal [] you won't get the conj type behaviour, so you will end up with a nested collection?

yuhan 2021-04-25T13:54:43.083500Z

I usually use vec for this, but (into []) might communicate the intent clearer.

athomasoriginal 2021-04-25T15:01:55.087400Z

I have a ring-jetty server. I use 3rd party libraries in my server which make network requests (think stripe sdk). I would like to monitor the network requests my server is making. What do people like to do for this? I use Charles Proxy to monitor front end requests, but i’m not sure if this tool is also used for monitor requests my server makes :thinking_face: (apologies if there is a better channel for this post as I know it’s not really Clojure specific)

Lukas 2021-04-25T17:47:33.087700Z

Hello, could anyone help me with the following: how do I realize a lazy seq and spit it into a edn file?

Lukas 2021-04-25T17:56:35.087900Z

Nvm my bad I was looking into the wrong file πŸ™ˆ πŸ˜‚ I'm sorry

sova-soars-the-sora 2021-04-25T17:57:16.088400Z

if you change a lot of code multiple times and nothing changes... maybe it is a different file xD ... hard-won lessons of coding

❀️ 2
2021-04-25T18:08:11.088600Z

The nice thing of that advice is that it is independent of programming language πŸ™‚

πŸ˜† 1
piyer 2021-04-25T20:52:27.090300Z

I am trying to find a nice linter. I currently use eastwood and kibit, what do people generally use?

piyer 2021-04-25T20:53:02.090800Z

I also saw https://github.com/candid82/joker

dharrigan 2021-04-25T20:54:33.092300Z

clj-kondo #clj-kondo

2021-04-25T20:55:38.093600Z

is there a way to use the value being threaded in cond-> in the condition used to decide whether or not to call the associated fn? if you do

(cond-> db
  true (something-that-changes-db)
  (some-cond? db) (called-conditionally)) 
the value used in that condition seems to be the original db, not the newly updated db value

piyer 2021-04-25T20:57:58.093800Z

will check it out. I was expecting eastwood to throw errors for unused imports

piyer 2021-04-25T20:58:03.094Z

It did not.

dharrigan 2021-04-25T20:58:17.094200Z

clj-kondo will flag unused imports

dharrigan 2021-04-25T20:58:50.094400Z

https://github.com/clj-kondo/clj-kondo`

piyer 2021-04-25T21:00:55.094800Z

perfect

2021-04-25T21:02:52.095Z

Well, db is never updated

2021-04-25T21:04:04.095700Z

db is a name bound to an immutable value

2021-04-25T21:04:15.096Z

yeah, it makes sense that the above does not work, having looked at it, but I was wondering how I could use the updated value in that next cond

2021-04-25T21:06:11.097Z

kind of like a combo between cond-> and as-> where you can thread the updated value through any position(s) you want

2021-04-25T21:06:18.097100Z

There is nothing built it for it, but various libraries add their own macros that do that sort thing like https://github.com/worldsingles/commons/blob/master/src/ws/clojure/extensions.clj#L50

2021-04-25T21:06:37.097500Z

thanks! I will take a look

seancorfield 2021-04-25T21:20:18.099300Z

The thing to watch with condp-> is that all of the conditions must be predicate expressions: you start with cond-> db true ... so that true needs to be something that db can be threaded into and will yield true.

seancorfield 2021-04-25T21:23:00.101900Z

(condp-> db (or true) (something-that-changes) (some-cond?) (called-conditionally)) might be what you need: db is threaded as the first argument into the first condition and (if truthy) the first result expression, and the result of that will be threaded into (some-cond?) and if that's truthy, it'll be threaded into (called-conditionally) -- make sense?

seancorfield 2021-04-25T21:26:39.102400Z

$ clj -Sdeps '{:deps {worldsingles/ws-commons {:mvn/version "RELEASE"}}}'
Downloading: worldsingles/ws-commons/maven-metadata.xml from clojars
Clojure 1.10.3
worldsingles/clojure/extensions.cljc on classpath.
user=> (require '[ws.clojure.extensions :refer :all])
nil
user=> (condp-> 42 (or true) (inc) (odd?) (inc))
44
user=> (condp-> 42 (or true) (inc) (even?) (inc))
43

2021-04-25T21:28:44.102500Z

yeah, thanks! example is super helpful

piyer 2021-04-25T22:59:07.103700Z

with-open with a custom closing problem looks generic enough that I am expecting something pre-written.

2021-04-25T23:01:05.103800Z

Maybe in a 3rd party library (not one I know about, unfortunately), but I don't think such a thing is built in.

2021-04-25T23:01:26.104Z

You could use something like proxy to create a one-off object with a close method that calls your custom close method.

2021-04-25T23:01:34.104200Z

and use built-in with-open on that object.

2021-04-25T23:02:11.104400Z

I haven't done this before, so may be getting confused over whether proxy, reify, or something similar is the best choice here.