minimatch: add match-lambda

This commit is contained in:
Ryan Culpepper 2018-07-25 14:51:42 +02:00
parent 34e7c8f556
commit 8a4bab5c3e

View File

@ -1,6 +1,18 @@
#lang racket/base #lang racket/base
(require (for-syntax racket/base racket/struct-info)) (require (for-syntax racket/base racket/struct-info))
(provide match ?) (provide match match-lambda ?)
(define-syntax (match-lambda stx)
(syntax-case stx ()
[(match-lambda clause ...)
#`(lambda (x)
(match-c x
clause ...
[_ (error 'minimatch-lambda "match at ~s:~s:~s failed: ~e"
'#,(syntax-source stx)
'#,(syntax-line stx)
'#,(syntax-column stx)
x)]))]))
(define-syntax (match stx) (define-syntax (match stx)
(syntax-case stx () (syntax-case stx ()