
#12422: Add decidable equality class -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): There are several fun things to respond to here! 1. Making `:~:` heterogeneous would likely break client code. The problem is that, right now, if I say `(Int :~: a)` somewhere, GHC can know that `a :: Type`. If we make `:~:` hetero, then GHC would rightly have `a :: k`, which can cause trouble. This is not hypothetical: I tried making this change once upon a time, and things broke. Even worse, it was hard to go from the error message reported to the actual cause. I advocate against this change. 2. We should have `:~~:` in the standard library. But I was too exhausted from implementing `TypeInType` to start this debate on the libraries mailing list. We should really put it in for 8.2. 3. Here is the hetero version of `TestEquality`: {{{ -- hetero class HTestEquality (f :: forall k. k -> Type) where hTestEquality :: f a -> f b -> Maybe (a :~~: b) }}} Note that `f` has to be polymorphic in its kind to avoid constraining `a` and `b` to have the same kind. Yes, this is a higher-rank kind! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12422#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler