-
-
Save atroche/731f80376985773c60d5e943b38d8052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(s/def ::fn-takes-two-args | |
(s/fspec :args (s/cat :arg1 long? | |
:arg2 long?) | |
:ret long? | |
:gen (fn [] (fn [a b] (* a b))))) | |
=> :user/fn-takes-two-args | |
(defn fn-that-takes-fn-with-two-args [f] | |
(f 1 2)) | |
=> #'user/fn-that-takes-fn-with-two-args | |
(s/fdef fn-that-takes-fn-with-two-args | |
:args (s/cat :function ::fn-takes-two-args)) | |
=> user/fn-that-takes-fn-with-two-args | |
(s/valid? ::fn-takes-two-args | |
(fn [a b] (+ a b))) | |
=> true | |
(s/explain ::fn-takes-two-args | |
(fn bad-fn [a b c] (+ a b c))) | |
val: (0 0) fails spec: :user/fn-takes-two-args predicate: (apply fn), Wrong number of args (2) passed to: user/eval47132/bad-fn--47133 | |
=> nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment