Comments (2)
I started taking a look at this yesterday, and part of the problem is what the actual type of cadr is in TR versus what you could reasonably expect. TR is currently taking the approach that type for cadr
and friends only have logical information if there is no possibility of failure at runtime (i.e the pair structure is correct), but that it is also fine to apply it to a (Listof a)
. In your example r
is not necessarily of the right structure because the inner (Listof (U String False))
could be null. Thus there is no logical information for the if to enhance the environment on. I believe this is easily fixable in some cases (which would cover this case).
The tricky cases are cadr
applied to a value of the type (Pair A (Listof B))
, which would currently return (U A B)
. So the question in these cases is what are the exact runtime failures that we allow to be not ruled out by the type? My thought is that it should be that if the runtime value that we need to be a cons-cell is null, then it should be allowed by the type.
The second issue is that inference doesn't take the object environment into account. So if we have x : (Listof (U False String))
and we know that car @ x
has type String
, then we still cannot infer type variables for car
such that it returns a String
in the expression (car x)
, but ((inst car String Any) x
will work because typechecking does use the object environment.
from typed-racket.
I have an in-progress pull request that I think solves the first part (fixing the types for cadr
etc) here: #15
But it doesn't currently pass the tests due to a type inference limitation. Also my PR probably doesn't the second issue you point out.
from typed-racket.
Related Issues (20)
- The typed version of racket/fixnum doesn't provide the popcount functions.
- input-port-append doesn't work in TR
- for loop fails to infer subtype.
- Examples of unexpected behavior for integer refinements
- `AnyValues` in `let/cc` is unbound.
- The `Nothing` type causes the type checker not to check the type. HOT 2
- struct #:mutable field option
- any-wrap: avoid wrapping immutable structs with immutable fields HOT 3
- Strange lack of subtyping for `case->` HOT 1
- Constructors in `typed/web-server/http` not provided
- Weird Error Message from `require/typed`
- apply < doesn't accept a non-empty list
- `check-eq? (hasheq) (hasheq)` fails HOT 4
- TR unsound with keyword args HOT 2
- `struct`'s `#:methods` missing in Typed Racket HOT 3
- The new hash match pattern doesn't work in Typed Racket
- type mismatch when using `Float`s with `for/sum` HOT 1
- `require/typed/provide` not providing constructors
- `require/typed` yields "unused require" warnings
- TR fails to typecheck when using optional arg and inline type specs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typed-racket.