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

Create GCoercible class, analogous to GEq #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ericson2314
Copy link
Contributor

@Ericson2314 Ericson2314 commented Apr 9, 2022

No description provided.

@Ericson2314 Ericson2314 force-pushed the gcoercible branch 2 times, most recently from 8509f8a to 2915e7b Compare April 9, 2022 19:23
@Ericson2314 Ericson2314 changed the title Add GCoercible --- contains #45 Create GCoercible class, analogous to GEq --- contains #45 Apr 9, 2022
@Ericson2314 Ericson2314 force-pushed the gcoercible branch 2 times, most recently from 46e2be8 to 6570a3a Compare May 18, 2022 13:56
It could be a superclass of `GEq`, but this would be a breaking change
and interferes with Safe Haskell, so we refrained from making it one.
@Ericson2314 Ericson2314 changed the title Create GCoercible class, analogous to GEq --- contains #45 Create GCoercible class, analogous to GEq Oct 1, 2022
@Ericson2314 Ericson2314 marked this pull request as ready for review October 1, 2022 18:12
gcoercible (InR x) (InR y) = gcoercible x y
gcoercible _ _ = Nothing

instance (GCoercible a, GCoercible b) => GCoercible (Product a b) where
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird (also in existing GEq instance. Either side would be enough, won't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? It is possible for one to fail and the other to succeed, is it not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For TestEquality yes only one is sufficient.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was thinking of TestEquality, and it doesn't seem to have instance for Product so all is fine.

(btw, that's another point not to have TestEquality as a super-class for GEq).

return Coercion

instance GCoercible IORef where
gcoercible x y =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be more welcome to add this and STRef instance if the implementation for this function were in base, and I could use Safe (or at least Trustworthy) interface. (This package takes Safe Haskell seriously for time being).

Turns out there is for heterogenous equality for StableName (eqStableName), so figuring out coercion based on STRef equality kind of belongs to base as well.

As maintainer I'll be happy if burden of tracking GHC internals is in GHC-provided lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had the same thought. The unsafe function should be where the implementation is, as those must be kept in sync?

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

Successfully merging this pull request may close these issues.

2 participants