You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
λ Data.Set>dataX=XIntStringderiving (Show)
λ Data.Set> instance EqXwhere (X a _) == (X b _) = a == b
λ Data.Set> instance OrdXwherecompare (X a _) (X b _) = a `compare` b
λ Data.Set> a = fromList [X1"A"]
λ Data.Set> b = fromList [X1"B"]
λ Data.Set> union a b
fromList [X1"A"]
λ Data.Set> union b a
fromList [X1"B"]
λ Data.Set> union a b == union b a
True
I don't see a problem. Your Eq / Ord says they are EQual.
They are equivalent according to the equivalence relation Eq (Set X), but they are not the same value. One is fromList [X 1 "A"] whereas the other one is fromList [X 1 "B"].
If you want the semilattice laws to hold with respect to Eq, rather than extensional equality, how would you describe them for the instance JoinSemiLattice (a -> b)?
JoinSemiLattice requires that join is commutative, but this is not necessarily true for the instance JoinSemiLattice (Set a) where join = union.
Consider this valid total order:
Now with:
The following do not give the same result:
The text was updated successfully, but these errors were encountered: