on 11bcbbb help sign in
52 lines 1.4 kB history raw
1{-# language DataKinds #-}
2{-# language StandaloneKindSignatures #-}
3{-# language TypeFamilies #-}
4{-# language TypeOperators #-}
6module Rel8.Schema.Context.Label
7 ( Labelable( labeler, unlabeler )
8 , HLabelable( hlabeler, hunlabeler )
9 )
10where
12-- base
13import Data.Functor.Identity ( Identity )
14import Data.Kind ( Constraint )
15import Prelude hiding ( null )
17-- rel8
18import Rel8.Schema.Context ( Interpretation, Col(..) )
19import Rel8.Schema.Kind ( Context, HContext )
20import Rel8.Schema.Spec ( Spec( Spec ) )
23type Labelable :: Context -> Constraint
24class Interpretation context => Labelable context where
25 labeler :: ()
26 => Col context ('Spec labels necessity a)
27 -> Col context ('Spec (label ': labels) necessity a)
29 unlabeler :: ()
30 => Col context ('Spec (label ': labels) necessity a)
31 -> Col context ('Spec labels necessity a)
34instance Labelable Identity where
35 labeler (Result a) = Result a
36 unlabeler (Result a) = Result a
39type HLabelable :: HContext -> Constraint
40class HLabelable context where
41 hlabeler :: ()
42 => context ('Spec labels necessity a)
43 -> context ('Spec (label ': labels) necessity a)
45 hunlabeler :: ()
46 => context ('Spec (label ': labels) necessity a)
47 -> context ('Spec labels necessity a)
50instance Labelable context => HLabelable (Col context) where
51 hlabeler = labeler
52 hunlabeler = unlabeler