Add unstable/match with == match expander.

Add 'match expander' tech def.

svn: r16814

original commit: 0ae5843f1163a247f776b47ac29e38e31664bc03
This commit is contained in:
Sam Tobin-Hochstadt 2009-11-16 16:58:11 +00:00
parent 40c53e2191
commit 9dbe7c808f
5 changed files with 18 additions and 13 deletions

View File

@ -2,11 +2,11 @@
(require "../utils/utils.ss")
(require mzlib/struct
mzlib/plt-match
scheme/match
syntax/boundmap
"free-variance.ss"
"interning.ss"
unstable/syntax
unstable/syntax unstable/match
mzlib/etc
scheme/contract
(for-syntax

View File

@ -33,7 +33,7 @@
[i:boolean (-val (syntax-e #'i))]
[i:identifier (-val (syntax-e #'i))]
[i:exact-integer -Integer]
[i:number -Number]
[(~var i (3d real?)) -Number]
[i:str -String]
[i:char -Char]
[i:keyword (-val (syntax-e #'i))]

View File

@ -6,7 +6,7 @@
[->* -->*]
[one-of/c -one-of/c])
(rep type-rep)
scheme/contract scheme/match
scheme/contract scheme/match unstable/match
(for-syntax scheme/base))
(provide combine-filter apply-filter abstract-filter abstract-filters

View File

@ -11,7 +11,7 @@ at least theoretically.
scheme/pretty mzlib/pconvert syntax/parse)
;; to move to unstable
(provide == debug reverse-begin)
(provide debug reverse-begin)
(provide
;; timing
@ -140,14 +140,6 @@ at least theoretically.
(printf "Timing ~a at ~a@~a~n" msg diff t)))]))
(values (lambda _ #'(void)) (lambda _ #'(void)))))
(define-match-expander
==
(lambda (stx)
(syntax-case stx ()
[(_ val)
#'(? (lambda (x) (equal? val x)))])))
;; custom printing
;; this requires lots of work for two reasons:
;; - 1 printers have to be defined at the same time as the structs

View File

@ -0,0 +1,13 @@
#lang scheme/base
(require scheme/match (for-syntax scheme/base))
(provide ==)
(define-match-expander
==
(lambda (stx)
(syntax-case stx ()
[(_ val comp)
#'(? (lambda (x) (comp val x)))]
[(_ val) #'(== val equal?)])))