plumatic/schema

Schema for higher order functions just like in clojure.spec?

zignd opened this issue · 2 comments

zignd commented

Currently, clojure.spec offers fspec as described here for validation of higher order functions. I've noticed a few mentions to make-fn-schema in Schema, but currently, it seems to be intended only for documentation, no validation is performed. Is it possible to implement something just like fspec in Schema?

w01fe commented

You can write (s/fn ...) to create a validated function directly. But as you say, schemas on higher-order functions are just for documentation purposes. As Clojure does not have a notion of a static signature, as far as I know we would have to wrap the input/output in order to validate it, and that is something we wanted to avoid in the past. Not sure if anyone else has thoughts in this area, however.

spec (as of a year ago, at least) validates the function itself by calling it ~15 times at runtime with randomly generated inputs.

which I think was always the most surprising and controversial thing about spec.