1{-# LANGUAGE DeriveAnyClass #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DerivingStrategies #-}
4{-# LANGUAGE LambdaCase #-}
5{-# language ConstraintKinds #-}
6{-# language DataKinds #-}
7{-# language FlexibleInstances #-}
9{-# language MultiParamTypeClasses #-}
10{-# language QuantifiedConstraints #-}
11{-# language RankNTypes #-}
12{-# language RecordWildCards #-}
13{-# language ScopedTypeVariables #-}
14{-# language StandaloneKindSignatures #-}
15{-# language TypeFamilies #-}
16{-# language TypeOperators #-}
17{-# language UndecidableInstances #-}
19module Rel8.Schema.HTable.Label
26import Data.Proxy ( Proxy( Proxy ) )
27import GHC.TypeLits ( KnownSymbol, Symbol )
31import Rel8.Kind.Labels ( SLabels( SLabels ) )
32import Rel8.Schema.HTable
34 , hfield, htabulate, hspecs
36import qualified Rel8.Schema.Kind as K
37import Rel8.Schema.Spec ( Spec( Spec ), SSpec(..) )
39import Rel8.Schema.HTable.MapTable
40import GHC.Generics (Generic)
43type HLabel :: Symbol -> K.HTable -> K.HTable
44newtype HLabel label table context = HLabel (HMapTable (Label label) table context)
45 deriving stock Generic
46 deriving anyclass HTable
49data Label :: Symbol -> Spec -> Exp Spec
52type instance Eval (Label label ('Spec labels necessity a)) = 'Spec (label : labels) necessity a
55instance KnownSymbol l => MapSpec (Label l) where
57 SSpec {..} -> SSpec {labels = SLabels Proxy labels, ..}
60hlabel :: (HTable t, KnownSymbol label)
61 => (forall labels necessity a. ()
62 => context ('Spec labels necessity a)
63 -> context ('Spec (label ': labels) necessity a))
65 -> HLabel label t context
66hlabel labeler a = HLabel $ htabulate $ \(HMapTableField field) ->
67 case hfield hspecs field of
68 SSpec {} -> labeler (hfield a field)
69{-# INLINABLE hlabel #-}
72hunlabel :: (HTable t, KnownSymbol label)
73 => (forall labels necessity a. ()
74 => context ('Spec (label ': labels) necessity a)
75 -> context ('Spec labels necessity a))
76 -> HLabel label t context
78hunlabel unlabler (HLabel as) =
80 case hfield hspecs field of
81 SSpec {} -> case hfield as (HMapTableField field) of
83{-# 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