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 qualified Rel8.Schema.Kind as K
45import Rel8.Schema.Name ( Name )
46import Rel8.Schema.Reify ( Reify )
47import Rel8.Schema.Result ( Result )
48import Rel8.Table ( Table, Context, Congruent, Unreify )
51type Unreifies :: K.Context -> Type -> Constraint
52type family Unreifies context a where
53 Unreifies (Reify context) a = Unreifier context a
57type Unreifiable :: Type -> Constraint
59 ( Context a ~ Reify Aggregate => Unreifier Aggregate a
60 , Context a ~ Reify Expr => Unreifier Expr a
61 , Context a ~ Reify Name => Unreifier Name a
62 , (forall ctx. (Context a ~ Reify (Reify ctx), Reifiable ctx) => Unreifier (Reify ctx) a)
66 ( Context a ~ Reify Aggregate => Unreifier Aggregate a
67 , Context a ~ Reify Expr => Unreifier Expr a
68 , Context a ~ Reify Name => Unreifier Name a
69 , (forall ctx. (Context a ~ Reify (Reify ctx), Reifiable ctx) => Unreifier (Reify ctx) a)
74type Unreifier :: K.Context -> Type -> Constraint
76 ( Table context (Unreify a)
77 , Congruent a (Unreify a)
79 => Unreifier context a
81 ( Table context (Unreify a)
82 , Congruent a (Unreify a)
84 => Unreifier context a
87type Unreifiability :: K.Context -> Type -> Type
88data Unreifiability context a where
89 UResult :: Unreifiability Result a
90 Unreifiability :: Unreifier context a
91 => SContext context -> Unreifiability context a
94unreifiability :: (Context a ~ Reify context, Unreifiable a)
95 => SContext context -> Unreifiability context a
97 SAggregate -> Unreifiability SAggregate
98 SExpr -> Unreifiability SExpr
99 SName -> Unreifiability SName
101 SReify context -> case sReifiable context of
102 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