`(filter (λ (x) #f) '())` has type `(Listof Nothing)`, but `(List)` would be better
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
This is a small enhancement suggestion. The following expressions have type (Listof Nothing), but a more precise type would be (List).
#lang typed/racket
(filter (λ (x) #f) '())
(filter (λ (x) #f) '(a b c))
I'm not sure whether (Listof Nothing) can always be collapsed to (List).
A bigger example that should typecheck, but doesn't because of that:
(ann (if (null? (filter (λ (x) #f) '())) #t #f) True)
My apologies if this has already been discussed in the past, my searches did not bring up anything relevant.
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 by reproducing the two filter examples and the larger ann expression in Typed Racket. Investigate how empty lists and filter results are inferred, then add coverage showing that the examples typecheck with the more precise List type; done means the existing examples no longer produce the reported type error.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100