Code Monkey home page Code Monkey logo

Comments (2)

endobson avatar endobson commented on June 3, 2024

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.

takikawa avatar takikawa commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.