1{-# LANGUAGE DeriveAnyClass #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DerivingStrategies #-}
4{-# LANGUAGE LambdaCase #-}
5{-# language ConstraintKinds #-}
6{-# language DataKinds #-}
7{-# language FlexibleInstances #-}
9{-# language InstanceSigs #-}
10{-# language MultiParamTypeClasses #-}
11{-# language QuantifiedConstraints #-}
12{-# language RankNTypes #-}
13{-# language RecordWildCards #-}
14{-# language ScopedTypeVariables #-}
15{-# language StandaloneKindSignatures #-}
16{-# language TypeApplications #-}
17{-# language TypeFamilies #-}
18{-# language TypeOperators #-}
19{-# language UndecidableInstances #-}
21module Rel8.Schema.HTable.Label
28import Data.Proxy ( Proxy( Proxy ) )
29import GHC.TypeLits ( KnownSymbol, Symbol )
33import Rel8.Kind.Labels ( SLabels( SLabels ) )
34import Rel8.Schema.HTable
36 , hfield, htabulate, hspecs
38import qualified Rel8.Schema.Kind as K
39import Rel8.Schema.Spec ( Spec( Spec ), SSpec(..) )
41import Rel8.Schema.HTable.MapTable
42import GHC.Generics (Generic)
45type HLabel :: Symbol -> K.HTable -> K.HTable
46newtype HLabel label table context = HLabel (HMapTable (Label label) table context)
47 deriving stock Generic
48 deriving anyclass HTable
51data Label :: Symbol -> Spec -> Exp Spec
54type instance Eval (Label label ('Spec labels necessity a)) = 'Spec (label : labels) necessity a
57instance KnownSymbol l => MapSpec (Label l) where
59 SSpec {..} -> SSpec {labels = SLabels Proxy labels, ..}
62hlabel :: (HTable t, KnownSymbol label)
63 => (forall labels necessity a. ()
64 => context ('Spec labels necessity a)
65 -> context ('Spec (label ': labels) necessity a))
67 -> HLabel label t context
68hlabel labeler a = HLabel $ htabulate $ \(HMapTableField field) ->
69 case hfield hspecs field of
70 SSpec {} -> labeler (hfield a field)
71{-# INLINABLE hlabel #-}
74hunlabel :: (HTable t, KnownSymbol label)
75 => (forall labels necessity a. ()
76 => context ('Spec (label ': labels) necessity a)
77 -> context ('Spec labels necessity a))
78 -> HLabel label t context
80hunlabel unlabler (HLabel as) =
82 case hfield hspecs field of
83 SSpec {} -> case hfield as (HMapTableField field) of
85{-# INLINABLE hunlabel #-}
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