Fix time-apply, add test
svn: r12727
This commit is contained in:
parent
238b248ad5
commit
dd8e878cb4
17
collects/tests/typed-scheme/succeed/time.ss
Normal file
17
collects/tests/typed-scheme/succeed/time.ss
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#lang typed-scheme
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(: foo : Number Number -> Number)
|
||||||
|
(define (foo x y)
|
||||||
|
(* x y))
|
||||||
|
|
||||||
|
(: bar : Number -> Number)
|
||||||
|
(define (bar c)
|
||||||
|
(: loop : Number Number -> Number)
|
||||||
|
(define (loop n acc)
|
||||||
|
(if (< 0 n)
|
||||||
|
(loop (- n 1) (+ (foo c n) acc))
|
||||||
|
acc))
|
||||||
|
(loop 10000000 0))
|
||||||
|
(time (bar 0))
|
|
@ -245,8 +245,10 @@
|
||||||
|
|
||||||
[apply (-poly (a b) (((list) a . ->* . b) (-lst a) . -> . b))]
|
[apply (-poly (a b) (((list) a . ->* . b) (-lst a) . -> . b))]
|
||||||
[kernel:apply (-poly (a b) (((list) a . ->* . b) (-lst a) . -> . b))]
|
[kernel:apply (-poly (a b) (((list) a . ->* . b) (-lst a) . -> . b))]
|
||||||
[time-apply (-poly (a b) (((list) a . ->* . b) (-lst a)
|
[time-apply (-polydots (b a) (((list) (a a) . ->... . b)
|
||||||
. -> . (-values (list b N N N))))]
|
(-lst a)
|
||||||
|
. -> .
|
||||||
|
(-values (list (-pair b (-val '())) N N N))))]
|
||||||
|
|
||||||
[call/cc (-poly (a b) (((a . -> . (Un)) . -> . b) . -> . (*Un a b)))]
|
[call/cc (-poly (a b) (((a . -> . (Un)) . -> . b) . -> . (*Un a b)))]
|
||||||
[call/ec (-poly (a b) (((a . -> . (Un)) . -> . b) . -> . (*Un a b)))]
|
[call/ec (-poly (a b) (((a . -> . (Un)) . -> . b) . -> . (*Un a b)))]
|
||||||
|
|
|
@ -216,6 +216,14 @@
|
||||||
|
|
||||||
(define (-Tuple l)
|
(define (-Tuple l)
|
||||||
(foldr -pair (-val '()) l))
|
(foldr -pair (-val '()) l))
|
||||||
|
|
||||||
|
(define (untuple t)
|
||||||
|
(match t
|
||||||
|
[(Value: '()) null]
|
||||||
|
[(Pair: a b) (cond [(untuple b) => (lambda (l) (cons a l))]
|
||||||
|
[else #f])]
|
||||||
|
[_ #f]))
|
||||||
|
|
||||||
(define -box make-Box)
|
(define -box make-Box)
|
||||||
(define -vec make-Vector)
|
(define -vec make-Vector)
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
(prefix-in c: scheme/contract)
|
(prefix-in c: scheme/contract)
|
||||||
(for-syntax scheme/base)
|
(for-syntax scheme/base)
|
||||||
(for-template
|
(for-template
|
||||||
|
(only-in '#%kernel [apply k:apply])
|
||||||
"internal-forms.ss" scheme/base
|
"internal-forms.ss" scheme/base
|
||||||
(only-in scheme/private/class-internal make-object do-make-object)))
|
(only-in scheme/private/class-internal make-object do-make-object)))
|
||||||
(require (r:infer constraint-structs))
|
(require (r:infer constraint-structs))
|
||||||
|
@ -620,7 +621,7 @@
|
||||||
|
|
||||||
(define (tc/app/internal form expected)
|
(define (tc/app/internal form expected)
|
||||||
(kernel-syntax-case* form #f
|
(kernel-syntax-case* form #f
|
||||||
(values apply not list list* call-with-values do-make-object make-object cons
|
(values apply k:apply not list list* call-with-values do-make-object make-object cons
|
||||||
andmap ormap) ;; the special-cased functions
|
andmap ormap) ;; the special-cased functions
|
||||||
;; special case for delay
|
;; special case for delay
|
||||||
[(#%plain-app
|
[(#%plain-app
|
||||||
|
@ -680,6 +681,12 @@
|
||||||
;; if arg was a predicate application, we swap the effects
|
;; if arg was a predicate application, we swap the effects
|
||||||
[(tc-result: t thn-eff els-eff)
|
[(tc-result: t thn-eff els-eff)
|
||||||
(ret B (map var->type-eff els-eff) (map var->type-eff thn-eff))])]
|
(ret B (map var->type-eff els-eff) (map var->type-eff thn-eff))])]
|
||||||
|
[(#%plain-app k:apply . args)
|
||||||
|
(tc/app/internal #'(#%plain-app apply . args) expected)]
|
||||||
|
;; special-er case for (apply values (list x y z))
|
||||||
|
[(#%plain-app apply values e)
|
||||||
|
(cond [(untuple (tc-expr/t #'e)) => (lambda (t) (ret (-values t)))]
|
||||||
|
[else (tc/apply #'values #'(e))])]
|
||||||
;; special case for `apply'
|
;; special case for `apply'
|
||||||
[(#%plain-app apply f . args) (tc/apply #'f #'args)]
|
[(#%plain-app apply f . args) (tc/apply #'f #'args)]
|
||||||
;; special case for keywords
|
;; special case for keywords
|
||||||
|
|
Loading…
Reference in New Issue
Block a user