Skip to content

Commit b2bee8d

Browse files
committed
Tidying
1 parent cbec2d9 commit b2bee8d

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

src/Rel8/Column/List.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Rel8.Table.List ( ListTable )
2323
-- | Nest a list within a 'Rel8able'. @HList f a@ will produce a 'ListTable'
2424
-- @a@ in the 'Expr' context, and a @[a]@ in the 'Result' context.
2525
type HList :: K.Context -> Type -> Type
26-
type family HList context where
26+
type family HList context = list | list -> context where
2727
HList Aggregate = ListTable Aggregate
2828
HList Expr = ListTable Expr
2929
HList Name = ListTable Name

src/Rel8/Table/List.hs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,15 @@ instance ListContext Name where
134134
where rename = N . (\(Name x) -> Name x) . unN
135135

136136

137-
instance (Table context a, c ~ context, Context a ~ c, ListContext context) =>
138-
Table context (ListTable c a)
137+
instance (Table context a, context ~ context', ListContext context') =>
138+
Table context' (ListTable context a)
139139
where
140-
type Columns (ListTable c a) = HListTable (Columns a)
141-
type Context (ListTable c a) = Context a
142-
type FromExprs (ListTable c a) = [FromExprs a]
143-
144-
fromColumns c = ListTable fromColumns c
140+
type Columns (ListTable context a) = HListTable (Columns a)
141+
type Context (ListTable context a) = Context a
142+
type FromExprs (ListTable context a) = [FromExprs a]
145143

144+
fromColumns = ListTable fromColumns
146145
toColumns (ListTable f cols) = mapColumns (toColumns . f) cols
147-
148146
fromResult = fmap (fromResult @_ @a) . hunvectorize unvectorizer
149147
toResult = hvectorize vectorizer . fmap (toResult @_ @a)
150148

@@ -171,7 +169,8 @@ instance (OrdTable a, context ~ Expr) => OrdTable (ListTable context a) where
171169
(Identity (ordTable @a))
172170

173171

174-
instance (context ~ Expr, ToExprs exprs a) => ToExprs (ListTable context exprs) [a] where
172+
instance (ToExprs exprs a, context ~ Expr) =>
173+
ToExprs (ListTable context exprs) [a]
175174

176175

177176
instance context ~ Expr => AltTable (ListTable context) where
@@ -182,19 +181,23 @@ instance context ~ Expr => AlternativeTable (ListTable context) where
182181
emptyTable = mempty
183182

184183

185-
instance (context ~ Expr, Table Expr a) => Semigroup (ListTable context a) where
186-
as <> bs = ListTable fromColumns $
184+
instance (context ~ Expr, Table Expr a) =>
185+
Semigroup (ListTable context a)
186+
where
187+
as <> bs = fromColumns $
187188
happend (\_ _ (E a) (E b) -> E (sappend a b)) (toColumns as) (toColumns bs)
188189

189190

190-
instance (context ~ Expr, Table Expr a) => Monoid (ListTable context a) where
191-
mempty = ListTable fromColumns $ hempty $ \_ -> E . sempty
191+
instance (context ~ Expr, Table Expr a) =>
192+
Monoid (ListTable context a)
193+
where
194+
mempty = fromColumns $ hempty $ \_ -> E . sempty
192195

193196

194197
-- | Construct a @ListTable@ from a list of expressions.
195198
listTable :: Table Expr a => [a] -> ListTable Expr a
196199
listTable =
197-
ListTable fromColumns .
200+
fromColumns .
198201
hvectorize (\SSpec {info} -> E . slistOf info . fmap unE) .
199202
fmap toColumns
200203

@@ -207,7 +210,7 @@ nameListTable
207210
=> a -- ^ The names of the columns of elements of the list.
208211
-> ListTable Name a
209212
nameListTable =
210-
ListTable fromColumns .
213+
fromColumns .
211214
hvectorize (\_ (Identity (N (Name a))) -> N (Name a)) .
212215
pure .
213216
toColumns

0 commit comments

Comments
 (0)