clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
tikotus 2020-07-23T06:12:05.024Z

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.

seancorfield 2020-07-23T14:46:32.025900Z

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

borkdude 2020-07-23T14:53:10.026800Z

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.

borkdude 2020-07-23T14:55:28.028300Z

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.

borkdude 2020-07-23T14:57:08.029200Z

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

tikotus 2020-07-23T16:27:13.037700Z

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.

borkdude 2020-07-23T16:32:20.038100Z

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

borkdude 2020-07-23T16:32:45.038300Z

This comment specifically: https://clojurians.slack.com/archives/C1B1BB2Q3/p1595516128028300

borkdude 2020-07-31T17:28:40.052900Z

That was mentioned as part of that conversation

johanatan 2020-07-31T17:30:28.053500Z

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

arohner 2020-08-06T12:49:15.069200Z

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

tikotus 2020-07-23T18:12:21.040100Z

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