on master help sign in
Fix bottom
commit38a9aecb34e2af5f43df9b0934873f894b4ab68a authorShane O'Brien <shane.obrien@circuithub.com> dateWed 24 Mar 2021, 12:18 (6 years ago) parent1926f58
3 files changed+16−7
src/Rel8/Schema/Context/Label.hs+1−1 src/Rel8/Schema/Generic.hs+6−6 src/Rel8/Table/Name.hs+9
src/Rel8/Schema/Context/Label.hs+1−1
@@ -86,4 +86,4 @@ instance (Labelable context, x ~ IsSpecialContext context) =>
8686 HLabelable (Col' x context)
8787 where
8888 hlabeler = labeler
89− hunlabeler = hunlabeler
89+ hunlabeler = unlabeler
src/Rel8/Schema/Generic.hs+6−6
@@ -638,9 +638,9 @@ instance
638638 where
639639 fromK1Columns =
640640 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
641− hunlabel hunlabeler
641+ hunlabel unlabeler
642642 toK1Columns =
643− hlabel hlabeler .
643+ hlabel labeler .
644644 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
645645 {-# INLINABLE fromK1Columns #-}
646646 {-# INLINABLE toK1Columns #-}
@@ -654,9 +654,9 @@ instance
654654 where
655655 fromK1Columns =
656656 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
657− hunlabel hunlabeler
657+ hunlabel unlabeler
658658 toK1Columns =
659− hlabel hlabeler .
659+ hlabel labeler .
660660 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
661661 {-# INLINABLE fromK1Columns #-}
662662 {-# INLINABLE toK1Columns #-}
@@ -670,9 +670,9 @@ instance
670670 where
671671 fromK1Columns =
672672 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
673− hunlabel hunlabeler
673+ hunlabel unlabeler
674674 toK1Columns =
675− hlabel hlabeler .
675+ hlabel labeler .
676676 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
677677 {-# INLINABLE fromK1Columns #-}
678678 {-# INLINABLE toK1Columns #-}
src/Rel8/Table/Name.hs+9
@@ -8,6 +8,7 @@
88module Rel8.Table.Name
99 ( namesFromLabels
1010 , namesFromLabelsWith
11+ , showExprs
1112 , showLabels
1213 , showNames
1314 )
@@ -23,6 +24,7 @@ import Prelude
2324import Text.Casing ( quietSnake )
2425
2526-- rel8
27+import Rel8.Expr ( Expr )
2628import Rel8.Kind.Labels ( renderLabels )
2729import Rel8.Schema.Context ( Col'(..), Name( Name ) )
2830import Rel8.Schema.HTable ( htabulate, htabulateA, hfield, hspecs )
@@ -43,6 +45,13 @@ namesFromLabelsWith f = fromColumns $ htabulate $ \field ->
4345 SSpec {labels} -> Col (Name (f (renderLabels labels)))
4446
4547
48+showExprs :: Table Expr a => a -> [(String, String)]
49+showExprs as = case (namesFromLabels, toColumns as) of
50+ (names, exprs) -> getConst $ htabulateA $ \field ->
51+ case (hfield names field, hfield exprs field) of
52+ (Col (Name name), DB expr) -> Const [(name, show expr)]
53+
54+
4655showLabels :: forall a. Table (Context a) a => a -> [NonEmpty String]
4756showLabels _ = getConst $
4857 htabulateA @(Columns a) $ \field -> case hfield hspecs field of