on 9216dbd help sign in
rel8/src/Rel8/Schema/HTable/Identity.hs
44 lines 1.1 kB history raw
1{-# language DataKinds #-}
2{-# language GADTs #-}
3{-# language StandaloneKindSignatures #-}
4{-# language TypeFamilies #-}
6module Rel8.Schema.HTable.Identity
7 ( HIdentity(..)
8 )
9where
11-- base
12import Data.Kind ( Type )
13import Prelude
15-- rel8
16import Rel8.Schema.Dict ( Dict( Dict ) )
17import Rel8.Schema.HTable
18 ( HTable, HConstrainTable, HField
19 , hfield, htabulate, htraverse, hdicts, hspecs
20 )
21import qualified Rel8.Schema.Kind as K
22import Rel8.Schema.Spec ( Spec, KnownSpec, specSing )
25type HIdentity :: Spec -> K.HTable
26newtype HIdentity spec context = HIdentity
27 { unHIdentity :: context spec
28 }
31type HIdentityField :: Spec -> Spec -> Type
32data HIdentityField _spec spec where
33 HIdentityField :: HIdentityField spec spec
36instance KnownSpec spec => HTable (HIdentity spec) where
37 type HConstrainTable (HIdentity spec) c = c spec
38 type HField (HIdentity spec) = HIdentityField spec
40 hfield (HIdentity a) HIdentityField = a
41 htabulate f = HIdentity $ f HIdentityField
42 htraverse f (HIdentity a) = HIdentity <$> f a
43 hdicts = HIdentity Dict
44 hspecs = HIdentity specSing