On this page:
λ:
do:
Un
mu
9.0
top
up

13Legacy FormsπŸ”— i

The following forms are provided by Typed Racket for backwards compatibility.

syntax

( lambda: formalsmaybe-ret. body)

maybe-ret =
| :type
formals = ([v:t]...)
| ([v:t]...v:t*)
| ([v:t]...v:tooobound)
A function of the formal arguments v, where each formal argument has the associated type. If a rest argument is present, then it has type (Listof t).

syntax

λ:

An alias for lambda: .

syntax

( plambda: (a...)formalsmaybe-ret. body)

(plambda: (a...booo)formalsmaybe-ret. body)
A polymorphic function, abstracted over the type variables a. The type variables a are bound in both the types of the formal, and in any type expressions in the body.

syntax

( opt-lambda: formalsmaybe-ret. body)

formals = ([v:t]...[v:tdefault]...)
| ([v:t]...[v:tdefault]...v:t*)
| ([v:t]...[v:tdefault]...v:tooobound)
A function with optional arguments.

syntax

( popt-lambda: (a...)formalsmaybe-ret. body)

(popt-lambda: (a...aooo)formalsmaybe-ret. body)
A polymorphic function with optional arguments.

syntax

case-lambda:

An alias for case-lambda .

syntax

( pcase-lambda: (a...)[formalsbody]...)

(pcase-lambda: (a...booo)[formalsbody]...)
A polymorphic function of multiple arities.

syntax

( let: ([v:te]...). body)

(let: loop:t0([v:te]...). body)
Local bindings, like let , each with associated types. In the second form, t0 is the type of the result of loop (and thus the result of the entire expression as well as the final expression in body). Type annotations are optional.

Examples:
> (:filter-even:(Listof Natural )(Listof Natural )-> (Listof Natural ))
> (define (filter-evenlstaccum)
(if (null? lst)
accum
(let: ([first :Natural (car lst)]
[rest :(Listof Natural )(cdr lst)])
(filter-evenrest (cons first accum))
(filter-evenrest accum)))))
> (filter-even(list 123456)null )

- : (Listof Nonnegative-Integer)

'(6 4 2)

Examples:
> (:filter-even-loop:(Listof Natural )-> (Listof Natural ))
> (define (filter-even-looplst)
(let: loop:(Listof Natural )
([accum:(Listof Natural )null ]
[lst:(Listof Natural )lst])
(cond
[(null? lst)accum]
[(even? (car lst))(loop(cons (car lst)accum)(cdr lst))]
[else (loopaccum(cdr lst))])))
> (filter-even-loop(list 1234))

- : (Listof Nonnegative-Integer)

'(4 2)

syntax

( plet: (a...)([v:te]...):t0. body)

A polymorphic version of let: , abstracted over the type variables a. The type variables a are bound in both the types of the formal, and in any type expressions in the body. Does not support the looping form of let.

syntax

( letrec: ([v:te]...). body)

syntax

( let*: ([v:te]...). body)

syntax

( let-values: ([([v:t]...)e]...). body)

syntax

( letrec-values: ([([v:t]...)e]...). body)

syntax

( let*-values: ([([v:t]...)e]...). body)

Type-annotated versions of letrec , let* , let-values , letrec-values , and let*-values . As with let: , type annotations are optional.

syntax

( let/cc: v:t. body)

syntax

( let/ec: v:t. body)

Type-annotated versions of let/cc and let/ec . As with let: , the type annotation is optional.

syntax

( define: v:te)

(define: (a...)v:te)
(define: (a...aooo)v:te)
(define: (f. formals):t. body)
(define: (a...)(f. formals):t. body)
(define: (a...aooo)(f. formals):t. body)
These forms define variables, with annotated types. The first form defines v with type t and value e. The second form does the same, but allows the specification of type variables. The third allows for polydotted variables. The fourth, fifth, and sixth forms define a function f with appropriate types. In most cases, use of : is preferred to use of define: .

Examples:
> (define: foo:Integer 10)
> (define: (A)mt-seq:(Sequenceof A)empty-sequence )
> (define: (A)(poly-app[func:(AA-> A)]
[first :A]
[rest :A]):A
(funcfirst rest ))

syntax

( define-struct/exec name-spec([f: t]...)[e: proc-t]maybe-type-name)

name-spec = name-id
| (name-idparent)
maybe-type-name =
| #:type-nametype-id
Equivalent to using define-struct to define a structure with the property prop:procedure supplied with the procedure e of type proc-t.

Changed in version 1.13 of package typed-racket-lib: Deprecated

Changed in version 1.4 of package typed-racket-lib: Added the #:type-name option.

syntax

struct:

An alias for struct .
An alias for define-struct .
An alias for define-struct/exec .

syntax

for:

An alias for for.

syntax

for*/and:

syntax

for*/first:

syntax

for*/fold:

syntax

for*/foldr:

syntax

for*/hash:

syntax

for*/hasheq:

syntax

for*/hasheqv:

syntax

for*/hashalw:

syntax

for*/last:

syntax

for*/list:

syntax

for*/lists:

syntax

for*/set:

syntax

for*/or:

syntax

for*/product:

syntax

for*/sum:

syntax

for*/vector:

syntax

for*:

syntax

for/and:

syntax

for/first:

syntax

for/flvector:

syntax

for/fold:

syntax

for/foldr:

syntax

for/hash:

syntax

for/hasheq:

syntax

for/hasheqv:

syntax

for/hashalw:

syntax

for/last:

syntax

for/list:

syntax

for/lists:

syntax

for/set:

syntax

for/or:

syntax

for/product:

syntax

for/sum:

syntax

for/vector:

Aliases for the same iteration forms without a :.

Changed in version 1.12 of package typed-racket-lib: Added for/foldr: and for*/foldr: .

syntax

do:

An alias for do .

Equivalent to define-type .
Equivalent to define-struct:
Similar to using the opaque keyword with require/typed .
Similar to using the struct keyword with require/typed .
Similar to require-typed-struct , but also provides the imported identifiers.

syntax

pdefine:

Defines a polymorphic function.

syntax

( pred t)

Equivalent to (Any -> Boolean : t).

type constructor

Un

An alias for U .

syntax

mu

An alias for Rec .

type constructor

Tuple

An alias for List .

type constructor

Parameter

An alias for Parameterof .

type constructor

Pair

An alias for Pairof .

type constructor

values

An alias for Values .

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /