Skip to content

Instantly share code, notes, and snippets.

@apskii
Last active December 22, 2015 14:39
Show Gist options
  • Save apskii/6487585 to your computer and use it in GitHub Desktop.
Save apskii/6487585 to your computer and use it in GitHub Desktop.
(define-statement-abstractor (monad m)
(:rules
(val ((name expr) rest) `(let ((,name ,expr)) ,rest))
(get ((name expr) rest) `($ (monad-bind m) ,expr (fn (,name) ,rest)))
(:else (expr rest)
(let ((arg (gensym)))
(if rest
`($ (monad-bind m) ,expr
(fn (,arg) (declare (ignore ,arg)) ,rest))
expr))))
(:whole (expr)
`(let ((*monad* m)) ,expr)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment