Fork me on GitHub
#clojure-spec
<
2020-07-23
>
tikotus06:07:05

Thanks @borkdude, that's what I was looking for. But doesn't seem very active. Is it just me or wouldn't such a tool be simply amazing? It would make transitioning from statically typed languages feel a lot safer.

seancorfield14:07:32

@jahvenni I think its very misleading to think of anything Spec-related as some sort of analogy to static typing...

borkdude14:07:10

Yes. spec is a runtime validation/conformation/generation library. And considering how complex core.typed gets, I don't think getting leverage out of specs at compile time is trivial. Using a tool for something it's not designed for in general is ... hard.

borkdude14:07:28

I do think you can get <some> leverage out of it. E.g. a tool could inspect specs at runtime, parse out the trivial stuff like, is the first argument an int?? Then something like https://github.com/borkdude/clj-kondo/blob/master/doc/types.md can be generated and you will get <some> static analysis benefits for clj-kondo, for example.

borkdude14:07:08

Malli / @ikitommi has demoed a similar approach at ClojureD.

tikotus16:07:13

Yeah, figuring out the trivial stuff is what I had in mind mostly. I can see many trivial cases where a linter utilising specs could easily provide value. Things like order of parameters, names of keyword arguments or tricky get-in's are mentally really heavy for someone who is used to have these things given by autofill. To me these sound like trivial things to check in most cases if spec is provided. It would be a much softer landing to a dynamic language.

borkdude16:07:20

@jahvenni The approached I outlined is open for anyone to implement or experiment with 🙂

borkdude17:07:40

That was mentioned as part of that conversation

johanatan17:07:28

Oh, sorry. Didn’t scroll back far enough I guess.

arohner12:08:15

spectrum is no where near working, and I’m not sure whether I will have the time to finish it

tikotus18:07:21

Yeah, thanks! That’s exactly the kind of info I was looking for :)