Evaluates an expression after replacing the keywords defining the
monad operations by the functions associated with these keywords
in the monad definition given by name.
(defmacro with-monad
"Evaluates an expression after replacing the keywords defining the
monad operations by the functions associated with these keywords
in the monad definition given by name."
[monad & exprs]
`(let [name# ~monad
~'m-bind (:m-bind name#)
~'m-result (:m-result name#)
~'m-zero (:m-zero name#)
~'m-plus (:m-plus name#)]
(with-symbol-macros ~@exprs)))
Comments top
No comments for with-monad. Log in to add a comment.