Add FxVector type to Typed Racket
The `for` forms for fxvectors are future work original commit: 6791b322ec8dedf7cc2d00aca4aa12df4d0567c2
This commit is contained in:
parent
8b46b0199a
commit
95afd01fde
|
@ -6,7 +6,8 @@
|
|||
@(define the-eval (make-base-eval))
|
||||
@(the-eval '(require (except-in typed/racket #%top-interaction #%module-begin)))
|
||||
@(define the-top-eval (make-base-eval))
|
||||
@(the-top-eval '(require (except-in typed/racket #%module-begin)))
|
||||
@(the-top-eval '(require (except-in typed/racket #%module-begin)
|
||||
racket/flonum racket/fixnum))
|
||||
|
||||
@(define-syntax-rule (ex . args)
|
||||
(examples #:eval the-top-eval . args))
|
||||
|
@ -322,11 +323,15 @@ corresponding to @racket[trest], where @racket[bound]
|
|||
|
||||
@defform[(Vectorof t)]{Homogenous @rtech{vectors} of @racket[t]}
|
||||
@defform[(Vector t ...)]{is the type of the list with one element, in order,
|
||||
for each type provided to the @racket[Vector] type constructor.}
|
||||
@defidform[FlVector]{An @rtech{flvector}.}
|
||||
for each type provided to the @racket[Vector] type constructor.
|
||||
|
||||
@ex[(vector 1 2 3)
|
||||
#(a b c)]
|
||||
@ex[(vector 1 2 3)
|
||||
#(a b c)]}
|
||||
|
||||
@defidform[FlVector]{An @rtech{flvector}.
|
||||
@ex[(flvector 1.0 2.0 3.0)]}
|
||||
@defidform[FxVector]{An @rtech{fxvector}.
|
||||
@ex[(fxvector 1 2 3)]}
|
||||
|
||||
@defidform[VectorTop]{is the type of a @rtech{vector} with unknown length and
|
||||
element types and is the supertype of all vector types.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(require
|
||||
"../utils/utils.rkt"
|
||||
(for-template racket/base racket/list racket/unsafe/ops racket/flonum)
|
||||
(for-template racket/base racket/list racket/unsafe/ops racket/flonum racket/fixnum)
|
||||
(utils tc-utils)
|
||||
(rename-in (types union abbrev numeric-tower) [-Number N] [-Boolean B] [-Symbol Sym]))
|
||||
|
||||
|
@ -287,6 +287,23 @@
|
|||
(-> -FlVector -Fixnum -Flonum -Void)
|
||||
(-> -FlVector index-type -Flonum -Void))]
|
||||
|
||||
;; Section 4.2.4.2 (Fixnum vectors)
|
||||
[fxvector? (make-pred-ty -FxVector)]
|
||||
[fxvector (->* (list) -Fixnum -FxVector)]
|
||||
[make-fxvector (cl->* (-> index-type -FxVector)
|
||||
(-> index-type -Fixnum -FxVector))]
|
||||
|
||||
[fxvector-length (-> -FxVector -Index)]
|
||||
[fxvector-ref (cl->* (-> -FxVector -NonNegFixnum -Fixnum)
|
||||
(-> -FxVector -Fixnum -Fixnum)
|
||||
(-> -FxVector index-type -Fixnum))]
|
||||
[fxvector-set! (cl->* (-> -FxVector -NonNegFixnum -Fixnum -Void)
|
||||
(-> -FxVector -Fixnum -Fixnum -Void)
|
||||
(-> -FxVector index-type -Fixnum -Void))]
|
||||
[fxvector-copy (cl->* (-> -FxVector -FxVector)
|
||||
(-> -FxVector index-type -FxVector)
|
||||
(-> -FxVector index-type index-type -FxVector))]
|
||||
|
||||
|
||||
[bytes-ref (-> -Bytes index-type -Byte)]
|
||||
[unsafe-bytes-ref (-> -Bytes index-type -Byte)]
|
||||
|
|
|
@ -151,6 +151,7 @@
|
|||
[Listof -Listof]
|
||||
[Vectorof (-poly (a) (make-Vector a))]
|
||||
[FlVector -FlVector]
|
||||
[FxVector -FxVector]
|
||||
[Option (-poly (a) (-opt a))]
|
||||
[HashTable (-poly (a b) (-HT a b))]
|
||||
[Promise (-poly (a) (-Promise a))]
|
||||
|
|
|
@ -26,11 +26,13 @@
|
|||
(only-in racket/udp udp?)
|
||||
(only-in racket/tcp tcp-listener?)
|
||||
(only-in racket/flonum flvector?)
|
||||
(only-in racket/fixnum fxvector?)
|
||||
(only-in '#%place place? place-channel?))
|
||||
(only-in racket/pretty pretty-print-style-table?)
|
||||
(only-in racket/udp udp?)
|
||||
(only-in racket/tcp tcp-listener?)
|
||||
(only-in racket/flonum flvector?)
|
||||
(only-in racket/fixnum fxvector?)
|
||||
(only-in '#%place place? place-channel?))
|
||||
|
||||
(provide (except-out (all-defined-out) make-Base)
|
||||
|
@ -141,6 +143,7 @@
|
|||
(define/decl -TCP-Listener (make-Base 'TCP-Listener #'tcp-listener? tcp-listener?))
|
||||
(define/decl -UDP-Socket (make-Base 'UDP-Socket #'udp? udp?))
|
||||
(define/decl -FlVector (make-Base 'FlVector #'flvector? flvector?))
|
||||
(define/decl -FxVector (make-Base 'FxVector #'fxvector? fxvector?))
|
||||
(define -Syntax make-Syntax)
|
||||
(define/decl In-Syntax
|
||||
(-mu e
|
||||
|
|
|
@ -1961,6 +1961,16 @@
|
|||
-Void]
|
||||
[tc-e (place-message-allowed? 'msg) -Boolean]
|
||||
|
||||
;; fxvectors
|
||||
[tc-e (let ()
|
||||
(define fx1 (fxvector 0 500 34))
|
||||
(define fx2 (make-fxvector 20 3))
|
||||
(fx+ (fxvector-ref fx1 0) 2)
|
||||
(fxvector-set! fx2 1 5)
|
||||
(fxvector-length fx1)
|
||||
(fxvector-copy fx2 0 5))
|
||||
-FxVector]
|
||||
|
||||
;; for/hash, for*/hash - PR 14306
|
||||
[tc-e (for/hash: : (HashTable Symbol String)
|
||||
([x (in-list '(x y z))]
|
||||
|
|
Loading…
Reference in New Issue
Block a user