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 qualified Rel8.Schema.Kind as K
26import Rel8.Schema.Name ( Name )
27import Rel8.Schema.Reify ( Reify, hreify, hunreify )
28import Rel8.Schema.Result ( Result )
30 ( Table, Columns, Congruent, Context, fromColumns, toColumns
31 , Unreify, reify, unreify
33import Rel8.Table.List ( ListTable( ListTable ) )
34import Rel8.Table.Recontextualize ( Recontextualize )
35import Rel8.Table.Unreify ( Unreifiability(..), Unreifiable, unreifiability )
38-- | Nest a list within a 'Rel8able'. @HList f a@ will produce a 'ListTable'
39-- @a@ in the 'Expr' context, and a @[a]@ in the 'Result' context.
40type HList :: K.Context -> Type -> Type
41type family HList context where
42 HList (Reify context) = AHList context
43 HList Aggregate = ListTable
44 HList Expr = 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 SName -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
90 SReify context -> \f g (AHList as) -> AHList (smapList context f g as)
93sfromColumnsList :: Table (Reify context) a
95 -> HListTable (Columns a) (Col (Reify context))
97sfromColumnsList = \case
98 SAggregate -> AHList . ListTable
99 SExpr -> AHList . ListTable
100 SResult -> AHList . fmap (fromColumns . hreify) . fromColumns . hunreify
101 SName -> AHList . ListTable
104 smapList context (fromColumns . hreify) hreify .
105 sfromColumnsList context .
109stoColumnsList :: Table (Reify context) a
112 -> HListTable (Columns a) (Col (Reify context))
113stoColumnsList = \case
114 SAggregate -> \(AHList (ListTable a)) -> a
115 SExpr -> \(AHList (ListTable a)) -> a
117 hreify . toColumns . fmap (hunreify . toColumns) . (\(AHList a) -> a)
118 SName -> \(AHList (ListTable a)) -> a
121 stoColumnsList context .
122 smapList context (hunreify . toColumns) hunreify .
126sreifyList :: Table (Reify context) a
127 => Unreifiability context a
128 -> HList context (Unreify a)
131 UResult -> AHList . fmap (reify Refl)
132 Unreifiability context ->
133 smapList context (reify Refl) hreify .
137sunreifyList :: Table (Reify context) a
138 => Unreifiability context a
140 -> HList context (Unreify a)
142 UResult -> fmap (unreify Refl) . (\(AHList a) -> a)
143 Unreifiability context ->
145 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