@@ -6,6 +6,7 @@
66{-# language FlexibleInstances #-}
77{-# language LambdaCase #-}
88{-# language MultiParamTypeClasses #-}
9+{-# language PolyKinds #-}
910{-# language QuantifiedConstraints #-}
1011{-# language ScopedTypeVariables #-}
1112{-# language StandaloneKindSignatures #-}
@@ -25,8 +26,9 @@ module Rel8.Generic.Rel8able
2526where
2627
2728-- base
29+import Data.Functor.Identity ( Identity )
2830import Data.Kind ( Constraint, Type )
29−import Data.Type.Equality ( type (==) )
31+import Data.Type.Bool ( type (&&) )
3032import GHC.Generics ( Generic, Rep, from, to )
3133import Prelude
3234
@@ -58,6 +60,20 @@ type KRel8able :: Type
5860type KRel8able = K.Rel8able
5961
6062
63+-- This is almost 'Data.Type.Equality.==', but we add an extra case.
64+type (==) :: k -> k -> Bool
65+type family a == b where
66+ -- This extra case is needed to solve the equation "a == Identity a",
67+ -- which occurs when we have polymorphic Rel8ables
68+ -- (e.g., newtype T a f = T { x :: Column f a })
69+ a == Identity a = 'False
70+
71+ -- These cases are exactly the same as those in 'Data.Type.Equality.==.
72+ f a == g b = f == g && a == b
73+ a == a = 'True
74+ _ == _ = 'False
75+
76+
6177type Serialize :: Bool -> Type -> Type -> Constraint
6278class transposition ~ (a == Transpose Result expr) =>
6379 Serialize transposition expr a