@@ -14,8 +14,7 @@ module Rel8.Generic.Rel8able
1414 ( KRel8able, Rel8able
1515 , Algebra
1616 , GRep
17− , GColumns, GContext, gfromColumns, gtoColumns
18− , GColumnsADT, gfromColumnsADT, gtoColumnsADT
17+ , GColumns, gfromColumns, gtoColumns
1918 , greify, gunreify
2019 , TUnreifyContext
2120 )
@@ -33,18 +32,14 @@ import Rel8.Kind.Context ( Reifiable )
3332import Rel8.FCF ( Eval, Exp )
3433import Rel8.Generic.Map ( GMap, GMappable, gmap, gunmap )
3534import Rel8.Generic.Record ( Record(..) )
36−import Rel8.Generic.Table
37− ( GGTable, GGColumns, GGContext, ggfromColumns, ggtoColumns
38− , GAlgebra
39− )
40−import qualified Rel8.Generic.Table.ADT as G
41−import Rel8.Kind.Algebra ( KnownAlgebra )
35+import Rel8.Generic.Table ( GAlgebra )
36+import qualified Rel8.Generic.Table.Record as G
4237import qualified Rel8.Kind.Algebra as K ( Algebra(..) )
4338import Rel8.Schema.Context ( Col )
4439import Rel8.Schema.Context.Label ( Labelable )
4540import Rel8.Schema.HTable ( HTable )
4641import qualified Rel8.Schema.Kind as K
47−import Rel8.Schema.Reify ( Col( Reify ), Reify, UnwrapReify )
42+import Rel8.Schema.Reify ( Reify, UnwrapReify )
4843import Rel8.Schema.Result ( Result )
4944import Rel8.Table
5045 ( fromColumns, toColumns, reify, unreify
@@ -99,123 +94,48 @@ type KRel8able = K.Rel8able
9994-- deriving ( GHC.Generics.Generic, Rel8able )
10095-- @
10196type Rel8able :: K.Rel8able -> Constraint
102−class
103− ( HTable (GColumns t)
104− , HTable (GColumnsADT t)
105− , GContext t Result ~ Result
106− )
107− => Rel8able t
108− where
109− type Algebra t :: K.Algebra
110−
111− type GRep t (context :: K.Context) :: Type -> Type
112−
97+class HTable (GColumns t) => Rel8able t where
11398 type GColumns t :: K.HTable
11499
115− type GContext t (context :: K.Context) :: K.Context
116−
117− gfromColumns :: (Labelable context, Reifiable context, GContext t context ~ context)
100+ gfromColumns :: (Labelable context, Reifiable context)
118101 => GColumns t (Col (Reify context)) -> t (Reify context)
119102
120− gtoColumns :: (Labelable context, Reifiable context, GContext t context ~ context)
103+ gtoColumns :: (Labelable context, Reifiable context)
121104 => t (Reify context) -> GColumns t (Col (Reify context))
122105
123− gfromColumnsADT :: GColumnsADT t (Col (Reify Result)) -> t (Reify Result)
124−
125− gtoColumnsADT :: t (Reify Result) -> GColumnsADT t (Col (Reify Result))
126−
127106 greify :: (Labelable context, Reifiable context)
128107 => t context -> t (Reify context)
129108
130109 gunreify :: (Labelable context, Reifiable context)
131110 => t (Reify context) -> t context
132111
133− type Algebra t = GAlgebra (GRep t (Reify Result))
134−
135− type GRep t context = Rep (Record (t context))
136−
137− type GColumns t = Eval (GGColumns (Algebra t) TColumns (GRep t (Reify Result)))
138−
139− type GContext t context =
140− Eval (GGContext (Algebra t) TUnreifyContext (GRep t (Reify context)))
112+ type GColumns t = G.GColumns TColumns (GRep t (Reify Result))
141113
142114 default gfromColumns :: forall context.
143115 ( Generic (Record (t (Reify context)))
144− , GRep t (Reify context) ~ Rep (Record (t (Reify context)))
145− , KnownAlgebra (Algebra t)
146− , Eval (GGTable (Algebra t) (TTable (Reify context)) TColumns (Col (Reify context)) (GRep t (Reify context)))
147− , Eval (GGColumns (Algebra t) TColumns (GRep t (Reify context))) ~ GColumns t
148− , Eval (GGContext (Algebra t) TUnreifyContext (GRep t (Reify context))) ~ context
116+ , G.GTable (TTable (Reify context)) TColumns (Col (Reify context)) (GRep t (Reify context))
117+ , G.GColumns TColumns (GRep t (Reify context)) ~ GColumns t
149118 )
150119 => GColumns t (Col (Reify context)) -> t (Reify context)
151120 gfromColumns =
152121 unrecord .
153122 to .
154− ggfromColumns
155− @(Algebra t)
156− @(TTable (Reify context))
157− @TColumns
158− (\(Reify a) -> a)
159− Reify
160− fromColumns
123+ G.gfromColumns @(TTable (Reify context)) @TColumns fromColumns
161124
162125 default gtoColumns :: forall context.
163126 ( Generic (Record (t (Reify context)))
164− , GRep t (Reify context) ~ Rep (Record (t (Reify context)))
165− , KnownAlgebra (Algebra t)
166− , Eval (GGTable (Algebra t) (TTable (Reify context)) TColumns (Col (Reify context)) (GRep t (Reify context)))
167− , Eval (GGColumns (Algebra t) TColumns (GRep t (Reify context))) ~ GColumns t
168− , Eval (GGContext (Algebra t) TUnreifyContext (GRep t (Reify context))) ~ context
127+ , G.GTable (TTable (Reify context)) TColumns (Col (Reify context)) (GRep t (Reify context))
128+ , G.GColumns TColumns (GRep t (Reify context)) ~ GColumns t
169129 )
170130 => t (Reify context) -> GColumns t (Col (Reify context))
171131 gtoColumns =
172− ggtoColumns
173− @(Algebra t)
174− @(TTable (Reify context))
175− @TColumns
176− (\(Reify a) -> a)
177− Reify
178− toColumns .
179− from .
180− Record
181−
182− default gfromColumnsADT ::
183− ( Generic (Record (t (Reify Result)))
184− , GRep t (Reify Result) ~ Rep (Record (t (Reify Result)))
185− , G.GTableADT (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRep t (Reify Result))
186− )
187− => GColumnsADT t (Col (Reify Result)) -> t (Reify Result)
188− gfromColumnsADT =
189− unrecord .
190− to .
191− G.gfromColumnsADT
192− @(TTable (Reify Result))
193− @TColumns
194− (\(Reify a) -> a)
195− Reify
196− fromColumns
197−
198− default gtoColumnsADT ::
199− ( Generic (Record (t (Reify Result)))
200− , GRep t (Reify Result) ~ Rep (Record (t (Reify Result)))
201− , G.GTableADT (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRep t (Reify Result))
202− )
203− => t (Reify Result) -> GColumnsADT t (Col (Reify Result))
204− gtoColumnsADT =
205− G.gtoColumnsADT
206− @(TTable (Reify Result))
207− @TColumns
208− (\(Reify a) -> a)
209− Reify
210− toColumns .
132+ G.gtoColumns @(TTable (Reify context)) @TColumns toColumns .
211133 from .
212134 Record
213135
214136 default greify :: forall context.
215137 ( Generic (Record (t context))
216− , GRep t context ~ Rep (Record (t context))
217138 , Generic (Record (t (Reify context)))
218− , GRep t (Reify context) ~ Rep (Record (t (Reify context)))
219139 , GMappable (TTable (Reify context)) (GRep t (Reify context))
220140 , GRep t context ~ GMap TUnreify (GRep t (Reify context))
221141 )
@@ -229,9 +149,7 @@ class
229149
230150 default gunreify :: forall context.
231151 ( Generic (Record (t context))
232− , GRep t context ~ Rep (Record (t context))
233152 , Generic (Record (t (Reify context)))
234− , GRep t (Reify context) ~ Rep (Record (t (Reify context)))
235153 , GMappable (TTable (Reify context)) (GRep t (Reify context))
236154 , GRep t context ~ GMap TUnreify (GRep t (Reify context))
237155 )
@@ -244,7 +162,12 @@ class
244162 Record
245163
246164
247−type GColumnsADT t = G.GColumnsADT TColumns (GRep t (Reify Result))
165+type Algebra :: K.Rel8able -> K.Algebra
166+type Algebra t = GAlgebra (GRep t (Reify Result))
167+
168+
169+type GRep :: K.Rel8able -> K.Context -> Type -> Type
170+type GRep t context = Rep (Record (t context))
248171
249172
250173data TUnreifyContext :: Type -> Exp K.Context