> On Oct 3, 2015, at 8:42 AM, Paolo Giarrusso <[email protected]> wrote:
> 
> Hi all!
> It seems to me that positive? is handled somehow specially by occurrence 
> typing, and that this is not documented but should be.
> 
> It appears to have a filter in practice, even the Typed Racket guide [1] 
> claims so in passing, but this filter is not visible in its type annotation, 
> compared e.g. to string?:
> 
>> string?
> - : (-> Any Boolean : String) ; <--- Note the filter annotation `: String`
> #<procedure:string?>
>> positive?
> - : (-> Real Boolean) ; <--- No filter annotation!
> #<procedure:positive?>
> 
> Therefore, I'm a bit confused by Sec. 5.3. I'm guessing that `positive?` has 
> a more complicated filter (it refines Real to Positive-Real, and Integer to 
> Positive-Integer), and that Sec. 5.2 is in fact oversimplified, but I failed 
> to find mention of filter or `positive?` in the Typed Racket reference [2].

It does have a filter, and it's slightly more complicated, but not too 
complicated:
https://github.com/racket/typed-racket/blob/aae17a0bc03de7c7aa2cfb3555838e456ad77e52/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt#L734
 
<https://github.com/racket/typed-racket/blob/aae17a0bc03de7c7aa2cfb3555838e456ad77e52/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt#L734>
It's the equivalent of (-> Real Boolean : #:+ Positive-Real #:- 
Nonpositive-Real).
This hiding is not specific to positive?, because:
(:type (-> Real Boolean : #:+ Positive-Real #:- Nonpositive-Real))
prints out
(-> Real Boolean)
[can expand further: Boolean Real]

> [1] http://docs.racket-lang.org/ts-guide/occurrence-typing.html
> [2] http://docs.racket-lang.org/search/index.html?q=T:ts-reference%20filter
> Also queried without results:
> T:ts-guide positive?
> T:ts-reference positive?
> 
> Instead, searching `T:ts-guide filter` leads me to the incomplete discussion 
> above.
> 
> Cheers,
> Paolo

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to