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
borkdude 2020-01-06T15:52:35.086600Z

I'm in the process of writing a version of spec(1) that can be used with babashka. For now it's an interpreted lib:

$ export BABASHKA_CLASSPATH="$(clojure -Sdeps '{:deps {spartan.spec {:git/url "<https://github.com/borkdude/spartan.spec>" :sha "104129aae9eab6dd4622937d0f46abeed9c9c537"}}}' -Spath)"
$ bb -e "(require '[spartan.spec :as s]) (s/explain (s/cat :i int? :j string?) [\"foo\" 1])"
"foo" - failed: int? in: [0] at: [:i]
I'm unsure what parts I could be adding to babashka as a built-in. Are there any assurances what parts of the API will be unchanged, and what the future namespace of spec will be ?

borkdude 2020-01-06T15:52:56.087100Z

If I have some more assurances, I could adopt parts of this lib as built-ins which would make it much faster.

alexmiller 2020-01-06T15:55:47.088Z

I can assure you that the future namespace will be different :) The current spec 2 is clojure.alpha.spec, clojure.alpha.spec.gen, etc. We're expecting this to eventually be clojure.spec, clojure.spec.gen

alexmiller 2020-01-06T15:56:55.088800Z

most of the existing spec forms will probably be the same, with some additions and some fine details changing around a few things (and deprecation/removal of s/keys)

alexmiller 2020-01-06T15:57:51.090100Z

most of the spec operations will be the same although we have added arities in all of the conforming ops (valid?, conform, explain, etc) to support spec checking modes

borkdude 2020-01-06T16:04:06.090900Z

thanks

seancorfield 2020-01-06T17:51:50.091600Z

@alexmiller Any sense yet of whether there will a migration path/tooling at launch of clojure.spec?

alexmiller 2020-01-06T17:54:08.091900Z

as long as there are no follow-up questions, yes :)

4
lgessler 2020-01-06T23:27:19.094500Z

hi, I want to use s/fdef with protocol functions. In one namespace, I'm calling fdef and defining and implementing a protocol, but the protocol's methods appear to be unaffected by fdef. If I understand [this issue](https://clojure.atlassian.net/browse/CLJ-2109) right, this is expected behavior. Is that all right, and if so, is there a recommended workaround for speccing protocol functions?

alexmiller 2020-01-06T23:33:46.096800Z

That’s correct - fn specs don’t work with protocol methods. Only workaround I’d suggest is wrapping the call to the protocol function in a method (which I often do as a matter of practice anyways)

👍 1