define functions differently

This commit is contained in:
Sam Caldwell 2018-08-13 19:32:23 -04:00 committed by Sam Caldwell
parent cabb4e2e7c
commit 5104677fc6
1 changed files with 10 additions and 5 deletions

View File

@ -906,8 +906,9 @@
#`(k #,(loop #'p))] #`(k #,(loop #'p))]
[(bind x:id τ) [(bind x:id τ)
#'x] #'x]
;; not sure about this
[discard [discard
#'_] #'discard]
[(~constructor-exp ctor p ...) [(~constructor-exp ctor p ...)
(define/with-syntax uctor (untyped-ctor #'ctor)) (define/with-syntax uctor (untyped-ctor #'ctor))
#`(ctor #,@(stx-map loop #'(p ...)))] #`(ctor #,@(stx-map loop #'(p ...)))]
@ -1033,10 +1034,14 @@
#:with x- (generate-temporary #'x) #:with x- (generate-temporary #'x)
-------- --------
[ (define/intermediate x x- τ e-) ( : ★/t)]] [ (define/intermediate x x- τ e-) ( : ★/t)]]
;; TODO - not sure how to get this to work with effects [(_ (f [x (~optional (~datum :)) ty] ...
;; right now `ann` forces the body to be pure (~or (~datum ) (~datum ->)) ty_out)
[(_ (f [x (~optional (~datum :)) ty] ... (~or (~datum ) (~datum ->)) ty_out) e ...+) e ...+)
[ (lambda ([x : ty] ...) (ann (begin e ...) : ty_out)) e- ( : fun-ty)] [ (lambda ([x : ty] ...) (begin e ...)) e- ( : (~and fun-ty
(~Computation (~Value τ-v)
_ ...)))]
#:fail-unless (<: #'τ-v #'ty_out)
(format "expected different return type, got ~a" (type->str #'τ-v))
#:with f- (add-orig (generate-temporary #'f) #'f) #:with f- (add-orig (generate-temporary #'f) #'f)
-------- --------
[ (define/intermediate f f- fun-ty e-) ( : ★/t)]]) [ (define/intermediate f f- fun-ty e-) ( : ★/t)]])