Replace let+ example with match; add margin note about Rec
This commit is contained in:
parent
2b6d979481
commit
e70617bf26
|
@ -3,8 +3,7 @@
|
|||
@begin[(require "../utils.rkt"
|
||||
scribble/core scribble/eval
|
||||
(for-label (only-meta-in 0 typed/racket)
|
||||
(prefix-in base: racket)
|
||||
(only-in mzlib/etc let+)))]
|
||||
(prefix-in base: racket)))]
|
||||
|
||||
@title[#:tag "more"]{Specifying Types}
|
||||
|
||||
|
@ -108,11 +107,14 @@ applied to a single variable using a reader extension:
|
|||
|
||||
This is equivalent to the earlier use of @racket[let]. This is
|
||||
mostly useful for binding forms which do not have counterparts
|
||||
provided by Typed Racket, such as @racket[let+]:
|
||||
provided by Typed Racket, such as @racket[match]:
|
||||
|
||||
@racketblock[
|
||||
(let+ ([val #,(annvar x Number) (+ 6 1)])
|
||||
(* x x))]
|
||||
(: assert-symbols! ((Listof Any) -> (Listof Symbol)))
|
||||
(define (assert-symbols! lst)
|
||||
(match lst
|
||||
[(list (? symbol? #,(annvar s (Listof Symbol))) ...) s]
|
||||
[_ (error "expected only symbols, given" lst)]))]
|
||||
|
||||
@subsection{Annotating Expressions}
|
||||
|
||||
|
|
|
@ -123,6 +123,10 @@ unions are flattened.
|
|||
themselves. This allows a type to describe an infinite family
|
||||
of data. For example, this is the type of binary trees of numbers.
|
||||
|
||||
@margin-note[]{
|
||||
Recursive types can also be created anonymously without the use of
|
||||
@racket[define-type] using the @racket[Rec] type constructor.}
|
||||
|
||||
@racketblock[
|
||||
(define-type BinaryTree (U Number (Pair BinaryTree BinaryTree)))]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user