on 134ddcf 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 Prelude
14-- rel8
15import Rel8.Schema.Dict ( Dict( Dict ) )
16import Rel8.Schema.HTable
17 ( HTable, HConstrainTable, HField
18 , hfield, htabulate, htraverse, hdicts, hspecs
19 )
20import Rel8.Schema.HTable.Context ( H, HKTable )
21import Rel8.Schema.Spec ( Context, Spec, KnownSpec, specSing )
24type HIdentity :: Spec -> HKTable
25data HIdentity spec context where
26 HIdentity ::
27 { unHIdentity :: context spec
28 } -> HIdentity spec (H context)
31type HIdentityField :: Spec -> Context
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