on master help sign in
Unify HType and HIdentity
2615b89Shane O'Brien
rel8.cabal−1
@@ -124,7 +124,6 @@ library
124 Rel8.Schema.HTable.Nullify
124 Rel8.Schema.HTable.Nullify
125 Rel8.Schema.HTable.Product
125 Rel8.Schema.HTable.Product
126 Rel8.Schema.HTable.These
126 Rel8.Schema.HTable.These
127− Rel8.Schema.HTable.Type
128 Rel8.Schema.HTable.Vectorize
127 Rel8.Schema.HTable.Vectorize
129 Rel8.Schema.Insert
128 Rel8.Schema.Insert
130 Rel8.Schema.Kind
129 Rel8.Schema.Kind
src/Rel8/Expr.hs+1−1
@@ -39,7 +39,7 @@ import Rel8.Expr.Opaleye
39import Rel8.Expr.Serialize ( litExpr )
39import Rel8.Expr.Serialize ( litExpr )
40import Rel8.Schema.Context ( Interpretation, Col )
40import Rel8.Schema.Context ( Interpretation, Col )
41import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
41import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
42−import Rel8.Schema.HTable.Type ( HType( HType ) )
42+import Rel8.Schema.HTable.Identity ( HIdentity( HType ), HType )
43import Rel8.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable )
43import Rel8.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable )
44import Rel8.Schema.Reify ( notReify )
44import Rel8.Schema.Reify ( notReify )
45import Rel8.Schema.Result ( Result )
45import Rel8.Schema.Result ( Result )
src/Rel8/Generic/Construction.hs+1−1
@@ -59,7 +59,7 @@ import qualified Rel8.Kind.Algebra as K
59import Rel8.Kind.Necessity ( SNecessity( SOptional, SRequired ) )
59import Rel8.Kind.Necessity ( SNecessity( SOptional, SRequired ) )
60import Rel8.Schema.Context.Nullify ( runTag )
60import Rel8.Schema.Context.Nullify ( runTag )
61import Rel8.Schema.HTable ( HTable )
61import Rel8.Schema.HTable ( HTable )
62−import Rel8.Schema.HTable.Type ( HType( HType ) )
62+import Rel8.Schema.HTable.Identity ( HIdentity( HType ) )
63import Rel8.Schema.Insert ( Col( OptionalInsert, RequiredInsert ), Insert )
63import Rel8.Schema.Insert ( Col( OptionalInsert, RequiredInsert ), Insert )
64import qualified Rel8.Schema.Kind as K
64import qualified Rel8.Schema.Kind as K
65import Rel8.Schema.Name ( Col( NameCol ), Name( Name ) )
65import Rel8.Schema.Name ( Col( NameCol ), Name( Name ) )
src/Rel8/Generic/Construction/ADT.hs+1−1
@@ -47,10 +47,10 @@ import Rel8.Generic.Table.ADT ( GColumnsADT, GColumnsADT' )
47import Rel8.Generic.Table.Record ( GColumns )
47import Rel8.Generic.Table.Record ( GColumns )
48import Rel8.Schema.Context.Label ( HLabelable, hlabeler, hunlabeler )
48import Rel8.Schema.Context.Label ( HLabelable, hlabeler, hunlabeler )
49import Rel8.Schema.HTable ( HTable )
49import Rel8.Schema.HTable ( HTable )
50+import Rel8.Schema.HTable.Identity ( HType )
50import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
51import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
51import Rel8.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify )
52import Rel8.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify )
52import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
53import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
53−import Rel8.Schema.HTable.Type ( HType )
54import Rel8.Schema.Null ( Nullify )
54import Rel8.Schema.Null ( Nullify )
55import Rel8.Schema.Spec ( Spec( Spec ), SSpec )
55import Rel8.Schema.Spec ( Spec( Spec ), SSpec )
56import qualified Rel8.Schema.Kind as K
56import qualified Rel8.Schema.Kind as K
src/Rel8/Generic/Table/ADT.hs+1−1
@@ -39,10 +39,10 @@ import Rel8.Generic.Table.Record
39 )
39 )
40import Rel8.Schema.Context.Label ( HLabelable, hlabeler, labeler, unlabeler )
40import Rel8.Schema.Context.Label ( HLabelable, hlabeler, labeler, unlabeler )
41import Rel8.Schema.HTable ( HTable, hmap )
41import Rel8.Schema.HTable ( HTable, hmap )
42+import Rel8.Schema.HTable.Identity ( HIdentity( HType ), HType )
42import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
43import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
43import Rel8.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify )
44import Rel8.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify )
44import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
45import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
45−import Rel8.Schema.HTable.Type ( HType( HType ) )
46import qualified Rel8.Schema.Kind as K
46import qualified Rel8.Schema.Kind as K
47import Rel8.Schema.Null ( Nullify )
47import Rel8.Schema.Null ( Nullify )
48import Rel8.Schema.Spec ( Spec( Spec ), SSpec )
48import Rel8.Schema.Spec ( Spec( Spec ), SSpec )
src/Rel8/Schema/HTable/Identity.hs+14−2
@@ -1,10 +1,12 @@
1{-# language DataKinds #-}
1{-# language DataKinds #-}
2{-# language GADTs #-}
2{-# language GADTs #-}
3+{-# language PatternSynonyms #-}
3{-# language StandaloneKindSignatures #-}
4{-# language StandaloneKindSignatures #-}
4{-# language TypeFamilies #-}
5{-# language TypeFamilies #-}
5
6
6module Rel8.Schema.HTable.Identity
7module Rel8.Schema.HTable.Identity
7− ( HIdentity(..)
8+ ( HIdentity( HIdentity, HType, unHIdentity )
9+ , HType
8 )
10 )
9where
11where
10
12
@@ -13,13 +15,23 @@ import Data.Kind ( Type )
13import Prelude
15import Prelude
14
16
15-- rel8
17-- rel8
18+import Rel8.Kind.Necessity ( Necessity( Required ) )
16import Rel8.Schema.Dict ( Dict( Dict ) )
19import Rel8.Schema.Dict ( Dict( Dict ) )
17import Rel8.Schema.HTable
20import Rel8.Schema.HTable
18 ( HTable, HConstrainTable, HField
21 ( HTable, HConstrainTable, HField
19 , hfield, htabulate, htraverse, hdicts, hspecs
22 , hfield, htabulate, htraverse, hdicts, hspecs
20 )
23 )
21import qualified Rel8.Schema.Kind as K
24import qualified Rel8.Schema.Kind as K
22−import Rel8.Schema.Spec ( Spec, KnownSpec, specSing )
25+import Rel8.Schema.Spec ( Spec( Spec ), KnownSpec, specSing )
26+
27+
28+type HType :: Type -> K.HTable
29+type HType a = HIdentity ('Spec '[] 'Required a)
30+
31+
32+pattern HType :: context ('Spec '[] 'Required a) -> HType a context
33+pattern HType a = HIdentity a
34+{-# COMPLETE HType #-}
23
35
24
36
25type HIdentity :: Spec -> K.HTable
37type HIdentity :: Spec -> K.HTable
src/Rel8/Schema/HTable/Type.hsdeleted−60
@@ -1,60 +0,0 @@
1−{-# language DataKinds #-}
2−{-# language GADTs #-}
3−{-# language StandaloneKindSignatures #-}
4−{-# language TypeFamilies #-}
5−{-# language UndecidableInstances #-}
6−
7−module Rel8.Schema.HTable.Type
8− ( HType(..)
9− )
10−where
11−
12−-- base
13−import Data.Kind ( Type )
14−import Prelude
15−
16−-- rel8
17−import Rel8.Kind.Labels ( SLabels( SNil ) )
18−import Rel8.Kind.Necessity ( Necessity( Required ), SNecessity( SRequired ) )
19−import Rel8.Schema.Dict ( Dict( Dict ) )
20−import Rel8.Schema.HTable
21− ( HTable, HConstrainTable, HField
22− , hfield, htabulate, htraverse, hdicts, hspecs
23− )
24−import qualified Rel8.Schema.Kind as K
25−import Rel8.Schema.Null ( Sql, nullable )
26−import Rel8.Schema.Spec ( Spec( Spec ), SSpec(..) )
27−import Rel8.Type ( DBType, typeInformation )
28−
29−
30−type HType :: Type -> K.HTable
31−newtype HType a context = HType
32− { unHType :: context ('Spec '[] 'Required a)
33− }
34−
35−
36−type HTypeField :: Type -> Spec -> Type
37−data HTypeField a spec where
38− HTypeField :: HTypeField a ('Spec '[] 'Required a)
39−
40−
41−instance Sql DBType a => HTable (HType a) where
42− type HConstrainTable (HType a) c = c ('Spec '[] 'Required a)
43− type HField (HType a) = HTypeField a
44−
45− hfield (HType a) HTypeField = a
46− htabulate f = HType $ f HTypeField
47− htraverse f (HType a) = HType <$> f a
48− hdicts = HType Dict
49− hspecs = HType SSpec
50− { labels = SNil
51− , necessity = SRequired
52− , info = typeInformation
53− , nullity = nullable
54− }
55−
56− {-# INLINABLE hfield #-}
57− {-# INLINABLE htabulate #-}
58− {-# INLINABLE htraverse #-}
59− {-# INLINABLE hdicts #-}
60− {-# INLINABLE hspecs #-}
src/Rel8/Schema/Insert.hs+1−1
@@ -36,7 +36,7 @@ import Rel8.Schema.Context.Nullify
36 ( Nullifiable, encodeTag, decodeTag, nullifier, unnullifier
36 ( Nullifiable, encodeTag, decodeTag, nullifier, unnullifier
37 , runTag, unnull
37 , runTag, unnull
38 )
38 )
39−import Rel8.Schema.HTable.Type ( HType( HType ) )
39+import Rel8.Schema.HTable.Identity ( HIdentity( HType ), HType )
40import Rel8.Schema.Name ( Name, Selects )
40import Rel8.Schema.Name ( Name, Selects )
41import Rel8.Schema.Null ( Sql )
41import Rel8.Schema.Null ( Sql )
42import Rel8.Schema.Reify ( notReify )
42import Rel8.Schema.Reify ( notReify )
src/Rel8/Schema/Name.hs+1−1
@@ -29,7 +29,7 @@ import Prelude
29import Rel8.Expr ( Expr )
29import Rel8.Expr ( Expr )
30import Rel8.Schema.Context ( Interpretation, Col )
30import Rel8.Schema.Context ( Interpretation, Col )
31import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
31import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
32−import Rel8.Schema.HTable.Type ( HType( HType ) )
32+import Rel8.Schema.HTable.Identity ( HIdentity( HType ), HType )
33import Rel8.Schema.Null ( Sql )
33import Rel8.Schema.Null ( Sql )
34import Rel8.Schema.Reify ( notReify )
34import Rel8.Schema.Reify ( notReify )
35import Rel8.Schema.Result ( Result )
35import Rel8.Schema.Result ( Result )
src/Rel8/Table.hs+1−2
@@ -44,14 +44,13 @@ import Rel8.Generic.Reify ( ARep )
44import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
44import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
45import Rel8.Schema.HTable ( HTable )
45import Rel8.Schema.HTable ( HTable )
46import Rel8.Schema.HTable.Either ( HEitherTable(..) )
46import Rel8.Schema.HTable.Either ( HEitherTable(..) )
47−import Rel8.Schema.HTable.Identity ( HIdentity(..) )
47+import Rel8.Schema.HTable.Identity ( HIdentity(..), HType )
48import Rel8.Schema.HTable.Label ( hlabel, hunlabel )
48import Rel8.Schema.HTable.Label ( hlabel, hunlabel )
49import Rel8.Schema.HTable.List ( HListTable )
49import Rel8.Schema.HTable.List ( HListTable )
50import Rel8.Schema.HTable.Maybe ( HMaybeTable(..) )
50import Rel8.Schema.HTable.Maybe ( HMaybeTable(..) )
51import Rel8.Schema.HTable.NonEmpty ( HNonEmptyTable )
51import Rel8.Schema.HTable.NonEmpty ( HNonEmptyTable )
52import Rel8.Schema.HTable.Nullify ( hnulls, hnullify, hunnullify )
52import Rel8.Schema.HTable.Nullify ( hnulls, hnullify, hunnullify )
53import Rel8.Schema.HTable.These ( HTheseTable(..) )
53import Rel8.Schema.HTable.These ( HTheseTable(..) )
54−import Rel8.Schema.HTable.Type ( HType( HType ) )
55import Rel8.Schema.HTable.Vectorize ( hvectorize, hunvectorize )
54import Rel8.Schema.HTable.Vectorize ( hvectorize, hunvectorize )
56import qualified Rel8.Schema.Kind as K
55import qualified Rel8.Schema.Kind as K
57import Rel8.Schema.Null ( Sql )
56import Rel8.Schema.Null ( Sql )
src/Rel8/Table/Eq.hs+1−1
@@ -43,7 +43,7 @@ import Rel8.Schema.HTable
43 ( HTable, HConstrainTable
43 ( HTable, HConstrainTable
44 , htabulateA, hfield, hdicts
44 , htabulateA, hfield, hdicts
45 )
45 )
46−import Rel8.Schema.HTable.Type ( HType(..) )
46+import Rel8.Schema.HTable.Identity ( HIdentity( HType ) )
47import Rel8.Schema.Null ( Sql )
47import Rel8.Schema.Null ( Sql )
48import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType, nullifier )
48import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType, nullifier )
49import Rel8.Table ( Table, Columns, toColumns, TColumns )
49import Rel8.Table ( Table, Columns, toColumns, TColumns )
src/Rel8/Table/Ord.hs+1−1
@@ -41,7 +41,7 @@ import Rel8.Schema.HTable
41 ( HTable, HConstrainTable
41 ( HTable, HConstrainTable
42 , htabulateA, hfield, hdicts
42 , htabulateA, hfield, hdicts
43 )
43 )
44−import Rel8.Schema.HTable.Type ( HType(..) )
44+import Rel8.Schema.HTable.Identity ( HIdentity( HType ) )
45import Rel8.Schema.Null (Sql)
45import Rel8.Schema.Null (Sql)
46import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType, nullifier )
46import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType, nullifier )
47import Rel8.Table ( Columns, toColumns, TColumns )
47import Rel8.Table ( Columns, toColumns, TColumns )
src/Rel8/Table/Serialize.hs+1−1
@@ -40,7 +40,7 @@ import Rel8.Generic.Table
40 )
40 )
41import Rel8.Kind.Algebra ( KnownAlgebra )
41import Rel8.Kind.Algebra ( KnownAlgebra )
42import Rel8.Schema.HTable ( HTable, htabulate, htabulateA, hfield, hspecs )
42import Rel8.Schema.HTable ( HTable, htabulate, htabulateA, hfield, hspecs )
43−import Rel8.Schema.HTable.Type ( HType(..) )
43+import Rel8.Schema.HTable.Identity ( HIdentity( HType ) )
44import Rel8.Schema.Null ( NotNull, Sql )
44import Rel8.Schema.Null ( NotNull, Sql )
45import Rel8.Schema.Result ( Col( Result ), Result )
45import Rel8.Schema.Result ( Col( Result ), Result )
46import Rel8.Schema.Spec ( SSpec(..), KnownSpec )
46import Rel8.Schema.Spec ( SSpec(..), KnownSpec )