1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
3{-# language FlexibleInstances #-}
5{-# language LambdaCase #-}
6{-# language MultiParamTypeClasses #-}
7{-# language QuantifiedConstraints #-}
8{-# language RankNTypes #-}
9{-# language StandaloneKindSignatures #-}
10{-# language TypeFamilies #-}
11{-# language UndecidableInstances #-}
13-- | This module implements some machinery for implementing methods of the
14-- 'Table' class for a particular special (but important) class of polymorphic
17-- This special case is characterised by a @newtype@ wrapper around a bare
18-- 'HTable' which is constructed by applying a type family to the polymorphic
21-- Examples of this class of @Table@ include @ListTable@ and @NonEmptyTable@.
23-- The tricky part about implementing @Table@ for these types is 'reify' and
24-- 'unreify'. There is no guarantee in general that @'Unreify' a@ is itself
25-- a @Table@, let alone a @Table@ with the same 'Columns' as @a@
26-- (e.g., @Unreify (AColumn Result Bool) = Bool@, and @Bool@ is not a
29module Rel8.Table.Unreify
30 ( Unreifiable, Unreifiability(..), unreifiability
36import Data.Kind ( Constraint, Type )
40import Rel8.Aggregate ( Aggregate )
41import Rel8.Expr ( Expr )
42import Rel8.Kind.Context ( SContext(..), Reifiable, sReifiable )
43import Rel8.Schema.Dict ( Dict( Dict ) )
44import Rel8.Schema.Insert ( Insert )
45import qualified Rel8.Schema.Kind as K
46import Rel8.Schema.Name ( Name )
47import Rel8.Schema.Reify ( Reify )
48import Rel8.Schema.Result ( Result )
49import Rel8.Table ( Table, Context, Congruent, Unreify )
52type Unreifies :: K.Context -> Type -> Constraint
53type family Unreifies context a where
54 Unreifies (Reify context) a = Unreifier context a
58type Unreifiable :: Type -> Constraint
60 ( Context a ~ Reify Aggregate => Unreifier Aggregate a
61 , Context a ~ Reify Expr => Unreifier Expr a
62 , Context a ~ Reify Insert => Unreifier Insert a
63 , Context a ~ Reify Name => Unreifier Name a
64 , (forall ctx. (Context a ~ Reify (Reify ctx), Reifiable ctx) => Unreifier (Reify ctx) a)
68 ( Context a ~ Reify Aggregate => Unreifier Aggregate a
69 , Context a ~ Reify Expr => Unreifier Expr a
70 , Context a ~ Reify Insert => Unreifier Insert a
71 , Context a ~ Reify Name => Unreifier Name a
72 , (forall ctx. (Context a ~ Reify (Reify ctx), Reifiable ctx) => Unreifier (Reify ctx) a)
77type Unreifier :: K.Context -> Type -> Constraint
79 ( Table context (Unreify a)
80 , Congruent a (Unreify a)
82 => Unreifier context a
84 ( Table context (Unreify a)
85 , Congruent a (Unreify a)
87 => Unreifier context a
90type Unreifiability :: K.Context -> Type -> Type
91data Unreifiability context a where
92 UResult :: Unreifiability Result a
93 Unreifiability :: Unreifier context a
94 => SContext context -> Unreifiability context a
97unreifiability :: (Context a ~ Reify context, Unreifiable a)
98 => SContext context -> Unreifiability context a
100 SAggregate -> Unreifiability SAggregate
101 SExpr -> Unreifiability SExpr
102 SInsert -> Unreifiability SInsert
103 SName -> Unreifiability SName
105 SReify context -> case sReifiable context of
106 Dict -> Unreifiability (SReify context)
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