commit 95a7fb87f8e72a80675d99487eb1f554aedd1012 parent 9b171fd62ea20fe4bd077cf92553768e9847671b Author: AlexKnauth <alexander@knauth.org> Date: Mon, 2 May 2016 14:29:51 -0400 add ~?∀ for matching possibly polymorphic types Diffstat:
| M | tapl/mlish.rkt | | | 13 | ++++++++++++- |
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tapl/mlish.rkt b/tapl/mlish.rkt @@ -31,8 +31,19 @@ ;; - pattern matching ;; - (local) type inference - ;; type inference constraint solving (begin-for-syntax + ;; matching possibly polymorphic types + (define-syntax ~?∀ + (pattern-expander + (lambda (stx) + (syntax-case stx () + [(?∀ vars-pat body-pat) + #'(~or (~∀ vars-pat body-pat) + (~and (~not (~∀ _ _)) + (~parse vars-pat #'()) + body-pat))])))) + + ;; type inference constraint solving (define (compute-constraint τ1-τ2) (syntax-parse τ1-τ2 [(X:id τ) #'((X τ))]