Fork me on GitHub
#clj-kondo
<
2019-10-22
>
whilo05:10:20

I have just played around with the current type checking. Nice work. How can I define the type of my own functions?

borkdude07:10:00

hey @whilo. that's documented here: https://github.com/borkdude/clj-kondo/blob/master/doc/types.md please note that this format is WIP and might change (although I hope not too much and I will document changes)

whilo20:10:32

What would be necessary to derive these type definitions from spec?

whilo20:10:19

I think one problem that core.typed had was that too few people wrote type definitions. A possibly very restricted subset of spec would be better than having your own type definitions. A problem of this approach would be that it can limit the use of spec for users. The restricted definitions could be an overlay that automatically tries to use spec when there is no restricted type definition available. But you are more familiar with the details of spec, I assume I am idealizing a bit.

whilo20:10:24

If this is unclear I can rephrase it.

borkdude21:10:14

One problem with spec is that you cannot express a direct relation of the arity of your function and the return type.

borkdude21:10:32

Another problem is: spec is alpha, it might change. I'm not going to build on quicksand 🙂

borkdude21:10:51

Also, the current format is mostly designed for one pass, speed

borkdude21:10:18

There could be other more convenient formats that translate to this format of course

borkdude21:10:57

Another issue with spec is that there can be many indirections, specs pointing at other specs in other files. Hard to lint. Not impossible, but hard.

borkdude21:10:45

Spec is not designed as a language for expressing types, but more like a runtime contract system.

borkdude21:10:48

Spec is also not serialisable. I want something that people can put in an .edn file.

borkdude21:10:22

I have tried spec in the beginning btw, but these were some of the issues I had with it

whilo21:10:30

Ok, I see. It is a bit peculiar that the development of spec takes so long and feels a bit intransparent.

whilo21:10:14

These issues make sense, could you talk to some spec developers about them?

borkdude21:10:58

yeah, I have talked to Alex about it. He mentioned they were going to maybe introduce a defn-like macro for specs. Once that's out and out of alpha, I'm keen on supporting that

whilo21:10:40

I think it is not strictly necessary for a type system not to contain functions, which would be required to put into an edn file. Having a validating function definition could be meaningful if one can analyze its source as well.

borkdude08:10:29

Got a hello world version of clj-kondo.lsp working 🙂 Adding the real diagnostics can't be that hard now the plumbing is more or less there

👍 8
4
borkdude10:10:58

@filipematossilva I'll probably publish the server part of clj-kondo.lsp using this: https://github.com/BrunoBonacci/lein-binplus It wraps an uberjar in a executable-like thing that works on any platform. Maybe that can also be used for the normal clj-kondo on Windows

Filipe Silva13:10:01

ah I guess that's what clojure-lsp does?

Filipe Silva13:10:08

yes that would work

Filipe Silva13:10:24

I guess it ends up being the exact same thing as I'm doing, just one jar less

Filipe Silva13:10:10

but I image your native images for osx/linux are still faster

borkdude13:10:24

yes, that wrapped jar executable would only be for Windows

borkdude13:10:37

until GraalVM sorts things out for Windows

Filipe Silva13:10:17

FWIW windows user numbers are quite high, at least on the npm ecosystem

Filipe Silva13:10:33

~50% of Angular users are on Windows for instance

borkdude13:10:18

I'm not downplaying the importance of Windows, I just don't know anything better right now 🙂

borkdude13:10:03

I think clj-kondo.lsp will help these users. The startup time for command line usage isn't much of an issue. It's the editor feedback that should be fast.

Filipe Silva13:10:06

yes I know, just wanted to give perspective

Filipe Silva13:10:39

I think there's a common perspective that windows users are a minority, but the reality ends up being different

borkdude13:10:01

I'd like to see Windows % in the next Clojure Survey

Filipe Silva13:10:33

that's a tricky one

Filipe Silva13:10:54

although it would be accurate for survey respondents, they might not accurately represent the population

Filipe Silva13:10:49

does maven provide download stats per OS?

Filipe Silva13:10:04

that might be a more accurate, if it can filter out CI machines

borkdude13:10:23

clj-kondo is published to clojars. not sure if it has those stats

borkdude16:10:18

@snoe Do you have Windows users of clojure-lsp? I just tried the lein bin plugin you're using with one of my own jars and it didn't run for me in a Windows VM

snoe16:10:55

@borkdude there's been a couple, and I have a number of open issues around it, kinda hoping someone champions it cause it's difficult for me to get a handle on.

borkdude16:10:41

I'm experimenting with bundling a .jar file in a VSCode extension. I first tried the lein bin approach, but I got a 32-bit error in a Windows VM. java -jar does work

snoe16:10:00

yeah, there's a few other older school things like jar2exe. I wanted to get ci running on azul to be able tot test them all

dominicm18:10:12

Is anyone using clj-kondo with Github actions and has that process documented?

Filipe Silva19:10:24

@snoe I can help you get github actions working

Filipe Silva19:10:35

it has windows CI too

snoe19:10:39

oh perfect

Filipe Silva19:10:55

@dominicm do you mean just running clj-kondo on github actions for CI, or a github action that runs clj-kondo on your code?

borkdude19:10:18

I think he means the latter

Filipe Silva19:10:38

that I have never done

whilo20:10:19

I think one problem that core.typed had was that too few people wrote type definitions. A possibly very restricted subset of spec would be better than having your own type definitions. A problem of this approach would be that it can limit the use of spec for users. The restricted definitions could be an overlay that automatically tries to use spec when there is no restricted type definition available. But you are more familiar with the details of spec, I assume I am idealizing a bit.

dominicm20:10:03

@filipematossilva what does the latter mean? I think I meant the former.

Filipe Silva21:10:19

the latter means making a github action that is triggered by some event in github and performs some piece of code, in this case clj-kondo

Filipe Silva21:10:51

a common usage of github actions is to automatically add/remove labels in issues/prs

Filipe Silva21:10:25

the former means adding a github actions for CI check to your commits, where a series of commands is ran and status is displayed on PRs

Filipe Silva21:10:10

if you want the former, it is mostly a matter of - deciding what OS you want it to run on - deciding on a way to install clj-kondo on that run - running clj-kondo

Filipe Silva21:10:51

I can help you setup that, can you point me to your repo?

dominicm21:10:19

I wouldn't want to put you out :) I just wanted to poke around and see how that looked in practice.

Filipe Silva22:10:45

Looks like this

Filipe Silva22:10:13

And this is the definition