[racket] handling curried functions in a 'define' macro

From: Matthew Butterick (mb at mbtype.com)
Date: Sat Feb 15 20:05:34 EST 2014

The macro noob (me) is experimenting with a macro that operates on define. I understand how to match the three common forms of define:

(define-syntax (define/foo stx)
  (syntax-case stx ()
    [(_ (name arg ... . rest-arg) body ...)
     #'(omitted)]
    [(_ (name arg ...) body ...)
     #'(omitted)]
    [(_ name body ...)
     #'(omitted)]))

But how do I handle curried function definitions? Since they can be nested to arbitrary depth, I'm puzzled. Is there a way to match them directly in syntax-case? Or do I need a preliminary step of converting them into the basic define form, like so:

(define/foo (((bar a) b) c)
  (+ a b c))

(define/foo bar
  (λ(a) (λ(b) (λ(c) (+ a b c)))))

... and then send them through the syntax-case I've already got.

Posted on the users mailing list.