on 00a36f5 help sign in
rel8/src/Rel8/Schema/Structure.hs
54 lines 1.0 kB history raw
1{-# language DataKinds #-}
2{-# language StandaloneKindSignatures #-}
3{-# language PolyKinds #-}
4{-# language TypeFamilies #-}
6module Rel8.Schema.Structure
7 ( Structure
8 , Shape( Column, Either, List, Maybe, NonEmpty, These )
9 , Shape1
10 , Shape2
11 , IsStructure
12 )
13where
15-- base
16import Data.Kind ( Type )
17import Prelude
19-- rel8
20import qualified Rel8.Schema.Kind as K
21import Rel8.Schema.Spec ( Spec )
24type Structure :: K.Context
25data Structure a
28type Shape :: Type
29data Shape
30 = Column Spec
31 | Either Type Type
32 | List Type
33 | Maybe Type
34 | NonEmpty Type
35 | These Type Type
38type Shape1 :: (a -> Shape) -> a -> Type
39data Shape1 shape a
42type Shape2 :: (a -> b -> Shape) -> a -> b -> Type
43data Shape2 shape a b
46type IsStructure :: Type -> Bool
47type family IsStructure a where
48 IsStructure (Shape1 _ _) = 'True
49 IsStructure (Shape2 _ _ _) = 'True
50 IsStructure (_, _) = 'True
51 IsStructure (_, _, _) = 'True
52 IsStructure (_, _, _, _) = 'True
53 IsStructure (_, _, _, _, _) = 'True
54 IsStructure _ = 'False