Fork me on GitHub
#beginners
<
2019-11-13
>
indy07:11:17

Hi all, I'm looking to contribute to some beginner friendly open source clojure projects, I've gone through the brave clojure list and though there are some beginner friendly issues, I don't know where to start

indy07:11:48

Is it required that I read much of the source code and understand it before contributing?

Alexander Heldt08:11:01

well, it depends. but in general you probably should have a good grasp on what the project does to be able to make a good contribution.

valerauko08:11:02

find a beginner-friendly issue, reproduce it, debug it, fix it, put up a pr

ho0man08:11:11

Hi, everyone How can I have a drop in repl (like browse in R lang) for debug in clojure?

seancorfield14:11:36

@U6CE37RK6 sounds like you're looking for a Socket Repl?

ho0man14:11:18

Thanks @seancorfield Do you have a link or code example on how to do it?

ho0man14:11:59

I wanna make it part of my workflow (I use spacemacs + cider) (Should I use clojure.core.server/start-server?)

ho0man14:11:04

Thanks again

seancorfield15:11:25

You can start a socket repl with just a JVM option when you start your application. You can then connect to it via telnet or netcat. Our use unravel / unrepl for a better experience.

seancorfield15:11:07

Cider requires NREPL

seancorfield15:11:08

When you talk about spacemacs/CIDER, that sounds like a regular development workflow which is always REPL-based in Clojure

seancorfield15:11:27

So maybe I'm confused about what you're asking?

noisesmith19:11:06

maybe the key thing with "browse" is that it drops you into the context of the error, with the locals and stack frames available? that's not really how things work in clojure normally but there was at least once a debug-repl for this sort of functionality https://stat.ethz.ch/R-manual/R-devel/library/base/html/browser.html

noisesmith19:11:52

@U6CE37RK6 maybe to move up a level, what we usually do instead is isolate state and mutation, so that as much as possible can be debugged standalone

ho0man08:11:15

Thanks @seancorfield , yeah I already use the repl all the time, and what I was looking for was exactly what @noisesmith mentioned : to be dropped into the context and be able to access locals and stack frames.

ho0man08:11:41

Thanks a lot @noisesmith, the debug-repl you mentioned by @U0GN0S72R appears to be exactly what I was looking for.

ho0man08:11:20

Also thanks for your advice. But I have a question about it. I do try to isolate state and mutation yet I still find such functionality useful ... to use it when you’re probing the system for sth or ... e.g. when a generative test fails and it’s not able to shrink it properly. What’s the best way to debug then ? Thanks again @noisesmith

noisesmith18:11:20

glad I could assist, mutation in order to track local data is actually useful (and isn't neccessarily subject to the same problems that mixing side effects with app logic can be) - eg. you can add (def debug (atom [])) at the top level and something like (swap! debug conj {:context ::some-context :args [arg1 arg2] :locals {:a a :b b}}) inside the function you are debugging - it's like println debugging except you can actually play with the data, even if the issue comes up every Nth invocation

noisesmith18:11:33

but the more principled you are about isolating side effects and logic, the more likely something like that is actually useful (eg. not relying on state of some fd or resource that is closed on error or exit)

solf08:11:03

Any better way of associating a variable using update-in than using constantly? The reason I don't use assoc-in instead is because it's intended to be used with lein update-in. Here's what I got:

(update-in {} [:local-repo] (constantly ".m2"))

solf09:11:24

Actually scratch that, using constantly doesn't work, so a better question would be, how to change lein :local-repo using the command line? This doesn't work:

lein update-in :local-repo '(constantly ".m2")' -- deps

jaihindhreddy10:11:09

Well, is there a lein assoc-in?

timo11:11:24

hi there

timo11:11:17

I am using chime to heartbeat via async-http request like documented here: https://github.com/jarohen/chime#chime-ch

timo11:11:53

now I need to find a way to return the channel so that I can close it when needed. the example just runs and I cannot stop it gracefully. any ideas?

valerauko15:11:02

my first idea is that you return a function closed on it when you create it so you can call that when you want to close it

(let [chimes (chime-ch ,,,)]
  (<!! ,,,)
  (fn stop-chiming []
    (close! chimes)))

valerauko15:11:04

if you use mount state then

(defstate chimer
  :start
  (let [chimes (chime-ch ,,,)]
    (<!! ,,,)
    chimes)
  :stop
  (close! chimer))

👍 4
timo15:11:03

thing is, <!! is blocking

timo15:11:26

but one can just leave it away

mloughlin14:11:40

is there a preferred method to open a file at a given byte? I don't know Java well.

mloughlin14:11:01

that might be correct, I only need to read the file. Is this a use Java interop situation?

mloughlin14:11:11

amazing. thanks both!

Luke Schubert14:11:11

is there a way to prevent backtick quoting from adding the namespace?

Luke Schubert14:11:12

example

(ns test-ns)
(defn get-vec `[?foo ?bar])
(get-vec)
=> [test-ns/?foo test-ns/?bar]
;;I want that to return
;;=> [?foo ?bar]

hansbugge14:11:12

user=> `[~'?foo ~'?bar]
[?foo ?bar]

Luke Schubert14:11:06

ah gotcha, that makes sense albeit not the most clean looking thing. Thanks

👍 4
coder4633415:11:38

What does everyone use instead of async-await in cljs? Need to make a few calls to js libraries and want to avoid callback hell. I don't seem to be able to find tutorials

enforser15:11:04

and mentioned at the bottom of that blogpost is cljs-promises which make a promise more like an async channel

coder4633415:11:49

The problem with that tutorial is that it seems out of date. Promesa doesn't have p/await

mloughlin15:11:03

you could try asking in #clojurescript

Sreeram16:11:57

I know what I am going to ask below is very vague question, sorry for that. But if you have any points for me to check will greatly help. I get the below exception: clojure.lang.ArityException: Wrong number of args (3) passed to: core$not This started coming after I added new argument for the existing function in both Java class and also in clojure reify where ever it is used. Any suggestions/ideas to fix this issue will be helpful. Thank you!

andy.fingerhut16:11:10

Do you know how to show stack traces for exceptions?

Sreeram17:11:19

I tried the below in my .clj file. But it doesn't print stacktrace in the log file. (catch Exception e (logger/error (str "failure " ) e) (clojure.stacktrace/print-cause-trace e)) could you please tell me how I can enable full stack trace in clojure?

andy.fingerhut16:11:47

They can be long, and contain things you can safely ignore, and it takes some practice to read them, but they can give valuable clues.

seancorfield16:11:50

@sreerama.naga Sounds like you have code that calls not like this: (not a b c) instead of (not a) (single argument). Perhaps when editing the code to add a new argument, you ended up moving a )?

Camilo Jorquera19:11:26

Hello! What is the best book to learn Clojure? I work with Java and I have experience with Scala, but i want to learn a pure functional lang. Thanks!

andy.fingerhut19:11:24

Hard to say what is the best. I like "Clojure Programming" by Emerick, Grand, and Carper, but published in 2012 so while much of it still works just fine, you may want something more recent like "Programming Clojure" by Miller, Halloway, and Bedra, 2018.

😄 4
mruzekw19:11:27

Joy of Clojure. Heard it’s good and enjoying it

😄 4
mruzekw19:11:35

Gets behind the why, not just how

Camilo Jorquera19:11:17

Joy of Clojure Manning? @U1RCQD0UE

Dave Goodchild22:11:40

Clojure For The Brave And True

👌 4
g19:11:29

hey everyone. what exactly is the difference between jetty and ring?

hiredman19:11:32

Ring is an abstraction

hiredman19:11:44

It describes how http requests can be mapped to functions that take maps in one format and return maps in another format

g19:11:21

got it. so in theory you could plug a different implementation into it

hiredman19:11:53

Not in theory there are many ring adapters for different webservers

andy.fingerhut19:11:57

The best kind of theory -- the one that works in practice.

🙏 4
hiredman19:11:12

Jetty is a webserver for which the ring project ships an adapter for (most other adapters are maintained outside of the ring project)

g19:11:48

so it sounds like if i wanted to learn about how to tune a jetty server for production load, it would be more of a jvm question than clj

hiredman19:11:33

It depends, as an abstraction ring has some costs, and depending on your analysis you might decide things will perform better without the adapter and speaking to jetty directly from clojure

hiredman19:11:40

I think it would start as more of a jetty question (jetty has pretty extensive docs), and then maybe move to the jvm, then maybe looking at the costs of ring

g19:11:56

sounds like a plan. thank you

ho0man08:11:15

Thanks @seancorfield , yeah I already use the repl all the time, and what I was looking for was exactly what @noisesmith mentioned : to be dropped into the context and be able to access locals and stack frames.