Don't special case typechecking of =.
Its type is more useful than the special typing rule.
This commit is contained in:
parent
9e8cc6af3c
commit
568f401bdc
6
collects/tests/typed-racket/succeed/num-equal-filter.rkt
Normal file
6
collects/tests/typed-racket/succeed/num-equal-filter.rkt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#lang typed/racket
|
||||||
|
|
||||||
|
(: f : Nonnegative-Integer -> Boolean)
|
||||||
|
(define (f x)
|
||||||
|
(cond [(= 0 x) #t]
|
||||||
|
[else (f (sub1 x))])) ; here, x is Positive-Integer
|
|
@ -19,9 +19,10 @@
|
||||||
(export tc-app-eq^)
|
(export tc-app-eq^)
|
||||||
|
|
||||||
;; comparators that inform the type system
|
;; comparators that inform the type system
|
||||||
|
;; `=' is not included. Its type is more useful than this typing rule.
|
||||||
(define-syntax-class comparator
|
(define-syntax-class comparator
|
||||||
#:literals (eq? equal? eqv? = string=? symbol=? memq member memv)
|
#:literals (eq? equal? eqv? string=? symbol=? memq member memv)
|
||||||
(pattern eq?) (pattern equal?) (pattern eqv?) (pattern =) (pattern string=?) (pattern symbol=?)
|
(pattern eq?) (pattern equal?) (pattern eqv?) (pattern string=?) (pattern symbol=?)
|
||||||
(pattern member) (pattern memq) (pattern memv))
|
(pattern member) (pattern memq) (pattern memv))
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
(define-syntax-rule (alt nm pred ...)
|
(define-syntax-rule (alt nm pred ...)
|
||||||
(and (free-identifier=? #'nm comparator) (or (pred val) ...)))
|
(and (free-identifier=? #'nm comparator) (or (pred val) ...)))
|
||||||
(or (alt symbol=? symbol?)
|
(or (alt symbol=? symbol?)
|
||||||
(alt string=? string?)
|
(alt string=? string?)
|
||||||
(alt eq? eq?-able)
|
(alt eq? eq?-able)
|
||||||
(alt eqv? eqv?-able)
|
(alt eqv? eqv?-able)
|
||||||
(alt equal? equal?-able)))
|
(alt equal? equal?-able)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user