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

heterogeneous physical equality for references #7428

Closed
vicuna opened this issue Dec 6, 2016 · 2 comments
Closed

heterogeneous physical equality for references #7428

vicuna opened this issue Dec 6, 2016 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Dec 6, 2016

Original bug ID: 7428
Reporter: Christophe Raffalli
Assigned to: @gasche
Status: resolved (set by @gasche on 2016-12-06T18:24:44Z)
Resolution: duplicate
Priority: normal
Severity: feature
Version: 4.04.0
Category: standard library
Duplicate of: #7425

Bug description

I would like the following (or equivalent) to be added somewhere
in the stdlib. This sound type safe and sometimes very useful,
by avoiding a runtime representation of the type.


type ('a,'b) eq = Eq : ('a, 'a) eq | Neq : ('a, 'b) eq

let (===) : type a b.a ref -> b ref -> (a,b) eq = fun r1 r2 ->
if Obj.repr r1 == Obj.repr r2 then Obj.magic Eq else Neq

@vicuna
Copy link
Author

vicuna commented Dec 6, 2016

Comment author: @alainfrisch

Do you have some concrete examples where this could be used?

@vicuna
Copy link
Author

vicuna commented Dec 6, 2016

Comment author: @gasche

Could we keep discussing this in 7425 where the discussion started? I can rename the other ticket with a more explicit name for the current discussion if you think that is helpful.

#7425

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