Skip to content

Commit 97711ff

Browse files
committed
doc: add a margin note to show that (andmap string ...) works
This is a follow up of #1345. Thanks to @capfredf for the improvement suggestion.
1 parent d1ba049 commit 97711ff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

typed-racket-doc/typed-racket/scribblings/guide/occurrence.scrbl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Intuitively, a value that satisfies the predicate must have type
101101
(andmap string? lst))
102102
]
103103

104-
We then may wish to use this predicate to narrow a type in our main program:
104+
We then may wish to use this predicate to narrow a type in the @racket[main] function:
105105

106106
@examples[#:label #f #:eval the-eval*
107107
(: main (-> (Listof Any) String))
@@ -112,16 +112,21 @@ We then may wish to use this predicate to narrow a type in our main program:
112112
]
113113

114114
Unfortunately, Typed Racket fails to narrow the type, because we did not specify
115-
a proposition for @racket[listof-string?]. To fix this issue, we include
116-
the proposition in the @racket[->] form for @racket[listof-string].
115+
a proposition for @racket[listof-string?].@margin-note*{
116+
Note that if we directly use @racket[(andmap string? lst)] as the conditional expression,
117+
@racket[main] would be successfully type-checked,
118+
because @racket[andmap] and @racket[string?] do provide propositions
119+
that allow Typed Racket to narrow the type.
120+
} To fix this issue, we include
121+
the proposition in the @racket[->] form for @racket[listof-string?].
117122

118123
@examples[#:no-result #:eval the-eval
119124
(: listof-string? (-> (Listof Any) Boolean : (Listof String)))
120125
(define (listof-string? lst)
121126
(andmap string? lst))
122127
]
123128

124-
With the proposition, Typed Racket successfully type-checks our main program.
129+
With the proposition, Typed Racket successfully type-checks @racket[main].
125130

126131
@examples[#:label #f #:eval the-eval
127132
(: main (-> (Listof Any) String))

0 commit comments

Comments
 (0)