www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 93323091600ebf3db9a3fb92de82557ae493b2cc
parent 6f48690446305aa0667746984efed5e7f2fdacfc
Author: AlexKnauth <alexander@knauth.org>
Date:   Fri, 18 Mar 2016 23:25:44 -0400

propagate expected type through lambda

fixes https://bitbucket.org/stchang/macrotypes/issues/4

Diffstat:
Mtapl/mlish.rkt | 3+++
Mtapl/tests/mlish/inst.mlish | 11+++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/tapl/mlish.rkt b/tapl/mlish.rkt @@ -412,6 +412,9 @@ (define-typed-syntax liftedλ #:export-as λ [(_ (y:id x:id ...) . body) (type-error #:src stx #:msg "λ parameters must have type annotations")] + [(_ args body) + #:with (~∀ () (~ext-stlc:→ arg-ty ... body-ty)) (get-expected-type stx) + #`(Λ () (ext-stlc:λ args #,(add-expected-ty #'body #'body-ty)))] [(_ . rst) #'(Λ () (ext-stlc:λ . rst))]) diff --git a/tapl/tests/mlish/inst.mlish b/tapl/tests/mlish/inst.mlish @@ -61,3 +61,14 @@ (check-type alias-test2 : (→/test B (Read-Result B))) (check-type alias-test3 : (→/test B (Result (× B (List Char)) String))) (check-type alias-test3 : (→/test B (Read-Result B))) + +(define (expect-listof-int [loi : (List Int)] → Int) + 0) + +(check-type (expect-listof-int nil) : Int -> 0) + +(define (expect-→listof-int [f : (→ (List Int))] → Int) + 0) + +(check-type (expect-→listof-int (λ () nil)) : Int -> 0) +