clojure-spec 2024-10-29

I found https://github.com/clojure/core.specs.alpha. It hosts spec for clojure.core functions/macros but there're small number of specs. Is there a clojure.spec.alpha spec for almost all clojure.core? If not, I am planning to work on it.

https://github.com/metosin/malli?tab=readme-ov-file#clj-kondo I find clj-kondo support by Malli. This feature is probably I'm looking for. And I type clojure.core functions by malli, clj-kondo report issues on-the-fly.

👌🏼 1

There is at least one such library of specs out there. I don't remember who maintains it nor how up-to-date it is.

1

https://ask.clojure.org/index.php/12851/full-specs-for-clojure-core-in-core-specs-alpha mentions this (and explains why the core team have not built this).

Alex Miller (Clojure team) 2024-10-29T18:27:24.324339Z

there are a lot of reasons why making these specs is surprisingly difficult - a lot of core functions are very generic and/or polymorphic - they intentionally work with many "types" and there is usually not a common supertype. also, the things it does not work with NOW are places where we like to add features. I did help borkdude on some of the specs above

Alex Miller (Clojure team) 2024-10-29T18:27:54.598119Z

I think what he found using it was that turning on instrumentation for everything core makes it intolerably slow to use

@conao3 one of the nice things about the core specs is they (for the most part) round trip between conform and unform. That’s a feature I would appreciate for parsing. And would be willing to help achieve. It depends on your specific goals… and what are they?

I was thinking something similar to Schuyler. https://ask.clojure.org/index.php/12851/full-specs-for-clojure-core-in-core-specs-alpha?show=12866#c12866 The runtime errors from spec are great, but as someone coming from Python, I notice Clojure doesn't seem to report type errors on the fly - that's something I'd like to work on. While there are various ways to represent types, as a beginner, I think clojure.spec might be worth investing my time in.

I will probably use that type information to contribute to clojure-lsp.