on master help sign in
Fix bottom
38a9aecShane O'Brien
src/Rel8/Schema/Context/Label.hs+1−1
@@ -86,4 +86,4 @@ instance (Labelable context, x ~ IsSpecialContext context) =>
86 HLabelable (Col' x context)
86 HLabelable (Col' x context)
87 where
87 where
88 hlabeler = labeler
88 hlabeler = labeler
89− hunlabeler = hunlabeler
89+ hunlabeler = unlabeler
src/Rel8/Schema/Generic.hs+6−6
@@ -638,9 +638,9 @@ instance
638 where
638 where
639 fromK1Columns =
639 fromK1Columns =
640 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
640 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
641− hunlabel hunlabeler
641+ hunlabel unlabeler
642 toK1Columns =
642 toK1Columns =
643− hlabel hlabeler .
643+ hlabel labeler .
644 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
644 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
645 {-# INLINABLE fromK1Columns #-}
645 {-# INLINABLE fromK1Columns #-}
646 {-# INLINABLE toK1Columns #-}
646 {-# INLINABLE toK1Columns #-}
@@ -654,9 +654,9 @@ instance
654 where
654 where
655 fromK1Columns =
655 fromK1Columns =
656 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
656 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
657− hunlabel hunlabeler
657+ hunlabel unlabeler
658 toK1Columns =
658 toK1Columns =
659− hlabel hlabeler .
659+ hlabel labeler .
660 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
660 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
661 {-# INLINABLE fromK1Columns #-}
661 {-# INLINABLE fromK1Columns #-}
662 {-# INLINABLE toK1Columns #-}
662 {-# INLINABLE toK1Columns #-}
@@ -670,9 +670,9 @@ instance
670 where
670 where
671 fromK1Columns =
671 fromK1Columns =
672 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
672 fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
673− hunlabel hunlabeler
673+ hunlabel unlabeler
674 toK1Columns =
674 toK1Columns =
675− hlabel hlabeler .
675+ hlabel labeler .
676 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
676 toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
677 {-# INLINABLE fromK1Columns #-}
677 {-# INLINABLE fromK1Columns #-}
678 {-# INLINABLE toK1Columns #-}
678 {-# INLINABLE toK1Columns #-}
src/Rel8/Table/Name.hs+9
@@ -8,6 +8,7 @@
8module Rel8.Table.Name
8module Rel8.Table.Name
9 ( namesFromLabels
9 ( namesFromLabels
10 , namesFromLabelsWith
10 , namesFromLabelsWith
11+ , showExprs
11 , showLabels
12 , showLabels
12 , showNames
13 , showNames
13 )
14 )
@@ -23,6 +24,7 @@ import Prelude
23import Text.Casing ( quietSnake )
24import Text.Casing ( quietSnake )
24
25
25-- rel8
26-- rel8
27+import Rel8.Expr ( Expr )
26import Rel8.Kind.Labels ( renderLabels )
28import Rel8.Kind.Labels ( renderLabels )
27import Rel8.Schema.Context ( Col'(..), Name( Name ) )
29import Rel8.Schema.Context ( Col'(..), Name( Name ) )
28import Rel8.Schema.HTable ( htabulate, htabulateA, hfield, hspecs )
30import Rel8.Schema.HTable ( htabulate, htabulateA, hfield, hspecs )
@@ -43,6 +45,13 @@ namesFromLabelsWith f = fromColumns $ htabulate $ \field ->
43 SSpec {labels} -> Col (Name (f (renderLabels labels)))
45 SSpec {labels} -> Col (Name (f (renderLabels labels)))
44
46
45
47
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+
46showLabels :: forall a. Table (Context a) a => a -> [NonEmpty String]
55showLabels :: forall a. Table (Context a) a => a -> [NonEmpty String]
47showLabels _ = getConst $
56showLabels _ = getConst $
48 htabulateA @(Columns a) $ \field -> case hfield hspecs field of
57 htabulateA @(Columns a) $ \field -> case hfield hspecs field of