@@ -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