Code Monkey home page Code Monkey logo

Comments (4)

LPTK avatar LPTK commented on May 29, 2024

Related JS-gen issue: #65 (comment)

from mlscript.

LPTK avatar LPTK commented on May 29, 2024

I realize the right way of doing this is to change the way field removal types act on tuples (and arrays).

Currently it leaves tuples untouched:

case _: TypeVariable | _: ClassTag | _: RecordType => rw

We should add a field in TupleType and ArrayType to remember which fields have been hidden by a Without type applied on such types.

(Cc @Meowcolm024.)

from mlscript.

LPTK avatar LPTK commented on May 29, 2024

Another improvement request: properly reason about intersected tuple-record types, as mentioned in #79 (comment).

For example:

def test: (string, 1) & { _1: "hello" }
//│ test: (string, 1,) & {_1: "hello", _2: 1}

The above should simplify to test: ("hello", 1,).

Moreover in:

test: { _1: 'a }
//│ res: {_1: "hello"}

test: ('a, 1)
//│ res: (string, 1,)

I would have expected to get type ("hello", 1,) for the latter.

Similarly, the following could "simplify" to res: Array[1] & {_1: 1}:

error: Array[1] & { _1: int }
//│ res: Array[1] & {_1: int}

from mlscript.

LPTK avatar LPTK commented on May 29, 2024

I realize the right way of doing this is to change the way field removal types act on tuples (and arrays).

Note: To make things simpler, we didn't go with this approach. Instead, we just convert these types to records upon removing fields from them, which is not optimal ((1, 2) with {_1 = 3} is typed as {_1: 3, _2: 2} whereas it could be typed as (3, 2)), but probably sufficient for now.

from mlscript.

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.