@@ -101,7 +101,7 @@ Intuitively, a value that satisfies the predicate must have type
101
101
(andmap string? lst))
102
102
]
103
103
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 :
105
105
106
106
@examples[#:label #f #:eval the-eval*
107
107
(: main (-> (Listof Any) String))
@@ -112,16 +112,21 @@ We then may wish to use this predicate to narrow a type in our main program:
112
112
]
113
113
114
114
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?].
117
122
118
123
@examples[#:no-result #:eval the-eval
119
124
(: listof-string? (-> (Listof Any) Boolean : (Listof String)))
120
125
(define (listof-string? lst)
121
126
(andmap string? lst))
122
127
]
123
128
124
- With the proposition, Typed Racket successfully type-checks our main program .
129
+ With the proposition, Typed Racket successfully type-checks @racket[ main] .
125
130
126
131
@examples[#:label #f #:eval the-eval
127
132
(: main (-> (Listof Any) String))
0 commit comments