1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
4{-# language LambdaCase #-}
5{-# language MultiParamTypeClasses #-}
6{-# language StandaloneKindSignatures #-}
7{-# language TypeFamilies #-}
8{-# language UndecidableInstances #-}
10module Rel8.Column.List
16import Data.Kind ( Type )
20import Rel8.Aggregate ( Aggregate )
21import Rel8.Expr ( Expr )
22import Rel8.Kind.Context ( SContext(..), Reifiable( contextSing ) )
23import Rel8.Schema.Context ( Col )
24import Rel8.Schema.HTable.List ( HListTable )
25import Rel8.Schema.Insert ( Insert )
26import qualified Rel8.Schema.Kind as K
27import Rel8.Schema.Name ( Name )
28import Rel8.Schema.Reify ( Reify, hreify, hunreify )
29import Rel8.Schema.Result ( Result )
31 ( Table, Columns, Congruent, Context, fromColumns, toColumns
32 , Unreify, reify, unreify
34import Rel8.Table.List ( ListTable( ListTable ) )
35import Rel8.Table.Recontextualize ( Recontextualize )
36import Rel8.Table.Unreify ( Unreifiable )
39type HList :: K.Context -> Type -> Type
40type family HList context where
41 HList (Reify context) = AHList context
42 HList Aggregate = ListTable
43 HList Expr = ListTable
44 HList Insert = ListTable
45 HList Name = ListTable
49type AHList :: K.Context -> Type -> Type
50newtype AHList context a = AHList (HList context a)
55 , Table (Reify context) a
56 , Unreifiable (Reify context) a
58 => Table (Reify context) (AHList context a)
60 type Context (AHList context a) = Reify context
61 type Columns (AHList context a) = HListTable (Columns a)
62 type Unreify (AHList context a) = HList context (Unreify a)
64 fromColumns = sfromColumnsList contextSing
65 toColumns = stoColumnsList contextSing
67 smapList contextSing (reify proof) hreify .
71 smapList contextSing (unreify proof) hunreify
75 ( Reifiable context, Reifiable context'
76 , Unreifiable (Reify context) a, Unreifiable (Reify context') a'
77 , Recontextualize (Reify context) (Reify context') a a'
86smapList :: Congruent a b
89 -> (HListTable (Columns a) (Col (Context a)) -> HListTable (Columns b) (Col (Context b)))
93 SAggregate -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
94 SExpr -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
95 SResult -> \f _ (AHList as) -> AHList (fmap f as)
96 SInsert -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
97 SName -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
98 SReify context -> \f g (AHList as) -> AHList (smapList context f g as)
101sfromColumnsList :: Table (Reify context) a
103 -> HListTable (Columns a) (Col (Reify context))
105sfromColumnsList = \case
106 SAggregate -> AHList . ListTable
107 SExpr -> AHList . ListTable
108 SResult -> AHList . fmap (fromColumns . hreify) . fromColumns . hunreify
109 SInsert -> AHList . ListTable
110 SName -> AHList . ListTable
113 smapList context (fromColumns . hreify) hreify .
114 sfromColumnsList context .
118stoColumnsList :: Table (Reify context) a
121 -> HListTable (Columns a) (Col (Reify context))
122stoColumnsList = \case
123 SAggregate -> \(AHList (ListTable a)) -> a
124 SExpr -> \(AHList (ListTable a)) -> a
126 hreify . toColumns . fmap (hunreify . toColumns) . (\(AHList a) -> a)
127 SInsert -> \(AHList (ListTable a)) -> a
128 SName -> \(AHList (ListTable a)) -> a
131 stoColumnsList context .
132 smapList context (hunreify . toColumns) hunreify .
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list