Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2016 20:35
Show Gist options
  • Save anonymous/ef92987c8160a796b62c95e207ee0ad4 to your computer and use it in GitHub Desktop.
Save anonymous/ef92987c8160a796b62c95e207ee0ad4 to your computer and use it in GitHub Desktop.
(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