propagate expected type through lambda

fixes https://bitbucket.org/stchang/macrotypes/issues/4
This commit is contained in:
AlexKnauth 2016-03-18 23:25:44 -04:00
parent 6f48690446
commit 9332309160
2 changed files with 14 additions and 0 deletions

View File

@ -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))])

View File

@ -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)