Fork me on GitHub
#clojure
<
2023-01-21
>
hifumi12300:01:30

How do people typically set up clj-kondo in github actions? I'm considering https://github.com/DeLaGuardo/clojure-lint-action and wondering if anyone can vouch for it.

hifumi12300:01:08

Does this also display linter warnings in commits?

hifumi12300:01:38

That is the main feature I'm looking for. I have a project that can already run CI builds and tests, but I just need something to run clj-kondo and display its warnings near offending lines in PRs and what not

practicalli-johnny09:01:29

https://github.com/nnichols/clojure-lint-action uses clj-kondo with reviewdog which will comment issues in the PR where they occur

👍 2
practicalli-johnny10:01:20

This is a list of GitHub actions I commonly use for Clojure projects https://practical.li/engineering-playbook/continuous-integration/github-actions/

🙏 2
borkdude17:01:28

@U0479UCF48H FWIW, I'm using that clojure-lint-action on clj-kondo's repo itself and it displays errors nicely

Ravinder Ram12:01:31

hi how to convert (def aa (io/input-stream ...)) byte/binary into string

phill13:01:19

slurp

😀 2
Ravinder Ram12:01:51

how to get as string from input-stream /binary data

Gerome12:01:23

Hello! I’m developing clojure in my free time because my employer uses JS and Java. However, I would like to get a lot more practice and I was wondering how other people find room to develop in their free time, especially with a family. Do you always have your laptop ready to go or do you have some mobile development setup with your phone?

dpsutton14:01:41

Hey @UPJP9G4G1 this is a really interesting question and I think you could spark a fruitful discussion. But do you mind deleting it from this channel and asking in #C03RZGPG3 ? We try to keep this channel a bit focused on technical bits and encourage the more conversational questions there. Thanks

Gerome15:01:01

Sure thing

🙏 2
Jakub Holý (HolyJak)21:01:48

Hello! Is that a simple, cross-platform way to check for a lazy seq? I have been burned before by logging a lazy seq and getting the useless clojure.lang.LazySeq@zdcqe1 in my logs so I want to force it into something that prints nicely. Currently I do

(cond-> input (instance? #?(:clj clojure.lang.LazySeq :cljs cljs.core/LazySeq) input) vec)
🙏

didibus22:01:16

Look here: https://github.com/didibus/special/blob/faster-and-more-correct-eagerization/src/special/eagerize.cljc You can copy some of this. Basically make a protocol like Eagerizable, and then just extend types to it.

didibus22:01:08

Calling eagerize will then realize anything. So no matter what you log, it will get realized and logged.

didibus22:01:32

I'll probably turn it into a small library some day, but for now you can just copy/paste the code

phronmophobic22:01:53

What are you using to print values? It seems like if you want to change how the value is printed, then you should modify/change the printer rather than modify/change the value.

Jakub Holý (HolyJak)00:01:15

I am using taoensso.timbre/info Thank you, didibus, I will have a look!

phronmophobic00:01:55

timbre offers config and middleware so you can augment how values are logged. that would allow you to fix how values are printed in one place.

🙏 2
Jakub Holý (HolyJak)00:01:17

Thank you! I did not know that

didibus23:01:01

I'm choking a bit with a macro here, I'm inside of unquote and want to return code that also uses unquote?

(let [expr false]
  `(foo `(bar ~expr)))
and I want:
(foo `(bar false))

hiredman23:01:52

Nesting syntax quote is almost certainly a mistake

didibus23:01:59

Maybe, but I'm doing something quite tricky. A macro that returns if the compiler thinks the return value of a form is primitive

didibus23:01:37

Hum, ok, you're right

didibus23:01:47

It's a mistake, I actually don't need this to be a macro at all

didibus23:01:29

Shouldn't this error:

(loop [i 0]
  (if (= i 0)
    (recur "hello")
    i))
Because the primitive local type was rebound to a different type? > • recur forms that rebind primitive locals do so without boxing, and do type-checking for same primitive type.

phill00:01:45

i isn't primitive. You can use (loop [^long i 0]... to get the effect you expected

didibus00:01:16

That's not valid syntax, it says: > Can't type hint a local with a primitive initializer

didibus00:01:36

i should be primitive in my example, let does inference

phronmophobic00:01:05

(set! *unchecked-math* :warn-on-boxed)

;; emits warning
(loop [ i 0]
  (case i
    0 (recur "hello")
    "hello" (recur 1)
    1 (inc i)))

;; does not emit warning
(loop [ i 0]
  (case i
    0 (recur 1)
    1 (inc i)))

didibus00:01:09

Ya, which contradicts the docs, because instead of type-checking for same type, it infered Object ?

ghadi00:01:32

I don’t see the contradiction

phronmophobic00:01:37

do you have a link to the docs you're referring to?

didibus00:01:31

So in what scenario would we get a type-check error here? By the way, I'm pretty sure I've seen recur complain about wrong type before, but now am confused how to repro or when it would do so

ghadi00:01:22

where is the error implication?

didibus00:01:46

> and do type-checking for same primitive type.

phronmophobic00:01:56

it doesn't say that it gives a type check error. it says it checks the type, which you can see with (set! *unchecked-math* :warn-on-boxed)

2
didibus00:01:38

So this is just saying it would make it Object if you were to rebind to a different primitive type?

didibus00:01:55

The warn on box is different, like take this:

(loop [i 0]
  (if (= i 0)
    (recur false)
    i))
Why no warn?

phronmophobic00:01:08

It doesn't say it makes it Object. it says that it rebinds primitive locals without boxing when the type checks out

phronmophobic00:01:49

unchecked-math only warns on boxed math. your example doesn't have boxed math

didibus00:01:26

No, it says it does type checking for SAME primitive type: > and do type-checking for same primitive type

phronmophobic00:01:07

It's not really clear what you're trying to do

didibus00:01:14

I also remember getting this error many times, and you need to cast, because you're like rebinding a double into a long for example.

didibus00:01:47

I guess I was under the impression, because I remember getting the error before, that if you recur and change the primitive type of the local, Clojure errors. I remember getting this error a few times before. And then I went looking again, and saw that it is mentioned in the doc. But I wasn't able to see this behaviour.

didibus00:01:59

Knew it:

(loop [a (byte 0)]
  (if (= a 0)
    (recur (long 1))
    a))

Caused by java.lang.IllegalArgumentException
    recur arg for primitive local: a is not matching primitive, had: long,
   needed: byte

didibus00:01:30

So it seems it only does it for certain combination of types, but not for all change in the type. Weird

didibus00:01:25

(loop [a (short 0)]
  (if (= a 0)
    (recur "hello")
    a))

Caused by java.lang.IllegalArgumentException
    recur arg for primitive local: a is not matching primitive, had:
   java.lang.String, needed: short

didibus01:01:32

Well, I don't totally understand why it doesn't always do mismatch checking, might be other things going on in other places, and can't tell if it's a bug or not. If anyone has more idea, I'm all ears