Fork me on GitHub
#clojure-europe
<
2021-07-23
>
pez06:07:16

Morning!

helios06:07:29

👋 ☀️

dharrigan07:07:05

Good Morning!

borkdude11:07:28

morning, good.

otfrom13:07:17

wow. I had no idea that emacs tramp mode worked with google drive

🤯 8
otfrom13:07:39

if only I could get clojure working this easily with google drive

mccraigmccraig13:07:11

wat ? that is very cool

otfrom13:07:26

C-x d ~//gdrive::/

otfrom13:07:55

this is on ubuntu w/the account syncing already set up so I don't know if it is using that behind the scenes

ordnungswidrig14:07:55

Good luck when you're und 2FA. Or does this work?

slipset15:07:33

Hi hi, I’m so old I remember when tramp was initially developed.

otfrom15:07:13

@ordnungswidrig I have 2fa turned on for google

otfrom15:07:26

has no one else tried it yet?

pez17:07:57

I’m wondering, what’s involved in testing if a functions f is using any function g, h, or i … or even a macro m, or n? I’d like to have that feature in Rich 4Clojure, but I don’t know where to start.

borkdude19:07:37

You could also use with-redefs to temporarily disable these functions maybe

borkdude19:07:42

as a crude workaround

borkdude19:07:10

it doesn't work for inlined functions though:

(with-redefs [inc nil] (inc 1))

borkdude19:07:27

but that should be an acceptable edge case

pez21:07:44

I’d like for the rest of the tests to still work, but if I can’t have that, then maybe redefs is the way to go…

borkdude21:07:45

what rest of the tests?

borkdude21:07:54

I mean, evaluate the answer in the with-redefs, not all of your project

borkdude21:07:00

@U0ETXRFEW do you use a separate namespace for each problem?

borkdude21:07:18

Then you could also use :refer-clojure :exclude [the-forbidden-var] perhaps

borkdude21:07:36

of course users can hack around this, but who are they fooling but themselves

pez21:07:17

For a problem like: > Write a function which returns the last element in a sequence. Which restricts the use of last. And the tests:

(tests
 (__ [1 2 3 4 5]) := 5
 (__ '(5 4 3)) := 3
 (__ ["b" "c" "d"]) := "d")
I’d like the tests to pass for a solution like:
(def __ last)
And I want to add a test that informs that the solution is not OK. In this case it is quite easy:
(tests
 __ :<> last
 (__ [1 2 3 4 5]) := 5
 (__ '(5 4 3)) := 3
 (__ ["b" "c" "d"]) := "d")
but it is sometimes much trickier than that.

pez21:07:38

> do you use a separate namespace for each problem Yes

borkdude21:07:52

yes, so you could use :refer-clojure :exclude [...] then?

borkdude21:07:50

with ... containing only the restricted var per problem

pez06:07:11

That would make the tests in the example with

(def __ last)
Throw exceptions instead of pass. The attached image is how I want it to work. (And it does work for this simple example.

borkdude07:07:48

You have said this before but I didn’t understand what you said. Isn’t the whole point to make this fail because that specific var is forbidden?

borkdude07:07:52

SCI supports evaluating expressions while forbidding certain symbols/vars

borkdude07:07:43

You could also use normal JVM eval while pre-processing the sexpr

pez07:07:49

It can be argued what the point is. 😀 I want the user to be able to freely explore. Also the restricted things. I am fine with not checking it at all, but one of the first users seemed to get confused by that. So want to investigate what it could take. And learn something in the process.

borkdude08:07:52

So you want to both allow and disallow it? Yeah I can see how that can be a conflicting requirement :-)

borkdude08:07:42

But again, I think with-redefs or some light macro around this called forbid or so, could work

borkdude08:07:56

So you can locally forbid it

pez08:07:36

Haha, yeah, conflicting requirements. I’m thinking more like clj-kondo, it gives advice, but doesn’t force you do to anything. Maybe it could even be implemented as a linter? That would be great!

borkdude09:07:39

@U055NJ5CC also asked for a similar thing, if he could somehow emit extra lint warnings so clj-kondo would display them (I think?)

borkdude09:07:23

clj-kondo could support this e.g. by having a directory in .clj-kondo where people can dump extra findings in an EDN file, clj-kondo would return them on the next run or so

borkdude09:07:48

but then you would only see them on the next edit. and the tool should then also take care to remove the findings when the error was no longer there

borkdude09:07:59

perhaps CIDER supports something similar

ikitommi10:07:20

a findings-file would be great. Or a socket endpoint in LSP-server to receive edn-events. In my use-case, I know a Var and would like to tag an issue for it, e.g.

{:var user/kikka
 :level :warning
 :message "invalid function schema, calling function with arguments (0, 0) produces invalid output \"00\", should be :int"}

borkdude10:07:02

for clj-kondo running as a non-server (standalone binary) a socket won't work, I think the only way would be a file

👌 3
borkdude10:07:22

for clojure-lsp a directory watcher or so could work

👂 3
borkdude10:07:45

but let's say for the sake of argument, we went with the file option

borkdude10:07:54

what would be the flow?

borkdude10:07:06

user in a REPL activates your tool, tool finds something, emits a file

borkdude10:07:28

then clj-kondo has to run, but the editor tooling only makes it run on the next code edit

borkdude10:07:42

so there is a synchronization problem there

ikitommi10:07:02

yes. It already recreates the full clj-kondo config per each check (which happens when user evaluates a form, via atom watcher)

borkdude10:07:35

I think something in CIDER could be more appropriate since it's really something that comes from the runtime. I'm surprised that people have made specific tooling for flycheck when it comes to eastwood linting since that could probably also be implemented as a CIDER middleware? E.g here is some code to display stack traces. https://github.com/clojure-emacs/cider-nrepl/blob/6d3934eb665574af891e81ef5c11cf9c2b4e1d65/src/cider/nrepl/middleware/stacktrace.clj#L197

bozhidar12:07:02

Yeah, that should be easy to do.

borkdude19:07:00

Somebody on the internet made something cool: https://twitter.com/RustyVermeer/status/1418652171558481921

🎉 9