Occurrence typing: Advanced filters (e.g. for `positive?`) kept secret
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
When looking at a function type, (some?) filters which can't be expressed with just : are not shown without warning, making it hard to understand how occurrence typing works. This is also not documented, so I'm not sure if there's any rationale, but I can only imagine verbosity or complexity of the signature.
However, such filters are never shown, even when using #:verbose, and I'm confident that's bad — how can I understand what the typechecker is doing if signatures are hidden?
Moreover, even if you want to hide part of a type by default, there should be some warning to the user. So for positive?, Typed Racket shouldn't show (-> Real Boolean) but sth. like (-> Real Boolean ...), and docs should explain that ... means "there's more you're not seeing". (No clue if ... is a decent idea as concrete syntax, you can figure that out).
> string?
- : (-> Any Boolean : String)
#<procedure:string?>
> positive?
- : (-> Real Boolean)
#<procedure:positive?>
> (:type (-> Real Boolean : #:+ Positive-Real #:- Nonpositive-Real))
(-> Real Boolean)
[can expand further: Boolean Real]
> (:type #:verbose (-> Real Boolean : #:+ Positive-Real #:- Nonpositive-Real))
(-> (U 0
1
Byte-Larger-Than-One
Positive-Index-Not-Byte
Positive-Fixnum-Not-Index
Negative-Fixnum
Positive-Integer-Not-Fixnum
Negative-Integer-Not-Fixnum
Positive-Rational-Not-Integer
Negative-Rational-Not-Integer
Float-Nan
Float-Positive-Zero
Float-Negative-Zero
Positive-Float-No-NaN
Negative-Float-No-NaN
Single-Flonum-Nan
Single-Flonum-Positive-Zero
Single-Flonum-Negative-Zero
Positive-Single-Flonum-No-Nan
Negative-Single-Flonum-No-Nan)
(U #f #t))
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the REPL examples for string? and positive?, comparing the default and #:verbose output for occurrence filters. Determine how advanced filters should be surfaced or warned about, then document the meaning of any hidden-filter notation and verify that the examples expose the relevant type information.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100