7 Exploring Types
In addition to printing a summary of the types of REPL results, Typed Racket provides interactive utilities to explore and query types. The following bindings are only available at the Typed Racket REPL.
syntax
(:type maybe-verbose t)
maybe-verbose =
| #:verbose
If #:verbose is provided, all type aliases are expanded in the printed type.
> (:type Number)
(U Exact-Number Imaginary Inexact-Complex Real)
[can expand further: Exact-Number Inexact-Complex Imaginary Real]
> (:type Real)
(U Negative-Real Nonnegative-Real)
[can expand further: Negative-Real Nonnegative-Real]
> (:type #:verbose Number)
(U 0
1
Byte-Larger-Than-One
Exact-Complex
Exact-Imaginary
Float-Complex
Float-Imaginary
Float-Nan
Float-Negative-Zero
Float-Positive-Zero
Negative-Fixnum
Negative-Float-No-NaN
Negative-Integer-Not-Fixnum
Negative-Rational-Not-Integer
Negative-Single-Flonum-No-Nan
Positive-Fixnum-Not-Index
Positive-Float-No-NaN
Positive-Index-Not-Byte
Positive-Integer-Not-Fixnum
Positive-Rational-Not-Integer
Positive-Single-Flonum-No-Nan
Single-Flonum-Complex
Single-Flonum-Imaginary
Single-Flonum-Nan
Single-Flonum-Negative-Zero
Single-Flonum-Positive-Zero)
syntax
(:print-type e)
> (:print-type (+ 1 2)) Positive-Index
> (:print-type map)
(All (c a b ...)
(case->
(-> (-> a c) (Pairof a (Listof a)) (Pairof c (Listof c)))
(-> (-> a b ... b c) (Listof a) (Listof b) ... b (Listof c))))
syntax
(:query-type/args f t ...)
> (:query-type/args + Integer Number) (-> Integer Number Number)
syntax
(:query-type/result f t)
> (:query-type/result + Integer) (-> Integer * Integer)
> (:query-type/result + Float)
(case->
(-> Flonum Flonum * Flonum)
(-> Real Real Flonum Real * Flonum)
(-> Real Flonum Real * Flonum)
(-> Flonum Real Real * Flonum))