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

Open Objects example lacks explanation #540

Open
lxsmnsyc opened this issue May 10, 2019 · 0 comments
Open

Open Objects example lacks explanation #540

lxsmnsyc opened this issue May 10, 2019 · 0 comments

Comments

@lxsmnsyc
Copy link

For example, in the Open Objects example

type tesla('a) = {
  ..
  drive: int => int
} as 'a;

The tutorial does not explain:

  • What the alias does or does it affect all generics with the same keyword as the alias.
  • How to implement an open object generics
  • How to implement an open object interface

It also needs an example where an open object accepts another open object as a parameter, similar to this:

type a('a) = {
  ..
  myAMethod: unit => unit
} as 'a;

type b('b, 'a) = {
  ..
  /* some implementation that uses the generic */
} as 'a

I found this a problem when I was writing Reaxon, specially with this kind of types:

type subscription = Cancellable.Boolean.i;

type observer('observer, 'a) = {
  ..
  onSubscribe: subscription => unit,
  onSuccess: 'a => unit,
  onError: exn => unit,
} as 'observer;


type t('observer,'a) = {
  .
  subscribeWith: observer('observer, 'a) => unit,
};
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

2 participants