Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Records lose information in type constructors #125

Open
j14159 opened this issue Feb 6, 2017 · 0 comments
Open

Records lose information in type constructors #125

j14159 opened this issue Feb 6, 2017 · 0 comments

Comments

@j14159
Copy link
Collaborator

j14159 commented Feb 6, 2017

Consider the following:

type t = T {x: int}

let make_t_with_xy = T {x=1, y=2}

let main () =
  let example_t = make_t_with_xy in
  match example_t with
    T rec -> rec  -- rec loses y: int

This information loss occurs because type constructors don't carry any information about their arguments - they're used only to make type arrows that instantiate their parent type. This means that even though T {x=1, y=2} keeps the y: int in its row variable, going from T rec has no access to it. I think there are a couple of possibilities to solve this:

  • package type information with type constructors. How this gets propagated to the type might get really messy.
  • synthesize ADT type variables for the row variable in each record that exists in an ADT.

I think the latter is somewhat tractable but the larger question I have is: should we bother? Is preserving this information desirable? I suspect it is purely for consistency's sake but am curious as to others' opinions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant