Skip to content

Instantly share code, notes, and snippets.

@fogus
Created November 20, 2012 16:47
core.contracts with HoCs
(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