on 2d8335d help sign in
rel8/src/Rel8/Schema/Structure.hs
53 lines 997 B 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 Rel8.Schema.Spec ( Context, Spec )
23type Structure :: Context
24data Structure spec
27type Shape :: Type
28data Shape
29 = Column Spec
30 | Either Type Type
31 | List Type
32 | Maybe Type
33 | NonEmpty Type
34 | These Type Type
37type Shape1 :: (a -> Shape) -> a -> Type
38data Shape1 shape a
41type Shape2 :: (a -> b -> Shape) -> a -> b -> Type
42data Shape2 shape a b
45type IsStructure :: Type -> Bool
46type family IsStructure a where
47 IsStructure (Shape1 _ _) = 'True
48 IsStructure (Shape2 _ _ _) = 'True
49 IsStructure (_, _) = 'True
50 IsStructure (_, _, _) = 'True
51 IsStructure (_, _, _, _) = 'True
52 IsStructure (_, _, _, _, _) = 'True
53 IsStructure _ = 'False