Closed zignd closed 3 years ago
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.
Currently, clojure.spec offers
fspec
as described here for validation of higher order functions. I've noticed a few mentions tomake-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 likefspec
in Schema?