clojure-spec

conao3 2024-10-29T16:25:38.497719Z

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.

conao3 2024-10-30T22:16:09.494479Z

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
seancorfield 2024-10-29T16:29:41.533659Z

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
seancorfield 2024-10-29T16:31:08.948689Z

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:25:20.035159Z

https://github.com/borkdude/speculative

1
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

ray 2024-10-29T19:34:04.871109Z

@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?

conao3 2024-10-29T23:20:16.526589Z

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.

conao3 2024-10-29T23:21:38.742879Z

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