Created
July 22, 2016 20:35
-
-
Save anonymous/ef92987c8160a796b62c95e207ee0ad4 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
(defmacro | |
let | |
"Monadic let for the dynamically loaded test.check monad" | |
[bindings & body] | |
(cond | |
(not (and (vector? bindings) (even? (count bindings)))) | |
(throw | |
(ex-info "Bindings must be a vector with an even number of elements" | |
{:bindings bindings, :body body})) | |
(empty? bindings) | |
`(do ~@body) | |
:else | |
(clojure.core/let [[var val & other-bindings] bindings] | |
`(gen/bind ~val (fn [~var] (let ~other-bindings ~@body)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment