-
Notifications
You must be signed in to change notification settings - Fork 14
Better docs to distinguish from TestEquality #47
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
Comments
I wouldn't hold my breath on #21 going in. Please, hold your horses. |
Oh I know |
If |
I'd like to see this clarification, especially now that haskell/core-libraries-committee#21 is resolved. It may help us use this package instead of |
@bb010g if they would do different thing, I think it might be a good idea to keep them separate. Having types implement the function with a complicated type (suggesting they do the thing) is confusing.
I'd follow that suggestion and only write TL;DR I'd keep the classes separate. I have to adjust the docs now as the @Ericson2314 change in |
@phadej Right after that suggestion, it says:
haskell/core-libraries-committee#21 explicitly accepted the "Weaker" option of ghc/ghc#7333, which means instance TestEquality Tag where
testEquality TagInt1 TagInt1 = Just Refl
testEquality TagInt1 TagInt2 = Just Refl
testEquality TagInt2 TagInt1 = Just Refl
testEquality TagInt2 TagInt2 = Just Refl is explicitly a legal instance. If people want a typeclass where type argument equality coincides with term equality, then they should use a typeclass where that is explicitly the case (i.e. not I don't see why |
It's also the only legal That however is probably not the |
I agree that you don't want that instance for |
@bb010g your analysis of As I said, it's very much the purpose of I also think that if relation could be there, it should be I won't add the dependency, and close this issue when I get to update the docs. There is no practical motivation to have (3rd option is to add |
@phadej I think you could implement
I'm curious what @Ericson2314's thoughts are here. This doesn't feel right to me; if this wording is making you feel unsure about what laws the class has, I would like to see it removed and, if necessary,
alongside a typeclass with weaker laws, so people know their options and can choose what's necessary without assuming
By that reasoning, is there a practical reason for |
It's irrelevant. CLC didn't wanted to restrict
One can argue that |
is a simple example of a data type for which
Regardless: geqFromTestEquality a b = do
prf @ Refl <- testEquality
guard $ a == b
Just prf is now a valid function and we should probably add at least that. |
geqFromTestEquality a b = do
prf @ Refl <- testEquality
guard $ a == b
Just prf is "good", but OTOH we don't require that |
I come up with an example, where one can have Well, rather one can have We can have If we have Similarly if one makes |
Though |
Resolve #47. Add explanation between GEq and TestEquality difference.
Another, maybe even less contrived example is the instance for instance (GEq a, GEq b) => GEq (Sum a b) where
geq (InL x) (InL y) = geq x y
geq (InR x) (InR y) = geq x y
geq _ _ = Nothing But one cannot have instance (TestEquality a, TestEquality b) => TestEquality (Sum a b) where as e.g. |
Oops didn't reply here. Yeah I think the |
If and only if is fine for singleton types, in fact I makes TestEquality more useful in that case. |
Uh oh!
There was an error while loading. Please reload this page.
See haskell/core-libraries-committee#21. The important thing about
GEq
is that it is doing term and type equality. LikewiseGCompare
is doing value ordering.This will be easier after #21, as the quantified constraints bring the plain H98 classes "in scope", so we can less awkwardly write laws clarifying the situation.
(That PR is in turn blocked on haskell/core-libraries-committee#10, but the current plain H98 class instances for
Sum
andProduct
are too pointlessly restrictive for this to work.)The text was updated successfully, but these errors were encountered: