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

eq does not derive equal for (anonymous) objects #271

Open
zbaylin opened this issue Nov 16, 2023 · 0 comments
Open

eq does not derive equal for (anonymous) objects #271

zbaylin opened this issue Nov 16, 2023 · 0 comments

Comments

@zbaylin
Copy link

zbaylin commented Nov 16, 2023

Example:

type t = < foo : int >
[@@deriving eq]

Expected behavior: An equality function for t is generated, i.e. something like:

let equal : t -> t -> bool = fun a b -> Int.equal a#foo b#foo

Actual behavior: The ppx gives the following error:

eq cannot be derived for < foo : int >

I use anonymous objects like these to simulate similar behavior with anonymous records in standard variants, i.e.

type variant =
  | Foo of {
    bar : int
  }

type poly = [ `Foo of < bar : int > ]

Is there a reason I can't think of that deriving equality functions for objects is non-trivial compared to records?

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

1 participant