Fork me on GitHub

Ahoy! Is there any way to generate a spec for an anonymous function without using s/fspec? Or without s/fspec generating data to test the function with? We've got a pattern where a callback is passed into a function, and we want to validate that the callback conforms to the expected function 'shape'/arity. As I understand it we can't use s/fdef, because at the point we get the callback (as an arg to our function) it's not bound to a symbol, which s/fdef requires as the first arg. Our callback function may be side effecting/have state (store some of the callback results in an atom for later reference), so if we use s/fspec then we do get an error if the callback doesn't have the right arity, but our state also gets corrupted with all the junk data that s/fspec generated to test the function.


You can just spec it as ifn?


It won’t check the “shape” then