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

Add Equals to Type.Data.Boolean? #65

Open
kl0tl opened this issue Nov 23, 2020 · 4 comments
Open

Add Equals to Type.Data.Boolean? #65

kl0tl opened this issue Nov 23, 2020 · 4 comments
Labels
status: needs more info This issue needs more info before any action can be done.

Comments

@kl0tl
Copy link
Member

kl0tl commented Nov 23, 2020

We have Type.Data.Ordering.Equals and Type.Data.Symbol.Equals but no Type.Data.Boolean.Equals.

Is there any reason for not wanting or needing this class?

I assume it would be implemented like this:

class Equals :: Boolean -> Boolean -> Boolean -> Constraint
class Equals lhs rhs out | lhs rhs -> out, lhs out -> rhs, rhs out -> lhs

instance equalsTrueTrue :: Equals True True True
else instance equalsTrueFalse :: Equals True False False
else instance equalsFalseTrue :: Equals False True False
else instance equalsFalseFalse :: Equals False False True

equals :: forall proxy l r o. Equals l r o => proxy l -> proxy r -> Proxy o
equals _ _ = Proxy
@JordanMartinez
Copy link
Contributor

Yes, we should add it for completeness.

However, now that we have polykinds, is it possible for Equals to become polymorphic, so that we don't need an Ordering.Equals or Symbol.Equals?

@kl0tl
Copy link
Member Author

kl0tl commented Nov 26, 2020

I don’t think we can have a single polymorphic Equals class: its instance for symbols would overlap the other instances for orderings and booleans!

Also since Boolean has only two inhabitants we can have more functional dependencies (lhs out -> rhs and rhs out -> lhs), allowing the compiler to deduce one of the parameters from the other and the result (which isn’t possible for symbols nor orderings when the result is False).

@JordanMartinez
Copy link
Contributor

Ah, good point.

@JordanMartinez
Copy link
Contributor

#66 wasn't merged because a concrete use case wasn't known at that particular time.

@JordanMartinez JordanMartinez added the status: needs more info This issue needs more info before any action can be done. label Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info This issue needs more info before any action can be done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants