View difference between Paste ID: 1WEZCqGw and W2AhVqdP
SHOW: | | - or go back to the newest paste.
1
(define-syntax (define-monadic x)
2
  (syntax-case x ()
3
    ((k id (m) body)
4
     (with-implicit (k unit bind mmap)
5
       #'(define id
6
           (let ((unit (car m))
7
                 (bind (cdr m))
8
                 (mmap (mapM (car m) (cdr m))))
9-
             body))))))
9+
             body))))))
10
11
(define-syntax (doM x)
12
  (syntax-case x (<-)
13
    ((k e) #'e)
14
    ((k (v <- e) e* ...)
15
     (with-implicit (k bind)
16
       #'(bind e (lambda (v) (doM e* ...)))))))