Check number of type errors.

This commit is contained in:
Sam Tobin-Hochstadt 2008-06-24 14:05:24 -04:00
parent d7cf0a10c0
commit 97c5444b88
4 changed files with 26 additions and 5 deletions

View File

@ -0,0 +1,17 @@
#;
(exn-pred 3)
#lang typed-scheme
(: map-with-funcs (All (b a ...) ((a ... a -> b) * -> (a ... a -> (Listof b)))))
(define (map-with-funcs . fs)
(lambda as
(map (lambda: ([f : (a ... a -> b)])
(apply f as))
fs)))
(ann (map-with-funcs + - * /) (Number Number * -> (Listof Integer)))
(ann (map-with-funcs + - * /) (Number * -> (Listof Number)))
(ann (map-with-funcs + - * /) (Integer * -> (Listof Number)))

View File

@ -1,3 +1,5 @@
#;
(exn-pred 2)
#lang typed-scheme #lang typed-scheme
(plambda: (a ...) ([z : String] . [w : Number *]) (plambda: (a ...) ([z : String] . [w : Number *])

View File

@ -20,10 +20,12 @@
(lambda (val) (lambda (val)
(and (exn? val) (and (exn? val)
(for/and ([e args]) (for/and ([e args])
(if (procedure? e) (cond [(procedure? e) (e val)]
(e val) [(number? e)
(begin (and (exn:fail:syntax? val)
(regexp-match e (exn-message val))))))) (= e (length (exn:fail:syntax-exprs val))))]
[(or (string? e) (regexp? e) (bytes? e))
(regexp-match e (exn-message val))]))))
args)) args))
(define (exn-pred p) (define (exn-pred p)

View File

@ -8,4 +8,4 @@
(apply f as)) (apply f as))
fs))) fs)))
(ann (map-with-funcs + - * /) (Integer Integer * -> (Listof Number))) (ann (map-with-funcs + - * /) (Number Number * -> (Listof Number)))