Fork me on GitHub
#clojure-spec
<
2021-05-12
>
Elso15:05:59

I am trying to make the best case for clojure.spec I can, and apart from instrumentation and generators, I am trying to see if there is spec-powered tooling which is worth investigating thinking of something along these lines: https://reposhub.com/python/miscellaneous/clj-kondo-inspector.html in particular, any ways to integrate spec with cursive would be of great interest, as most folks on my job use it are there things you would suggest to check out?

dvingo16:05:36

I wanted to do data transformations from specs and down that path leads macro hell (see: https://github.com/dvingo/my-clj-utils/blob/master/src/main/dv/spec_util.clj#L36 with this helper I was told to just repeat the keys instead: https://clojurians-log.clojureverse.org/clojure-spec/2020-11-14/1605365585.379500) After this interaction, I have found much delight in using malli. Being based on data it makes analysis and transformation fairly trivial; additionally it has clj-kondo support already built in: https://github.com/metosin/malli#clj-kondo perhaps this clj-kondo transform and the graphviz one, plus the others built in would help make the case for adoption on your team.

seancorfield16:05:01

@d.eltzner012 maybe my blog post from 2019 will help provide some useful insights for you? https://corfield.org/blog/2019/09/13/using-spec/

vlaaad18:05:30

Why the difference in spec forms of anon fns?

(s/form (s/nilable #(= 1 %)))
=> (clojure.spec.alpha/nilable
     (clojure.core/fn [%]
        (clojure.core/= 1 %)))

(s/form (s/or :maybe-one (s/nilable #(= 1 %))))
=> (clojure.spec.alpha/or
     :maybe-one
     (clojure.spec.alpha/nilable
        (fn* [p1__11188#]
         (clojure.core/= 1 p1__11188#))))

Alex Miller (Clojure team)18:05:04

probably just not applying the right cleanup function on the latter