1{-# language AllowAmbiguousTypes #-}
2{-# language BlockArguments #-}
3{-# language ConstraintKinds #-}
4{-# language DataKinds #-}
5{-# language FlexibleInstances #-}
7{-# language InstanceSigs #-}
8{-# language MultiParamTypeClasses #-}
9{-# language ScopedTypeVariables #-}
10{-# language StandaloneKindSignatures #-}
11{-# language TypeApplications #-}
12{-# language TypeFamilies #-}
13{-# language UndecidableInstances #-}
14{-# language UndecidableSuperClasses #-}
16module Rel8.Schema.HTable.MapTable
25import Data.Kind ( Constraint, Type )
29import Rel8.FCF ( Exp, Eval )
30import Rel8.Schema.HTable
31 ( HTable, HConstrainTable, HField
32 , hfield, htabulate, htraverse, hdicts, hspecs
34import Rel8.Schema.Spec ( Spec )
35import qualified Rel8.Schema.Kind as K
36import Rel8.Schema.Dict ( Dict( Dict ) )
39type HMapTable :: (Type -> Exp Type) -> K.HTable -> K.HTable
40newtype HMapTable f t context = HMapTable
41 { unHMapTable :: t (Precompose f context)
45type Precompose :: (Type -> Exp Type) -> K.Context -> K.Context
46newtype Precompose f g x = Precompose
47 { precomposed :: g (Eval (f x))
51type HMapTableField :: (Type -> Exp Type) -> K.HTable -> K.Context
52data HMapTableField f t x where
53 HMapTableField :: HField t a -> HMapTableField f t (Eval (f a))
56instance (HTable t, MapSpec f) => HTable (HMapTable f t) where
57 type HField (HMapTable f t) =
60 type HConstrainTable (HMapTable f t) c =
61 HConstrainTable t (ComposeConstraint f c)
63 hfield (HMapTable x) (HMapTableField i) =
64 precomposed (hfield x i)
67 HMapTable $ htabulate (Precompose . f . HMapTableField)
69 htraverse f (HMapTable x) =
70 HMapTable <$> htraverse (fmap Precompose . f . precomposed) x
71 {-# INLINABLE htraverse #-}
73 hdicts :: forall c. HConstrainTable (HMapTable f t) c => HMapTable f t (Dict c)
75 htabulate \(HMapTableField j) ->
76 case hfield (hdicts @_ @(ComposeConstraint f c)) j of
80 HMapTable $ htabulate $ Precompose . mapInfo @f . hfield hspecs
81 {-# INLINABLE hspecs #-}
84type MapSpec :: (Type -> Exp Type) -> Constraint
86 mapInfo :: Spec x -> Spec (Eval (f x))
89type ComposeConstraint :: (Type -> Exp Type) -> (Type -> Constraint) -> Type -> Constraint
90class c (Eval (f a)) => ComposeConstraint f c a
91instance c (Eval (f a)) => ComposeConstraint f c a
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