From 95a7fb87f8e72a80675d99487eb1f554aedd1012 Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Mon, 2 May 2016 14:29:51 -0400 Subject: [PATCH] =?UTF-8?q?add=20~=3F=E2=88=80=20for=20matching=20possibly?= =?UTF-8?q?=20polymorphic=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tapl/mlish.rkt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tapl/mlish.rkt b/tapl/mlish.rkt index b103a17..10b93e7 100644 --- 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 τ))]