on 2cdc394 help sign in
rel8/src/Rel8/Table/Unreify.hs
43 lines 1.3 kB history raw
1{-# language DataKinds #-}
2{-# language StandaloneKindSignatures #-}
3{-# language TypeFamilies #-}
4{-# language UndecidableInstances #-}
6-- | This module implements some machinery for implementing methods of the
7-- 'Table' class for a particular special (but important) class of polymorphic
8-- @Table@ types.
9--
10-- This special case is characterised by a @newtype@ wrapper around a bare
11-- 'HTable' which is constructed by applying a type family to the polymorphic
12-- type variable.
13--
14-- Examples of this class of @Table@ include @ListTable@ and @NonEmptyTable@.
15--
16-- The tricky part about implementing @Table@ for these types is 'reify' and
17-- 'unreify'. There is no guarantee in general that @'Unreify' a@ is itself
18-- a @Table@, let alone a @Table@ with the same 'Columns' as @a@
19-- (e.g., @Unreify (AColumn Result Bool) = Bool@, and @Bool@ is not a
20-- @Table@)
22module Rel8.Table.Unreify
23 ( Unreifiable
24 )
25where
27-- base
28import Data.Kind ( Constraint, Type )
29import Prelude ()
31-- rel8
32import qualified Rel8.Schema.Kind as K
33import Rel8.Schema.Reify ( Reify )
34import Rel8.Table ( Table, Columns, Unreify )
37type Unreifiable :: K.Context -> Type -> Constraint
38type family Unreifiable context a where
39 Unreifiable (Reify context) a =
40 ( Table context (Unreify a)
41 , Columns a ~ Columns (Unreify a)
42 )
43 Unreifiable _ _ = ()