1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
3{-# language LambdaCase #-}
4{-# language MultiParamTypeClasses #-}
5{-# language StandaloneKindSignatures #-}
6{-# language TypeFamilies #-}
7{-# language UndecidableInstances #-}
15import Data.Kind ( Type )
16import Data.Type.Equality ( (:~:)( Refl ) )
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 ( Unreifiability(..), Unreifiable, unreifiability )
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)
53instance (Reifiable context, Unreifiable a, Table (Reify context) a) =>
54 Table (Reify context) (AHList context a)
56 type Context (AHList context a) = Reify context
57 type Columns (AHList context a) = HListTable (Columns a)
58 type Unreify (AHList context a) = HList context (Unreify a)
60 fromColumns = sfromColumnsList contextSing
61 toColumns = stoColumnsList contextSing
63 reify _ = sreifyList (unreifiability contextSing)
64 unreify _ = sunreifyList (unreifiability contextSing)
68 ( Reifiable context, Reifiable context'
69 , Unreifiable a, Unreifiable a'
70 , Recontextualize (Reify context) (Reify context') a a'
79smapList :: Congruent a b
82 -> (HListTable (Columns a) (Col (Context a)) -> HListTable (Columns b) (Col (Context b)))
86 SAggregate -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
87 SExpr -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
88 SResult -> \f _ (AHList as) -> AHList (fmap f as)
89 SInsert -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
90 SName -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
91 SReify context -> \f g (AHList as) -> AHList (smapList context f g as)
94sfromColumnsList :: Table (Reify context) a
96 -> HListTable (Columns a) (Col (Reify context))
98sfromColumnsList = \case
99 SAggregate -> AHList . ListTable
100 SExpr -> AHList . ListTable
101 SResult -> AHList . fmap (fromColumns . hreify) . fromColumns . hunreify
102 SInsert -> AHList . ListTable
103 SName -> AHList . ListTable
106 smapList context (fromColumns . hreify) hreify .
107 sfromColumnsList context .
111stoColumnsList :: Table (Reify context) a
114 -> HListTable (Columns a) (Col (Reify context))
115stoColumnsList = \case
116 SAggregate -> \(AHList (ListTable a)) -> a
117 SExpr -> \(AHList (ListTable a)) -> a
119 hreify . toColumns . fmap (hunreify . toColumns) . (\(AHList a) -> a)
120 SInsert -> \(AHList (ListTable a)) -> a
121 SName -> \(AHList (ListTable a)) -> a
124 stoColumnsList context .
125 smapList context (hunreify . toColumns) hunreify .
129sreifyList :: Table (Reify context) a
130 => Unreifiability context a
131 -> HList context (Unreify a)
134 UResult -> AHList . fmap (reify Refl)
135 Unreifiability context ->
136 smapList context (reify Refl) hreify .
140sunreifyList :: Table (Reify context) a
141 => Unreifiability context a
143 -> HList context (Unreify a)
145 UResult -> fmap (unreify Refl) . (\(AHList a) -> a)
146 Unreifiability context ->
148 smapList context (unreify Refl) 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