Created
November 20, 2012 16:47
-
-
Save fogus/4119175 to your computer and use it in GitHub Desktop.
core.contracts with HoCs
This file contains hidden or 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
(def C | |
(contract | |
foo | |
"bar" | |
[f n] | |
[(integer? n) | |
(_ f [n] [odd?]) | |
=> | |
integer?])) | |
(def foo (with-constraints | |
(fn [f n] (+ (f n) n)) | |
C)) | |
(foo #(* 2 %) 11) | |
;=> 33 | |
(foo #(* 2 %) 10) | |
; Pre-condition failure on argument to HoC for argument f: (odd? n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment