1{-# language AllowAmbiguousTypes #-}
2{-# language BlockArguments #-}
3{-# language ConstraintKinds #-}
4{-# language DataKinds #-}
5{-# language FlexibleInstances #-}
7{-# language InstanceSigs #-}
8{-# language MultiParamTypeClasses #-}
9{-# language PolyKinds #-}
10{-# language ScopedTypeVariables #-}
11{-# language StandaloneKindSignatures #-}
12{-# language TypeApplications #-}
13{-# language TypeFamilies #-}
14{-# language UndecidableInstances #-}
15{-# language UndecidableSuperClasses #-}
17module Rel8.Schema.HTable.MapTable
26import Data.Kind ( Constraint, Type )
27import Prelude ( ($), (.), (<$>), fmap )
31import Rel8.Schema.HTable
32import Rel8.Schema.Spec ( Spec, SSpec )
33import qualified Rel8.Schema.Kind as K
34import Rel8.Schema.Dict ( Dict( Dict ) )
37type HMapTable :: (a -> Exp b) -> ((a -> Type) -> Type) -> (b -> Type) -> Type
38newtype HMapTable f t g = HMapTable
39 { unHMapTable :: t (Precompose f g)
43type Precompose :: (a -> Exp b) -> (b -> Type) -> a -> Type
44newtype Precompose f g x = Precompose
45 { precomposed :: g (Eval (f x))
49type HMapTableField :: (Spec -> Exp a) -> K.HTable -> a -> Type
50data HMapTableField f t x where
51 HMapTableField :: HField t a -> HMapTableField f t (Eval (f a))
54instance (HTable t, MapSpec f) => HTable (HMapTable f t) where
55 type HField (HMapTable f t) =
58 type HConstrainTable (HMapTable f t) c =
59 HConstrainTable t (ComposeConstraint f c)
61 hfield (HMapTable x) (HMapTableField i) =
62 precomposed (hfield x i)
65 HMapTable $ htabulate (Precompose . f . HMapTableField)
67 htraverse f (HMapTable x) =
68 HMapTable <$> htraverse (fmap Precompose . f . precomposed) x
69 {-# INLINABLE htraverse #-}
71 hdicts :: forall c. HConstrainTable (HMapTable f t) c => HMapTable f t (Dict c)
73 htabulate \(HMapTableField j) ->
74 case hfield (hdicts @_ @(ComposeConstraint f c)) j of
78 HMapTable $ htabulate $ Precompose . mapInfo @f . hfield hspecs
79 {-# INLINABLE hspecs #-}
82type MapSpec :: (Spec -> Exp Spec) -> Constraint
84 mapInfo :: SSpec x -> SSpec (Eval (f x))
87type ComposeConstraint :: (a -> Exp b) -> (b -> Constraint) -> a -> Constraint
88class c (Eval (f a)) => ComposeConstraint f c a
89instance 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