Skip to content

variant to record #4307

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

Closed
4 tasks done
bobzhang opened this issue Apr 15, 2020 · 3 comments
Closed
4 tasks done

variant to record #4307

bobzhang opened this issue Apr 15, 2020 · 3 comments

Comments

@bobzhang
Copy link
Member

bobzhang commented Apr 15, 2020

  • no Blk_na
  • offending primitives:
    Obj.new_block, Obj.field, Obj.set_field, Obj.size, Obj.truncate
  • Blk_lazy
  • Oo.id/object_tag
    For ocaml objects, it is so dynamic that we have to compile it into array, _n indexing won't work since its size is created dynamically, we have to make sure for such field access is also compiled into array access
@sgrove
Copy link

sgrove commented Apr 15, 2020

Will this also cover polymorphic variants? Specifically, I'm trying to bind to some complex JS components that need them:

module Column = {
    [@bs.deriving abstract]
    type props = {
      [@bs.optional]
      align: [@bs.string] [ | `left | `right | `center],
    };
  }
}

But

align: [@bs.string] [ | `left | `right | `center]

doesn't work, which means writing a bunch of wrappers back and forth. Compiling flat polymorphic variants to strings (and respecting [@bs.as]) would make these much more ergonomic to use and lightweight at runtime.

@TheSpyder
Copy link
Contributor

@sgrove AFAIK this is based on #3801 which is only for non-polymorphic variants. A separate ticket (#4295) was opened last week regarding poly variant representation

@bobzhang
Copy link
Member Author

bobzhang commented Jun 1, 2020

done in master

@bobzhang bobzhang closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants