on master help sign in
Add supported for polymorphic nested Rel8ables (#215)

```haskell data Nest t u f = Nest { foo :: t f , bar :: u f } deriving (Generic, Rel8able) ``

commited4b5bb0acda2493daf291edc9962fce65734b3f authorShane <shane.obrien@circuithub.com> dateTue 8 Nov 2022, 13:47 (4 years ago) parent42e38c7
2 files changed+15−1
src/Rel8/Generic/Rel8able.hs+5 tests/Rel8/Generic/Rel8able/Test.hs+10−1
src/Rel8/Generic/Rel8able.hs+5
@@ -63,6 +63,11 @@ type KRel8able = K.Rel8able
6363-- This is almost 'Data.Type.Equality.==', but we add an extra case.
6464type (==) :: k -> k -> Bool
6565type family a == b where
66+ -- This extra case is needed to solve the equation "a == a" (where a is a
67+ -- KRel8able), which occurs when we have polymorphic Rel8ables
68+ -- (e.g., newtype T t f = T { x :: t a })
69+ (a :: KRel8able) == (a :: KRel8able) = 'True
70+
6671 -- This extra case is needed to solve the equation "a == Identity a",
6772 -- which occurs when we have polymorphic Rel8ables
6873 -- (e.g., newtype T a f = T { x :: Column f a })
tests/Rel8/Generic/Rel8able/Test.hs+10−1
@@ -5,6 +5,7 @@
55{-# language DuplicateRecordFields #-}
66{-# language FlexibleInstances #-}
77{-# language MultiParamTypeClasses #-}
8+{-# language StandaloneKindSignatures #-}
89{-# language TypeFamilies #-}
910{-# language UndecidableInstances #-}
1011
@@ -171,9 +172,17 @@ data NestedTableTestB f = NestedTableTestB
171172 deriving anyclass Rel8able
172173
173174
174−
175175newtype IdRecord a f = IdRecord { recordId :: Column f a }
176176 deriving stock Generic
177177
178178
179179instance DBType a => Rel8able (IdRecord a)
180+
181+
182+type Nest :: KRel8able -> KRel8able -> KRel8able
183+data Nest t u f = Nest
184+ { foo :: t f
185+ , bar :: u f
186+ }
187+ deriving stock Generic
188+ deriving anyclass Rel8able