This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-21
Channels
- # announcements (12)
- # aws (1)
- # babashka (82)
- # beginners (89)
- # calva (8)
- # cider (20)
- # clj-kondo (1)
- # clojars (9)
- # clojure (120)
- # clojure-australia (3)
- # clojure-europe (14)
- # clojure-france (24)
- # clojure-germany (3)
- # clojure-italy (16)
- # clojure-nl (1)
- # clojure-spec (3)
- # clojure-uk (22)
- # clojurescript (26)
- # cursive (38)
- # datascript (1)
- # emacs (10)
- # events (1)
- # helix (7)
- # jackdaw (5)
- # jobs-discuss (37)
- # lambdaisland (10)
- # malli (20)
- # meander (2)
- # off-topic (15)
- # pathom (42)
- # quil (1)
- # re-frame (38)
- # react (2)
- # reitit (2)
- # reveal (9)
- # rewrite-clj (3)
- # ring (5)
- # shadow-cljs (84)
- # spacemacs (1)
- # tools-deps (23)
- # vim (8)
- # vscode (1)
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