Code Monkey home page Code Monkey logo

Comments (4)

josefs avatar josefs commented on July 25, 2024

@zuiderkwast, didn't we have a discussion about this? I think it was you who worked out that it was better to not throw away all the types in a union even if any is one of the types. I can't remember the argument for why this is a good idea. Do you remember?
The paper "The Recursive Union of Some Gradual Types" by Jeremy G. Siek and Sam Tobin-Hochstadt might talk about this. Unfortunately I haven't read that paper in detail yet (though I really should have!)

from gradualizer.

zuiderkwast avatar zuiderkwast commented on July 25, 2024

Yes, I implemented normalization of unions. We merge any non-any types but keep any separate. @josefs, you showed an example of this yourself during the demo in last Design Forum. The error message was something like integer() | any() is not a compatible subtype of non_neg_integer().

The reasoning was that a value of type integer() | any() can at least be any positive or negative integer. Apart from this, it can possibly also be a value of other types that we don't know.

We merge anything else, so for example integer() | 42 | any() = integer() | any().

from gradualizer.

gomoripeti avatar gomoripeti commented on July 25, 2024

just expanding on this, I think the optimisation only work one way.

(:: is compatible subtype).

  • t2() :: t1() | any() is equivalent with t2() :: any() (in this case union means t2() :: t1() OR t2() :: any())
  • but t1() | any() :: t2() is not equivalent with any() :: t2() (in this case union translates to t1() :: t2() AND any() :: t2()).

from gradualizer.

Zalastax avatar Zalastax commented on July 25, 2024

@gomoripeti I think that is what they say in "Fig. 8. Merge operator" of "The Recursive Union of Some Gradual Types" - don't hold me accountable though.

from gradualizer.

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.