Make naturals be a sequence type.

This commit is contained in:
Eric Dobson 2013-02-14 09:43:36 -08:00
parent 4f9f00680e
commit 18d90115e7
3 changed files with 50 additions and 0 deletions

View File

@ -170,6 +170,16 @@
[(-HT t1 t2) (-HT t2 t1)]
[(make-Prompt-Tagof t1 t2) (make-Prompt-Tagof t2 t1)]
[(make-Continuation-Mark-Keyof t1) (make-Continuation-Mark-Keyof t2)]
[(-val 5) (-seq -Nat)]
[(-val 5) (-seq -Byte)]
[-Index (-seq -Index)]
[-NonNegFixnum (-seq -NonNegFixnum)]
[-Index (-seq -Nat)]
[FAIL (-val -5) (-seq -Nat)]
[FAIL -Fixnum (-seq -Fixnum)]
[FAIL -NonNegFixnum (-seq -Index)]
[FAIL (-val 5.0) (-seq -Nat)]
))
(define-go

View File

@ -470,6 +470,26 @@
(cg -Nat t*)]
[((Base: 'Input-Port _ _ _ _) (Sequence: (list t*)))
(cg -Nat t*)]
[((Value: (? exact-nonnegative-integer? n)) (Sequence: (list t*)))
(define possibilities
(list
(list byte? -Byte)
(list portable-index? -Index)
(list portable-fixnum? -NonNegFixnum)
(list values -Nat)))
(define type
(for/or ((pred-type possibilities))
(match pred-type
((list pred? type)
(and (pred? n) type)))))
(cg type t*)]
[((Base: _ _ _ _ #t) (Sequence: (list t*)))
(define type
(for/or ((t (list -Byte -Index -NonNegFixnum -Nat)))
(and (subtype S t) t)))
(if type
(cg type t*)
(fail! S T))]
[((Vector: t) (Sequence: (list t*)))
(cg t t*)]
[((Hashtable: k v) (Sequence: (list k* v*)))

View File

@ -297,6 +297,26 @@
(subtype* A0 -Byte t*)]
[((Base: 'Input-Port _ _ _ _) (Sequence: (list t*)))
(subtype* A0 -Nat t*)]
[((Value: (? exact-nonnegative-integer? n)) (Sequence: (list t*)))
(define possibilities
(list
(list byte? -Byte)
(list portable-index? -Index)
(list portable-fixnum? -NonNegFixnum)
(list values -Nat)))
(define type
(for/or ((pred-type possibilities))
(match pred-type
((list pred? type)
(and (pred? n) type)))))
(subtype* A0 type t*)]
[((Base: _ _ _ _ #t) (Sequence: (list t*)))
(define type
(for/or ((t (list -Byte -Index -NonNegFixnum -Nat)))
(and (subtype s t) t)))
(if type
(subtype* A0 type t*)
(fail! s t))]
[((Hashtable: k v) (Sequence: (list k* v*)))
(subtypes* A0 (list k v) (list k* v*))]
[((Set: t) (Sequence: (list t*)))