diff --git a/cabal.project b/cabal.project index 9c5314c1..2a04d302 100644 --- a/cabal.project +++ b/cabal.project @@ -1,4 +1,6 @@ -packages: . +packages: + rel8/rel8.cabal, + rel8-internal/rel8-internal.cabal source-repository-package type: git diff --git a/changelog.d/scriv.ini b/changelog.d/scriv.ini index 94954cc9..54cb8710 100644 --- a/changelog.d/scriv.ini +++ b/changelog.d/scriv.ini @@ -1,3 +1,3 @@ [scriv] format = md -output_file = Changelog.md +output_file = rel8/Changelog.md diff --git a/LICENSE b/rel8-internal/LICENSE similarity index 100% rename from LICENSE rename to rel8-internal/LICENSE diff --git a/rel8-internal/rel8-internal.cabal b/rel8-internal/rel8-internal.cabal new file mode 100644 index 00000000..275dbf63 --- /dev/null +++ b/rel8-internal/rel8-internal.cabal @@ -0,0 +1,244 @@ +cabal-version: 3.0 +name: rel8-internal +version: 1.7.0.0 +synopsis: Internals of rel8 +license: BSD-3-Clause +license-file: LICENSE +author: Oliver Charles +maintainer: ollie@ocharles.org.uk +homepage: https://github.com/circuithub/rel8 +bug-reports: https://github.com/circuithub/rel8/issues +build-type: Simple + +source-repository head + type: git + location: https://github.com/circuithub/rel8 + subdir: rel8-internal + +library + build-depends: + aeson + , attoparsec + , base >= 4.16 && < 4.23 + , base16 >= 1.0 + , base-compat >= 0.11 && < 0.15 + , bytestring + , case-insensitive + , comonad + , containers + , contravariant + , hasql >= 1.8 && < 1.10 + , iproute ^>= 1.7 + , opaleye ^>= 0.10.2.1 + , postgresql-binary ^>= 0.14.2 + , pretty + , profunctors + , product-profunctors + , scientific + , semialign + , semigroupoids + , text + , these + , time + , transformers + , utf8-string + , uuid + , vector + + default-language: + Haskell2010 + ghc-options: + -Werror=missing-methods -Werror=incomplete-patterns -Werror=missing-fields + -Weverything -Wno-unsafe -Wno-safe -Wno-missing-safe-haskell-mode + -Wno-missing-import-lists -Wno-prepositive-qualified-module + -Wno-monomorphism-restriction + -Wno-missing-local-signatures + -Wno-missing-kind-signatures + -Wno-missing-role-annotations + -Wno-missing-deriving-strategies + -Wno-term-variable-capture + -Wno-missed-specializations + + hs-source-dirs: + src + + exposed-modules: + Rel8.Internal.Aggregate + Rel8.Internal.Aggregate.Fold + Rel8.Internal.Aggregate.Function + Rel8.Internal.Aggregate.Range + + Rel8.Internal.Column + Rel8.Internal.Column.ADT + Rel8.Internal.Column.Either + Rel8.Internal.Column.Lift + Rel8.Internal.Column.List + Rel8.Internal.Column.Maybe + Rel8.Internal.Column.NonEmpty + Rel8.Internal.Column.Null + Rel8.Internal.Column.These + + Rel8.Internal.Data.Range + + Rel8.Internal.Expr + Rel8.Internal.Expr.Aggregate + Rel8.Internal.Expr.Array + Rel8.Internal.Expr.Bool + Rel8.Internal.Expr.Default + Rel8.Internal.Expr.Eq + Rel8.Internal.Expr.Function + Rel8.Internal.Expr.List + Rel8.Internal.Expr.NonEmpty + Rel8.Internal.Expr.Null + Rel8.Internal.Expr.Opaleye + Rel8.Internal.Expr.Ord + Rel8.Internal.Expr.Order + Rel8.Internal.Expr.Range + Rel8.Internal.Expr.Read + Rel8.Internal.Expr.Sequence + Rel8.Internal.Expr.Serialize + Rel8.Internal.Expr.Show + Rel8.Internal.Expr.Subscript + Rel8.Internal.Expr.Text + Rel8.Internal.Expr.Window + + Rel8.Internal.FCF + + Rel8.Internal.Kind.Algebra + Rel8.Internal.Kind.Context + + Rel8.Internal.Generic.Construction + Rel8.Internal.Generic.Construction.ADT + Rel8.Internal.Generic.Construction.Record + Rel8.Internal.Generic.Map + Rel8.Internal.Generic.Record + Rel8.Internal.Generic.Rel8able + Rel8.Internal.Generic.Table + Rel8.Internal.Generic.Table.ADT + Rel8.Internal.Generic.Table.Record + + Rel8.Internal.Order + + Rel8.Internal.Query + Rel8.Internal.Query.Aggregate + Rel8.Internal.Query.Distinct + Rel8.Internal.Query.Each + Rel8.Internal.Query.Either + Rel8.Internal.Query.Evaluate + Rel8.Internal.Query.Exists + Rel8.Internal.Query.Filter + Rel8.Internal.Query.Function + Rel8.Internal.Query.Indexed + Rel8.Internal.Query.Limit + Rel8.Internal.Query.List + Rel8.Internal.Query.Loop + Rel8.Internal.Query.Materialize + Rel8.Internal.Query.Maybe + Rel8.Internal.Query.Null + Rel8.Internal.Query.Opaleye + Rel8.Internal.Query.Order + Rel8.Internal.Query.Rebind + Rel8.Internal.Query.Set + Rel8.Internal.Query.SQL + Rel8.Internal.Query.These + Rel8.Internal.Query.Values + Rel8.Internal.Query.Window + + Rel8.Internal.Schema.Context.Nullify + Rel8.Internal.Schema.Dict + Rel8.Internal.Schema.Escape + Rel8.Internal.Schema.Field + Rel8.Internal.Schema.HTable + Rel8.Internal.Schema.HTable.Either + Rel8.Internal.Schema.HTable.Identity + Rel8.Internal.Schema.HTable.Label + Rel8.Internal.Schema.HTable.List + Rel8.Internal.Schema.HTable.MapTable + Rel8.Internal.Schema.HTable.Maybe + Rel8.Internal.Schema.HTable.NonEmpty + Rel8.Internal.Schema.HTable.Nullify + Rel8.Internal.Schema.HTable.Product + Rel8.Internal.Schema.HTable.These + Rel8.Internal.Schema.HTable.Vectorize + Rel8.Internal.Schema.Kind + Rel8.Internal.Schema.Name + Rel8.Internal.Schema.Null + Rel8.Internal.Schema.QualifiedName + Rel8.Internal.Schema.Result + Rel8.Internal.Schema.Spec + Rel8.Internal.Schema.Table + + Rel8.Internal.Statement + Rel8.Internal.Statement.Delete + Rel8.Internal.Statement.Insert + Rel8.Internal.Statement.OnConflict + Rel8.Internal.Statement.Prepared + Rel8.Internal.Statement.Returning + Rel8.Internal.Statement.Rows + Rel8.Internal.Statement.Run + Rel8.Internal.Statement.Select + Rel8.Internal.Statement.Set + Rel8.Internal.Statement.SQL + Rel8.Internal.Statement.Update + Rel8.Internal.Statement.Using + Rel8.Internal.Statement.View + Rel8.Internal.Statement.Where + + Rel8.Internal.Table + Rel8.Internal.Table.ADT + Rel8.Internal.Table.Aggregate + Rel8.Internal.Table.Aggregate.Maybe + Rel8.Internal.Table.Alternative + Rel8.Internal.Table.Bool + Rel8.Internal.Table.Cols + Rel8.Internal.Table.Either + Rel8.Internal.Table.Eq + Rel8.Internal.Table.HKD + Rel8.Internal.Table.List + Rel8.Internal.Table.Maybe + Rel8.Internal.Table.Name + Rel8.Internal.Table.NonEmpty + Rel8.Internal.Table.Null + Rel8.Internal.Table.Nullify + Rel8.Internal.Table.Opaleye + Rel8.Internal.Table.Ord + Rel8.Internal.Table.Order + Rel8.Internal.Table.Projection + Rel8.Internal.Table.Rel8able + Rel8.Internal.Table.Serialize + Rel8.Internal.Table.These + Rel8.Internal.Table.Transpose + Rel8.Internal.Table.Undefined + Rel8.Internal.Table.Verify + Rel8.Internal.Table.Window + + Rel8.Internal.Type + Rel8.Internal.Type.Array + Rel8.Internal.Type.Builder.ByteString + Rel8.Internal.Type.Builder.Fold + Rel8.Internal.Type.Builder.Time + Rel8.Internal.Type.Composite + Rel8.Internal.Type.Decimal + Rel8.Internal.Type.Decoder + Rel8.Internal.Type.Eq + Rel8.Internal.Type.Encoder + Rel8.Internal.Type.Enum + Rel8.Internal.Type.Information + Rel8.Internal.Type.JSONEncoded + Rel8.Internal.Type.JSONBEncoded + Rel8.Internal.Type.Monoid + Rel8.Internal.Type.Name + Rel8.Internal.Type.Nullable + Rel8.Internal.Type.Num + Rel8.Internal.Type.Ord + Rel8.Internal.Type.Parser + Rel8.Internal.Type.Parser.ByteString + Rel8.Internal.Type.Parser.Time + Rel8.Internal.Type.Range + Rel8.Internal.Type.ReadShow + Rel8.Internal.Type.Semigroup + Rel8.Internal.Type.String + Rel8.Internal.Type.Sum + Rel8.Internal.Type.Tag + + Rel8.Internal.Window diff --git a/src/Rel8/Aggregate.hs b/rel8-internal/src/Rel8/Internal/Aggregate.hs similarity index 96% rename from src/Rel8/Aggregate.hs rename to rel8-internal/src/Rel8/Internal/Aggregate.hs index da611aee..7a382823 100644 --- a/src/Rel8/Aggregate.hs +++ b/rel8-internal/src/Rel8/Internal/Aggregate.hs @@ -4,7 +4,7 @@ {-# language ScopedTypeVariables #-} {-# language StandaloneKindSignatures #-} -module Rel8.Aggregate +module Rel8.Internal.Aggregate ( Aggregator' (Aggregator) , Aggregator , Aggregator1 @@ -35,9 +35,9 @@ import Data.Profunctor.Product import Data.Profunctor (Profunctor, dimap) -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (toPrimExpr, toColumn) -import Rel8.Aggregate.Fold (Fallback (Empty, Fallback), Fold (Full, Semi)) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (toPrimExpr, toColumn) +import Rel8.Internal.Aggregate.Fold (Fallback (Empty, Fallback), Fold (Full, Semi)) -- semigroupoids import Data.Functor.Apply (Apply, liftF2) diff --git a/src/Rel8/Aggregate/Fold.hs b/rel8-internal/src/Rel8/Internal/Aggregate/Fold.hs similarity index 97% rename from src/Rel8/Aggregate/Fold.hs rename to rel8-internal/src/Rel8/Internal/Aggregate/Fold.hs index 8cedca4b..9c4f9233 100644 --- a/src/Rel8/Aggregate/Fold.hs +++ b/rel8-internal/src/Rel8/Internal/Aggregate/Fold.hs @@ -3,7 +3,7 @@ {-# language LambdaCase #-} {-# language StandaloneKindSignatures #-} -module Rel8.Aggregate.Fold +module Rel8.Internal.Aggregate.Fold ( Fallback (Empty, Fallback) , Fold (Semi, Full) ) diff --git a/src/Rel8/Aggregate/Function.hs b/rel8-internal/src/Rel8/Internal/Aggregate/Function.hs similarity index 63% rename from src/Rel8/Aggregate/Function.hs rename to rel8-internal/src/Rel8/Internal/Aggregate/Function.hs index 7e5f41cb..06a22049 100644 --- a/src/Rel8/Aggregate/Function.hs +++ b/rel8-internal/src/Rel8/Internal/Aggregate/Function.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Aggregate.Function ( +module Rel8.Internal.Aggregate.Function ( aggregateFunction, rawAggregateFunction, ) where @@ -14,15 +14,15 @@ import qualified Opaleye.Internal.Aggregate as Opaleye import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Aggregate (Aggregator1, unsafeMakeAggregator) -import Rel8.Aggregate.Fold (Fallback (Empty)) -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (castExpr, fromColumn, fromPrimExpr) -import Rel8.Schema.Null (Sql) -import Rel8.Schema.QualifiedName (QualifiedName, showQualifiedName) -import Rel8.Table (Table) -import Rel8.Table.Opaleye (unpackspec) -import Rel8.Type (DBType) +import Rel8.Internal.Aggregate (Aggregator1, unsafeMakeAggregator) +import Rel8.Internal.Aggregate.Fold (Fallback (Empty)) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (castExpr, fromColumn, fromPrimExpr) +import Rel8.Internal.Schema.Null (Sql) +import Rel8.Internal.Schema.QualifiedName (QualifiedName, showQualifiedName) +import Rel8.Internal.Table (Table) +import Rel8.Internal.Table.Opaleye (unpackspec) +import Rel8.Internal.Type (DBType) -- | 'aggregateFunction' allows the use use of custom aggregation functions diff --git a/rel8-internal/src/Rel8/Internal/Aggregate/Range.hs b/rel8-internal/src/Rel8/Internal/Aggregate/Range.hs new file mode 100644 index 00000000..27b7b6b3 --- /dev/null +++ b/rel8-internal/src/Rel8/Internal/Aggregate/Range.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Rel8.Internal.Aggregate.Range ( + rangeAgg, +) where + +-- base +import Prelude + +-- rel8 +import Rel8.Internal.Aggregate (Aggregator', toAggregator) +import Rel8.Internal.Aggregate.Function (aggregateFunction) +import Rel8.Internal.Data.Range (Multirange, Range) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Type.Range (DBRange) + + +rangeAgg :: + DBRange a => + Aggregator' fold (Expr (Range a)) (Expr (Multirange a)) +rangeAgg = toAggregator mempty $ aggregateFunction "range_agg" diff --git a/src/Rel8/Column.hs b/rel8-internal/src/Rel8/Internal/Column.hs similarity index 79% rename from src/Rel8/Column.hs rename to rel8-internal/src/Rel8/Internal/Column.hs index 730f1d54..2e7590f4 100644 --- a/src/Rel8/Column.hs +++ b/rel8-internal/src/Rel8/Internal/Column.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilies #-} -module Rel8.Column +module Rel8.Internal.Column ( Column , TColumn ) @@ -13,9 +13,9 @@ import Data.Kind ( Type ) import Prelude () -- rel8 -import Rel8.FCF ( Eval, Exp ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) +import Rel8.Internal.FCF ( Eval, Exp ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) -- | This type family is used to specify columns in 'Rel8able's. In @Column f diff --git a/src/Rel8/Column/ADT.hs b/rel8-internal/src/Rel8/Internal/Column/ADT.hs similarity index 66% rename from src/Rel8/Column/ADT.hs rename to rel8-internal/src/Rel8/Internal/Column/ADT.hs index 3b3ceb66..0751751e 100644 --- a/src/Rel8/Column/ADT.hs +++ b/rel8-internal/src/Rel8/Internal/Column/ADT.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilies #-} -module Rel8.Column.ADT +module Rel8.Internal.Column.ADT ( HADT ) where @@ -12,9 +12,9 @@ import Data.Kind ( Type ) import Prelude () -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.ADT ( ADT ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.ADT ( ADT ) type HADT :: K.Context -> K.Rel8able -> Type diff --git a/src/Rel8/Column/Either.hs b/rel8-internal/src/Rel8/Internal/Column/Either.hs similarity index 75% rename from src/Rel8/Column/Either.hs rename to rel8-internal/src/Rel8/Internal/Column/Either.hs index 140539e4..3bb51759 100644 --- a/src/Rel8/Column/Either.hs +++ b/rel8-internal/src/Rel8/Internal/Column/Either.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilyDependencies #-} -module Rel8.Column.Either +module Rel8.Internal.Column.Either ( HEither ) where @@ -12,9 +12,9 @@ import Data.Kind ( Type ) import Prelude -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.Either ( EitherTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.Either ( EitherTable ) -- | Nest an 'Either' value within a 'Rel8able'. @HEither f a b@ will produce a diff --git a/src/Rel8/Column/Lift.hs b/rel8-internal/src/Rel8/Internal/Column/Lift.hs similarity index 64% rename from src/Rel8/Column/Lift.hs rename to rel8-internal/src/Rel8/Internal/Column/Lift.hs index 9dc25b00..a457b297 100644 --- a/src/Rel8/Column/Lift.hs +++ b/rel8-internal/src/Rel8/Internal/Column/Lift.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilies #-} -module Rel8.Column.Lift +module Rel8.Internal.Column.Lift ( Lift ) where @@ -12,9 +12,9 @@ import Data.Kind ( Type ) import Prelude () -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.HKD ( HKD ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.HKD ( HKD ) type Lift :: K.Context -> Type -> Type diff --git a/src/Rel8/Column/List.hs b/rel8-internal/src/Rel8/Internal/Column/List.hs similarity index 73% rename from src/Rel8/Column/List.hs rename to rel8-internal/src/Rel8/Internal/Column/List.hs index f0024fea..abb8b812 100644 --- a/src/Rel8/Column/List.hs +++ b/rel8-internal/src/Rel8/Internal/Column/List.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilyDependencies #-} -module Rel8.Column.List +module Rel8.Internal.Column.List ( HList ) where @@ -12,9 +12,9 @@ import Data.Kind ( Type ) import Prelude () -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.List ( ListTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.List ( ListTable ) -- | Nest a list within a 'Rel8able'. @HList f a@ will produce a 'ListTable' diff --git a/src/Rel8/Column/Maybe.hs b/rel8-internal/src/Rel8/Internal/Column/Maybe.hs similarity index 74% rename from src/Rel8/Column/Maybe.hs rename to rel8-internal/src/Rel8/Internal/Column/Maybe.hs index 6955cc81..39fc0db4 100644 --- a/src/Rel8/Column/Maybe.hs +++ b/rel8-internal/src/Rel8/Internal/Column/Maybe.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilyDependencies #-} -module Rel8.Column.Maybe +module Rel8.Internal.Column.Maybe ( HMaybe ) where @@ -12,9 +12,9 @@ import Data.Kind ( Type ) import Prelude -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.Maybe ( MaybeTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.Maybe ( MaybeTable ) -- | Nest a 'Maybe' value within a 'Rel8able'. @HMaybe f a@ will produce a diff --git a/src/Rel8/Column/NonEmpty.hs b/rel8-internal/src/Rel8/Internal/Column/NonEmpty.hs similarity index 76% rename from src/Rel8/Column/NonEmpty.hs rename to rel8-internal/src/Rel8/Internal/Column/NonEmpty.hs index 5029b801..f47fab80 100644 --- a/src/Rel8/Column/NonEmpty.hs +++ b/rel8-internal/src/Rel8/Internal/Column/NonEmpty.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilyDependencies #-} -module Rel8.Column.NonEmpty +module Rel8.Internal.Column.NonEmpty ( HNonEmpty ) where @@ -13,9 +13,9 @@ import Data.List.NonEmpty ( NonEmpty ) import Prelude () -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.NonEmpty ( NonEmptyTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.NonEmpty ( NonEmptyTable ) -- | Nest a 'NonEmpty' list within a 'Rel8able'. @HNonEmpty f a@ will produce a diff --git a/src/Rel8/Column/Null.hs b/rel8-internal/src/Rel8/Internal/Column/Null.hs similarity index 74% rename from src/Rel8/Column/Null.hs rename to rel8-internal/src/Rel8/Internal/Column/Null.hs index 43c75420..650bb900 100644 --- a/src/Rel8/Column/Null.hs +++ b/rel8-internal/src/Rel8/Internal/Column/Null.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilyDependencies #-} -module Rel8.Column.Null +module Rel8.Internal.Column.Null ( HNull ) where @@ -12,9 +12,9 @@ import Data.Kind ( Type ) import Prelude -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.Null ( NullTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.Null ( NullTable ) -- | Nest a 'Null' value within a 'Rel8able'. @HNull f a@ will produce a diff --git a/src/Rel8/Column/These.hs b/rel8-internal/src/Rel8/Internal/Column/These.hs similarity index 76% rename from src/Rel8/Column/These.hs rename to rel8-internal/src/Rel8/Internal/Column/These.hs index c6a46316..badaa87d 100644 --- a/src/Rel8/Column/These.hs +++ b/rel8-internal/src/Rel8/Internal/Column/These.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilyDependencies #-} -module Rel8.Column.These +module Rel8.Internal.Column.These ( HThese ) where @@ -12,9 +12,9 @@ import Data.Kind ( Type ) import Prelude () -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) -import Rel8.Table.These ( TheseTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table.These ( TheseTable ) -- these import Data.These ( These ) diff --git a/src/Rel8/Data/Range.hs b/rel8-internal/src/Rel8/Internal/Data/Range.hs similarity index 91% rename from src/Rel8/Data/Range.hs rename to rel8-internal/src/Rel8/Internal/Data/Range.hs index 3a85ef13..cbc78fbf 100644 --- a/src/Rel8/Data/Range.hs +++ b/rel8-internal/src/Rel8/Internal/Data/Range.hs @@ -7,7 +7,7 @@ {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-orphans #-} -module Rel8.Data.Range ( +module Rel8.Internal.Data.Range ( Bound (Incl, Excl, Inf), Range (Empty, Range), quoteRange, @@ -46,25 +46,25 @@ import PostgreSQL.Binary.Range (Bound (Incl, Excl, Inf), Range (Empty, Range)) import qualified PostgreSQL.Binary.Range as PostgreSQL -- rel8 -import Rel8.Schema.QualifiedName (QualifiedName, showQualifiedName) -import Rel8.Type (DBType, typeInformation) -import Rel8.Type.Builder.Fold (interfoldMap) -import Rel8.Type.Decoder (Decoder (Decoder)) -import qualified Rel8.Type.Decoder -import Rel8.Type.Encoder (Encoder (Encoder)) -import qualified Rel8.Type.Encoder -import Rel8.Type.Eq (DBEq) -import Rel8.Type.Information (TypeInformation (TypeInformation)) -import qualified Rel8.Type.Information -import Rel8.Type.Name (TypeName (TypeName)) -import qualified Rel8.Type.Name -import Rel8.Type.Ord (DBOrd) -import Rel8.Type.Range ( +import Rel8.Internal.Schema.QualifiedName (QualifiedName, showQualifiedName) +import Rel8.Internal.Type (DBType, typeInformation) +import Rel8.Internal.Type.Builder.Fold (interfoldMap) +import Rel8.Internal.Type.Decoder (Decoder (Decoder)) +import qualified Rel8.Internal.Type.Decoder +import Rel8.Internal.Type.Encoder (Encoder (Encoder)) +import qualified Rel8.Internal.Type.Encoder +import Rel8.Internal.Type.Eq (DBEq) +import Rel8.Internal.Type.Information (TypeInformation (TypeInformation)) +import qualified Rel8.Internal.Type.Information +import Rel8.Internal.Type.Name (TypeName (TypeName)) +import qualified Rel8.Internal.Type.Name +import Rel8.Internal.Type.Ord (DBOrd) +import Rel8.Internal.Type.Range ( DBRange, rangeTypeName, rangeEncoder, rangeDecoder, multirangeTypeName, multirangeEncoder, multirangeDecoder, ) -import Rel8.Type.Parser (parse) +import Rel8.Internal.Type.Parser (parse) newtype Multirange a = Multirange (PostgreSQL.Multirange a) diff --git a/src/Rel8/Expr.hs b/rel8-internal/src/Rel8/Internal/Expr.hs similarity index 83% rename from src/Rel8/Expr.hs rename to rel8-internal/src/Rel8/Internal/Expr.hs index 98adc547..f309c22a 100644 --- a/src/Rel8/Expr.hs +++ b/rel8-internal/src/Rel8/Internal/Expr.hs @@ -10,7 +10,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Expr +module Rel8.Internal.Expr ( Expr(..) ) where @@ -25,27 +25,27 @@ import Prelude hiding ( null ) import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr.Function (function) -import Rel8.Expr.Null ( liftOpNull, nullify ) -import Rel8.Expr.Opaleye +import Rel8.Internal.Expr.Function (function) +import Rel8.Internal.Expr.Null ( liftOpNull, nullify ) +import Rel8.Internal.Expr.Opaleye ( castExpr , fromPrimExpr , mapPrimExpr , zipPrimExprsWith ) -import Rel8.Expr.Serialize ( litExpr ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable ) -import Rel8.Table +import Rel8.Internal.Expr.Serialize ( litExpr ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Type ( DBType ) -import Rel8.Type.Monoid ( DBMonoid, memptyExpr ) -import Rel8.Type.Num ( DBFloating, DBFractional, DBNum ) -import Rel8.Type.Semigroup ( DBSemigroup, (<>.) ) +import Rel8.Internal.Type ( DBType ) +import Rel8.Internal.Type.Monoid ( DBMonoid, memptyExpr ) +import Rel8.Internal.Type.Num ( DBFloating, DBFractional, DBNum ) +import Rel8.Internal.Type.Semigroup ( DBSemigroup, (<>.) ) -- scientific import Data.Scientific (fromRationalRepetendLimited) diff --git a/rel8-internal/src/Rel8/Internal/Expr.hs-boot b/rel8-internal/src/Rel8/Internal/Expr.hs-boot new file mode 100644 index 00000000..f64934eb --- /dev/null +++ b/rel8-internal/src/Rel8/Internal/Expr.hs-boot @@ -0,0 +1,20 @@ +{-# language DataKinds #-} +{-# language StandaloneKindSignatures #-} + +module Rel8.Internal.Expr + ( Expr(..) + ) +where + +-- base +import Prelude () + +-- opaleye +import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye + +-- rel8 +import Rel8.Internal.Schema.Kind ( Context ) + + +type Expr :: Context +newtype Expr a = Expr Opaleye.PrimExpr diff --git a/src/Rel8/Expr/Aggregate.hs b/rel8-internal/src/Rel8/Internal/Expr/Aggregate.hs similarity index 92% rename from src/Rel8/Expr/Aggregate.hs rename to rel8-internal/src/Rel8/Internal/Expr/Aggregate.hs index 78a12c82..377c5488 100644 --- a/src/Rel8/Expr/Aggregate.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Aggregate.hs @@ -9,7 +9,7 @@ {-# options_ghc -fno-warn-redundant-constraints #-} -module Rel8.Expr.Aggregate +module Rel8.Internal.Expr.Aggregate ( count, countOn, countStar , countDistinct, countDistinctOn , countWhere, countWhereOn @@ -52,18 +52,18 @@ import qualified Opaleye.Internal.Operators as Opaleye import Data.Profunctor (dimap, lmap) -- rel8 -import Rel8.Aggregate +import Rel8.Internal.Aggregate ( Aggregator' (Aggregator) , Aggregator1 , filterWhereExplicit , unsafeMakeAggregator ) -import Rel8.Aggregate.Fold (Fallback (Empty, Fallback)) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Array (sempty) -import Rel8.Expr.Bool (false, true) -import Rel8.Expr.Eq ((/=.)) -import Rel8.Expr.Opaleye +import Rel8.Internal.Aggregate.Fold (Fallback (Empty, Fallback)) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Array (sempty) +import Rel8.Internal.Expr.Bool (false, true) +import Rel8.Internal.Expr.Eq ((/=.)) +import Rel8.Internal.Expr.Opaleye ( castExpr , fromColumn , fromPrimExpr @@ -71,22 +71,22 @@ import Rel8.Expr.Opaleye , toPrimExpr , unsafeCastExpr ) -import Rel8.Expr.Order (asc) -import Rel8.Expr.Read (sread) -import Rel8.Expr.Show (show) -import qualified Rel8.Expr.Text as Text -import Rel8.Order (Order (Order)) -import Rel8.Schema.Null ( Sql, Unnullify ) -import Rel8.Table.Opaleye (fromOrder, unpackspec) -import Rel8.Table.Order (ascTable) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Array (arrayTypeName, quoteArrayElement) -import Rel8.Type.Eq ( DBEq ) -import Rel8.Type.Information (TypeInformation) -import Rel8.Type.Num (DBFractional, DBNum) -import Rel8.Type.Ord (DBMax, DBMin, DBOrd) -import Rel8.Type.String ( DBString ) -import Rel8.Type.Sum ( DBSum ) +import Rel8.Internal.Expr.Order (asc) +import Rel8.Internal.Expr.Read (sread) +import Rel8.Internal.Expr.Show (show) +import qualified Rel8.Internal.Expr.Text as Text +import Rel8.Internal.Order (Order (Order)) +import Rel8.Internal.Schema.Null ( Sql, Unnullify ) +import Rel8.Internal.Table.Opaleye (fromOrder, unpackspec) +import Rel8.Internal.Table.Order (ascTable) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Array (arrayTypeName, quoteArrayElement) +import Rel8.Internal.Type.Eq ( DBEq ) +import Rel8.Internal.Type.Information (TypeInformation) +import Rel8.Internal.Type.Num (DBFractional, DBNum) +import Rel8.Internal.Type.Ord (DBMax, DBMin, DBOrd) +import Rel8.Internal.Type.String ( DBString ) +import Rel8.Internal.Type.Sum ( DBSum ) -- | Count the occurances of a single column. Corresponds to @COUNT(a)@ diff --git a/src/Rel8/Expr/Array.hs b/rel8-internal/src/Rel8/Internal/Expr/Array.hs similarity index 76% rename from src/Rel8/Expr/Array.hs rename to rel8-internal/src/Rel8/Internal/Expr/Array.hs index c1462919..a1462ff9 100644 --- a/src/Rel8/Expr/Array.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Array.hs @@ -4,7 +4,7 @@ {-# options_ghc -fno-warn-redundant-constraints #-} -module Rel8.Expr.Array +module Rel8.Internal.Expr.Array ( listOf, nonEmptyOf , slistOf, snonEmptyOf , sappend, sappend1, sempty @@ -19,12 +19,12 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import {-# SOURCE #-} Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye (fromPrimExpr, toPrimExpr, zipPrimExprsWith) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Array (array) -import Rel8.Type.Information ( TypeInformation(..) ) -import Rel8.Schema.Null (Unnullify, Sql) +import {-# SOURCE #-} Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye (fromPrimExpr, toPrimExpr, zipPrimExprsWith) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Array (array) +import Rel8.Internal.Type.Information ( TypeInformation(..) ) +import Rel8.Internal.Schema.Null (Unnullify, Sql) sappend :: Expr [a] -> Expr [a] -> Expr [a] diff --git a/src/Rel8/Expr/Bool.hs b/rel8-internal/src/Rel8/Internal/Expr/Bool.hs similarity index 91% rename from src/Rel8/Expr/Bool.hs rename to rel8-internal/src/Rel8/Internal/Expr/Bool.hs index 00e80ea1..a1e05c25 100644 --- a/src/Rel8/Expr/Bool.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Bool.hs @@ -1,6 +1,6 @@ {-# language GADTs #-} -module Rel8.Expr.Bool +module Rel8.Internal.Expr.Bool ( false, true , (&&.), (||.), not_ , and_, or_ @@ -18,9 +18,9 @@ import Prelude hiding ( null ) import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import {-# SOURCE #-} Rel8.Expr ( Expr( Expr ) ) -import Rel8.Expr.Opaleye ( mapPrimExpr, toPrimExpr, zipPrimExprsWith ) -import Rel8.Expr.Serialize ( litExpr ) +import {-# SOURCE #-} Rel8.Internal.Expr ( Expr( Expr ) ) +import Rel8.Internal.Expr.Opaleye ( mapPrimExpr, toPrimExpr, zipPrimExprsWith ) +import Rel8.Internal.Expr.Serialize ( litExpr ) -- | The SQL @false@ literal. diff --git a/src/Rel8/Expr/Default.hs b/rel8-internal/src/Rel8/Internal/Expr/Default.hs similarity index 91% rename from src/Rel8/Expr/Default.hs rename to rel8-internal/src/Rel8/Internal/Expr/Default.hs index 1c49e0b8..e0289e34 100644 --- a/src/Rel8/Expr/Default.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Default.hs @@ -1,4 +1,4 @@ -module Rel8.Expr.Default +module Rel8.Internal.Expr.Default ( unsafeDefault ) where @@ -10,8 +10,8 @@ import Prelude () import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye ( fromPrimExpr ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye ( fromPrimExpr ) -- | Corresponds to the SQL @DEFAULT@ expression. diff --git a/src/Rel8/Expr/Eq.hs b/rel8-internal/src/Rel8/Internal/Expr/Eq.hs similarity index 87% rename from src/Rel8/Expr/Eq.hs rename to rel8-internal/src/Rel8/Internal/Expr/Eq.hs index 95b6a0c0..65e7ed91 100644 --- a/src/Rel8/Expr/Eq.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Eq.hs @@ -6,7 +6,7 @@ {-# options_ghc -fno-warn-redundant-constraints #-} -module Rel8.Expr.Eq +module Rel8.Internal.Expr.Eq ( (==.), (/=.) , (==?), (/=?) , in_ @@ -22,12 +22,12 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( (&&.), (||.), false, or_, coalesce ) -import Rel8.Expr.Null ( isNull, unsafeLiftOpNull ) -import Rel8.Expr.Opaleye ( fromPrimExpr, toPrimExpr, zipPrimExprsWith ) -import Rel8.Schema.Null ( Nullity( NotNull, Null ), Sql, nullable ) -import Rel8.Type.Eq ( DBEq ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( (&&.), (||.), false, or_, coalesce ) +import Rel8.Internal.Expr.Null ( isNull, unsafeLiftOpNull ) +import Rel8.Internal.Expr.Opaleye ( fromPrimExpr, toPrimExpr, zipPrimExprsWith ) +import Rel8.Internal.Schema.Null ( Nullity( NotNull, Null ), Sql, nullable ) +import Rel8.Internal.Type.Eq ( DBEq ) eq :: DBEq a => Expr a -> Expr a -> Expr Bool diff --git a/src/Rel8/Expr/Function.hs b/rel8-internal/src/Rel8/Internal/Expr/Function.hs similarity index 87% rename from src/Rel8/Expr/Function.hs rename to rel8-internal/src/Rel8/Internal/Expr/Function.hs index 6ea7bb64..306e99d4 100644 --- a/src/Rel8/Expr/Function.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Function.hs @@ -7,7 +7,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Expr.Function +module Rel8.Internal.Expr.Function ( Arguments , function , primFunction @@ -25,21 +25,21 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import {-# SOURCE #-} Rel8.Expr (Expr) -import Rel8.Expr.Opaleye +import {-# SOURCE #-} Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye ( castExpr , fromPrimExpr, toPrimExpr, zipPrimExprsWith ) -import Rel8.Schema.HTable (hfoldMap) -import Rel8.Schema.Null ( Sql ) -import Rel8.Schema.QualifiedName +import Rel8.Internal.Schema.HTable (hfoldMap) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Schema.QualifiedName ( QualifiedName (..) , showQualifiedName , showQualifiedOperator ) -import Rel8.Table (Table, toColumns) -import Rel8.Type ( DBType ) +import Rel8.Internal.Table (Table, toColumns) +import Rel8.Internal.Type ( DBType ) -- | This type class is basically @'Table' 'Expr'@, where each column of the diff --git a/src/Rel8/Expr/List.hs b/rel8-internal/src/Rel8/Internal/Expr/List.hs similarity index 74% rename from src/Rel8/Expr/List.hs rename to rel8-internal/src/Rel8/Internal/Expr/List.hs index 37363a60..0b2fd319 100644 --- a/src/Rel8/Expr/List.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/List.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Expr.List ( +module Rel8.Internal.Expr.List ( headExpr, indexExpr, lastExpr, @@ -16,12 +16,12 @@ import Data.Int (Int32) import Prelude -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (mapPrimExpr, toPrimExpr) -import Rel8.Schema.Null (Nullify, Sql, Unnullify) -import Rel8.Type (DBType, typeInformation) -import Rel8.Type.Information (TypeInformation) -import qualified Rel8.Type.Array as Prim +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (mapPrimExpr, toPrimExpr) +import Rel8.Internal.Schema.Null (Nullify, Sql, Unnullify) +import Rel8.Internal.Type (DBType, typeInformation) +import Rel8.Internal.Type.Information (TypeInformation) +import qualified Rel8.Internal.Type.Array as Prim headExpr :: Sql DBType a => Expr [a] -> Expr (Nullify a) diff --git a/src/Rel8/Expr/NonEmpty.hs b/rel8-internal/src/Rel8/Internal/Expr/NonEmpty.hs similarity index 75% rename from src/Rel8/Expr/NonEmpty.hs rename to rel8-internal/src/Rel8/Internal/Expr/NonEmpty.hs index 598f139f..bb805f39 100644 --- a/src/Rel8/Expr/NonEmpty.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/NonEmpty.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Expr.NonEmpty ( +module Rel8.Internal.Expr.NonEmpty ( head1Expr, index1Expr, last1Expr, @@ -17,12 +17,12 @@ import Data.List.NonEmpty (NonEmpty) import Prelude -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (mapPrimExpr, toPrimExpr) -import Rel8.Schema.Null (Nullify, Sql, Unnullify) -import Rel8.Type (DBType, typeInformation) -import Rel8.Type.Information (TypeInformation) -import qualified Rel8.Type.Array as Prim +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (mapPrimExpr, toPrimExpr) +import Rel8.Internal.Schema.Null (Nullify, Sql, Unnullify) +import Rel8.Internal.Type (DBType, typeInformation) +import Rel8.Internal.Type.Information (TypeInformation) +import qualified Rel8.Internal.Type.Array as Prim head1Expr :: Sql DBType a => Expr (NonEmpty a) -> Expr a diff --git a/src/Rel8/Expr/Null.hs b/rel8-internal/src/Rel8/Internal/Expr/Null.hs similarity index 89% rename from src/Rel8/Expr/Null.hs rename to rel8-internal/src/Rel8/Internal/Expr/Null.hs index 9d3987f9..54122b09 100644 --- a/src/Rel8/Expr/Null.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Null.hs @@ -4,7 +4,7 @@ {-# options -fno-warn-redundant-constraints #-} -module Rel8.Expr.Null +module Rel8.Internal.Expr.Null ( null, snull, nullableExpr, nullableOf , isNull, isNonNull , nullify, unsafeUnnullify @@ -20,12 +20,12 @@ import Prelude hiding ( null ) import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import {-# SOURCE #-} Rel8.Expr ( Expr( Expr ) ) -import Rel8.Expr.Bool ( (||.), boolExpr ) -import Rel8.Expr.Opaleye ( scastExpr, mapPrimExpr ) -import Rel8.Schema.Null ( NotNull ) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Information ( TypeInformation ) +import {-# SOURCE #-} Rel8.Internal.Expr ( Expr( Expr ) ) +import Rel8.Internal.Expr.Bool ( (||.), boolExpr ) +import Rel8.Internal.Expr.Opaleye ( scastExpr, mapPrimExpr ) +import Rel8.Internal.Schema.Null ( NotNull ) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Information ( TypeInformation ) -- | Lift an expression that can't be @null@ to a type that might be @null@. diff --git a/src/Rel8/Expr/Opaleye.hs b/rel8-internal/src/Rel8/Internal/Expr/Opaleye.hs similarity index 91% rename from src/Rel8/Expr/Opaleye.hs rename to rel8-internal/src/Rel8/Internal/Expr/Opaleye.hs index 983b79b7..d4486372 100644 --- a/src/Rel8/Expr/Opaleye.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Opaleye.hs @@ -6,7 +6,7 @@ {-# options_ghc -fno-warn-redundant-constraints #-} -module Rel8.Expr.Opaleye +module Rel8.Internal.Expr.Opaleye ( castExpr, unsafeCastExpr , scastExpr, sunsafeCastExpr , unsafeCoerceExpr @@ -25,11 +25,11 @@ import qualified Opaleye.Internal.Column as Opaleye import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import {-# SOURCE #-} Rel8.Expr ( Expr( Expr ) ) -import Rel8.Schema.Null ( Unnullify, Sql ) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Information ( TypeInformation(..) ) -import Rel8.Type.Name (TypeName, showTypeName) +import {-# SOURCE #-} Rel8.Internal.Expr ( Expr( Expr ) ) +import Rel8.Internal.Schema.Null ( Unnullify, Sql ) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Information ( TypeInformation(..) ) +import Rel8.Internal.Type.Name (TypeName, showTypeName) -- profunctors import Data.Profunctor ( Profunctor, dimap ) diff --git a/src/Rel8/Expr/Ord.hs b/rel8-internal/src/Rel8/Internal/Expr/Ord.hs similarity index 90% rename from src/Rel8/Expr/Ord.hs rename to rel8-internal/src/Rel8/Internal/Expr/Ord.hs index df436f27..d9d05eb6 100644 --- a/src/Rel8/Expr/Ord.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Ord.hs @@ -6,7 +6,7 @@ {-# options_ghc -fno-warn-redundant-constraints #-} -module Rel8.Expr.Ord +module Rel8.Internal.Expr.Ord ( (<.), (<=.), (>.), (>=.) , (?), (>=?) , leastExpr, greatestExpr @@ -20,12 +20,12 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr( Expr ) ) -import Rel8.Expr.Bool ( (&&.), (||.), coalesce ) -import Rel8.Expr.Null ( isNull, isNonNull, nullableExpr, unsafeLiftOpNull ) -import Rel8.Expr.Opaleye ( toPrimExpr, zipPrimExprsWith ) -import Rel8.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable ) -import Rel8.Type.Ord ( DBOrd ) +import Rel8.Internal.Expr ( Expr( Expr ) ) +import Rel8.Internal.Expr.Bool ( (&&.), (||.), coalesce ) +import Rel8.Internal.Expr.Null ( isNull, isNonNull, nullableExpr, unsafeLiftOpNull ) +import Rel8.Internal.Expr.Opaleye ( toPrimExpr, zipPrimExprsWith ) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable ) +import Rel8.Internal.Type.Ord ( DBOrd ) lt :: DBOrd a => Expr a -> Expr a -> Expr Bool diff --git a/src/Rel8/Expr/Order.hs b/rel8-internal/src/Rel8/Internal/Expr/Order.hs similarity index 87% rename from src/Rel8/Expr/Order.hs rename to rel8-internal/src/Rel8/Internal/Expr/Order.hs index cb9c9e84..293fa96e 100644 --- a/src/Rel8/Expr/Order.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Order.hs @@ -2,7 +2,7 @@ {-# options_ghc -fno-warn-redundant-constraints #-} -module Rel8.Expr.Order +module Rel8.Internal.Expr.Order ( asc , desc , nullsFirst @@ -20,11 +20,11 @@ import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye import qualified Opaleye.Internal.Order as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Null ( unsafeUnnullify ) -import Rel8.Expr.Opaleye ( toPrimExpr ) -import Rel8.Order ( Order( Order ) ) -import Rel8.Type.Ord ( DBOrd ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Null ( unsafeUnnullify ) +import Rel8.Internal.Expr.Opaleye ( toPrimExpr ) +import Rel8.Internal.Order ( Order( Order ) ) +import Rel8.Internal.Type.Ord ( DBOrd ) -- | Sort a column in ascending order. diff --git a/src/Rel8/Expr/Range.hs b/rel8-internal/src/Rel8/Internal/Expr/Range.hs similarity index 68% rename from src/Rel8/Expr/Range.hs rename to rel8-internal/src/Rel8/Internal/Expr/Range.hs index 160a35be..6cf2dc82 100644 --- a/src/Rel8/Expr/Range.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Range.hs @@ -1,19 +1,19 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} -module Rel8.Expr.Range ( +module Rel8.Internal.Expr.Range ( range, multirange, ) where -- rel8 -import Rel8.Data.Range ( +import Rel8.Internal.Data.Range ( Range, mapRange, quoteRange, Multirange, primMultirange, ) -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (fromPrimExpr, toPrimExpr) -import Rel8.Type.Range (DBRange, rangeTypeName, multirangeTypeName) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (fromPrimExpr, toPrimExpr) +import Rel8.Internal.Type.Range (DBRange, rangeTypeName, multirangeTypeName) range :: forall a. DBRange a => Range (Expr a) -> Expr (Range a) diff --git a/src/Rel8/Expr/Read.hs b/rel8-internal/src/Rel8/Internal/Expr/Read.hs similarity index 54% rename from src/Rel8/Expr/Read.hs rename to rel8-internal/src/Rel8/Internal/Expr/Read.hs index 7dea9511..7fb0b771 100644 --- a/src/Rel8/Expr/Read.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Read.hs @@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MonoLocalBinds #-} -module Rel8.Expr.Read +module Rel8.Internal.Expr.Read ( read , sread ) @@ -11,11 +11,11 @@ where import Prelude () -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (unsafeCastExpr, sunsafeCastExpr) -import Rel8.Schema.Null (Sql) -import Rel8.Type (DBType) -import Rel8.Type.Name (TypeName) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (unsafeCastExpr, sunsafeCastExpr) +import Rel8.Internal.Schema.Null (Sql) +import Rel8.Internal.Type (DBType) +import Rel8.Internal.Type.Name (TypeName) -- text import Data.Text (Text) diff --git a/src/Rel8/Expr/Sequence.hs b/rel8-internal/src/Rel8/Internal/Expr/Sequence.hs similarity index 67% rename from src/Rel8/Expr/Sequence.hs rename to rel8-internal/src/Rel8/Internal/Expr/Sequence.hs index f79c3b28..562b7957 100644 --- a/src/Rel8/Expr/Sequence.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Sequence.hs @@ -1,4 +1,4 @@ -module Rel8.Expr.Sequence +module Rel8.Internal.Expr.Sequence ( nextval ) where @@ -11,9 +11,9 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye (fromPrimExpr) -import Rel8.Schema.QualifiedName (QualifiedName, showQualifiedName) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye (fromPrimExpr) +import Rel8.Internal.Schema.QualifiedName (QualifiedName, showQualifiedName) -- | See https://www.postgresql.org/docs/current/functions-sequence.html diff --git a/src/Rel8/Expr/Serialize.hs b/rel8-internal/src/Rel8/Internal/Expr/Serialize.hs similarity index 72% rename from src/Rel8/Expr/Serialize.hs rename to rel8-internal/src/Rel8/Internal/Expr/Serialize.hs index 95993c4d..4015cf19 100644 --- a/src/Rel8/Expr/Serialize.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Serialize.hs @@ -3,7 +3,7 @@ {-# language NamedFieldPuns #-} {-# language TypeFamilies #-} -module Rel8.Expr.Serialize +module Rel8.Internal.Expr.Serialize ( litExpr , slitExpr , sparseValue @@ -20,13 +20,13 @@ import qualified Hasql.Decoders as Hasql import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import {-# SOURCE #-} Rel8.Expr ( Expr( Expr ) ) -import Rel8.Expr.Opaleye ( scastExpr ) -import Rel8.Schema.Null ( Unnullify, Nullity( Null, NotNull ), Sql, nullable ) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Decoder (Decoder (..)) -import Rel8.Type.Encoder (Encoder (..)) -import Rel8.Type.Information ( TypeInformation(..) ) +import {-# SOURCE #-} Rel8.Internal.Expr ( Expr( Expr ) ) +import Rel8.Internal.Expr.Opaleye ( scastExpr ) +import Rel8.Internal.Schema.Null ( Unnullify, Nullity( Null, NotNull ), Sql, nullable ) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Decoder (Decoder (..)) +import Rel8.Internal.Type.Encoder (Encoder (..)) +import Rel8.Internal.Type.Information ( TypeInformation(..) ) -- | Produce an expression from a literal. diff --git a/src/Rel8/Expr/Show.hs b/rel8-internal/src/Rel8/Internal/Expr/Show.hs similarity index 54% rename from src/Rel8/Expr/Show.hs rename to rel8-internal/src/Rel8/Internal/Expr/Show.hs index abb385f1..b05980d3 100644 --- a/src/Rel8/Expr/Show.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Show.hs @@ -1,4 +1,4 @@ -module Rel8.Expr.Show +module Rel8.Internal.Expr.Show ( show ) where @@ -7,8 +7,8 @@ where import Prelude () -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (unsafeCastExpr) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (unsafeCastExpr) -- text import Data.Text (Text) diff --git a/src/Rel8/Expr/Subscript.hs b/rel8-internal/src/Rel8/Internal/Expr/Subscript.hs similarity index 81% rename from src/Rel8/Expr/Subscript.hs rename to rel8-internal/src/Rel8/Internal/Expr/Subscript.hs index c72d28d7..c1d1bafa 100644 --- a/src/Rel8/Expr/Subscript.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Subscript.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Expr.Subscript +module Rel8.Internal.Expr.Subscript ( unsafeSubscript , unsafeSubscripts ) @@ -15,14 +15,14 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (fromPrimExpr, toPrimExpr) -import Rel8.Schema.HTable (hfoldMap) -import Rel8.Schema.Null (Sql, Unnullify) -import Rel8.Table (Table, toColumns) -import Rel8.Type (DBType, typeInformation) -import Rel8.Type.Array (extractArrayElement) -import Rel8.Type.Information (TypeInformation) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (fromPrimExpr, toPrimExpr) +import Rel8.Internal.Schema.HTable (hfoldMap) +import Rel8.Internal.Schema.Null (Sql, Unnullify) +import Rel8.Internal.Table (Table, toColumns) +import Rel8.Internal.Type (DBType, typeInformation) +import Rel8.Internal.Type.Array (extractArrayElement) +import Rel8.Internal.Type.Information (TypeInformation) -- | @'unsafeSubscript' a i@ will generate the SQL @a[i]@. diff --git a/src/Rel8/Expr/Text.hs b/rel8-internal/src/Rel8/Internal/Expr/Text.hs similarity index 97% rename from src/Rel8/Expr/Text.hs rename to rel8-internal/src/Rel8/Internal/Expr/Text.hs index 7458bd8b..a0a78359 100644 --- a/src/Rel8/Expr/Text.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Text.hs @@ -1,7 +1,7 @@ {-# language DataKinds #-} {-# language OverloadedStrings #-} -module Rel8.Expr.Text +module Rel8.Internal.Expr.Text ( -- * String concatenation (++.) @@ -37,9 +37,9 @@ import Data.ByteString ( ByteString ) import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Function (binaryOperator, function) -import Rel8.Expr.Opaleye (zipPrimExprsWith) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Function (binaryOperator, function) +import Rel8.Internal.Expr.Opaleye (zipPrimExprsWith) -- text import Data.Text (Text) diff --git a/src/Rel8/Expr/Window.hs b/rel8-internal/src/Rel8/Internal/Expr/Window.hs similarity index 94% rename from src/Rel8/Expr/Window.hs rename to rel8-internal/src/Rel8/Internal/Expr/Window.hs index c4464718..3a2ae9c7 100644 --- a/src/Rel8/Expr/Window.hs +++ b/rel8-internal/src/Rel8/Internal/Expr/Window.hs @@ -1,4 +1,4 @@ -module Rel8.Expr.Window +module Rel8.Internal.Expr.Window ( cumulative , rowNumber , rank @@ -28,11 +28,11 @@ import qualified Opaleye.Window as Opaleye import Data.Profunctor (dimap, lmap) -- rel8 -import Rel8.Aggregate (Aggregator' (Aggregator)) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye ( fromColumn, fromPrimExpr, toColumn, toPrimExpr ) -import Rel8.Schema.Null ( Nullify ) -import Rel8.Window ( Window( Window ) ) +import Rel8.Internal.Aggregate (Aggregator' (Aggregator)) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye ( fromColumn, fromPrimExpr, toColumn, toPrimExpr ) +import Rel8.Internal.Schema.Null ( Nullify ) +import Rel8.Internal.Window ( Window( Window ) ) -- | 'cumulative' allows the use of aggregation functions in 'Window' diff --git a/src/Rel8/FCF.hs b/rel8-internal/src/Rel8/Internal/FCF.hs similarity index 93% rename from src/Rel8/FCF.hs rename to rel8-internal/src/Rel8/Internal/FCF.hs index 97a5c471..47a99435 100644 --- a/src/Rel8/FCF.hs +++ b/rel8-internal/src/Rel8/Internal/FCF.hs @@ -3,7 +3,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilies #-} -module Rel8.FCF +module Rel8.Internal.FCF ( Exp, Eval , Id ) diff --git a/src/Rel8/Generic/Construction.hs b/rel8-internal/src/Rel8/Internal/Generic/Construction.hs similarity index 90% rename from src/Rel8/Generic/Construction.hs rename to rel8-internal/src/Rel8/Internal/Generic/Construction.hs index cec92825..856439d6 100644 --- a/src/Rel8/Generic/Construction.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Construction.hs @@ -11,7 +11,7 @@ {-# language UndecidableInstances #-} {-# language ViewPatterns #-} -module Rel8.Generic.Construction +module Rel8.Internal.Generic.Construction ( GGBuildable , GGBuild, ggbuild , GGConstructable @@ -30,12 +30,12 @@ import GHC.TypeLits ( Symbol ) import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Eq ( (==.) ) -import Rel8.Expr.Null ( nullify, snull, unsafeUnnullify ) -import Rel8.Expr.Serialize ( litExpr ) -import Rel8.FCF ( Eval, Exp, Id ) -import Rel8.Generic.Construction.ADT +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Eq ( (==.) ) +import Rel8.Internal.Expr.Null ( nullify, snull, unsafeUnnullify ) +import Rel8.Internal.Expr.Serialize ( litExpr ) +import Rel8.Internal.FCF ( Eval, Exp, Id ) +import Rel8.Internal.Generic.Construction.ADT ( GConstructorADT, GMakeableADT, gmakeADT , GConstructableADT , GBuildADT, gbuildADT @@ -43,29 +43,29 @@ import Rel8.Generic.Construction.ADT , RepresentableConstructors, GConstructors, gcindex, gctabulate , RepresentableFields, gftabulate ) -import Rel8.Generic.Construction.Record +import Rel8.Internal.Generic.Construction.Record ( GConstructor , GConstructable, GConstruct, gconstruct, gdeconstruct , Representable, gindex, gtabulate ) -import Rel8.Generic.Table ( GGColumns ) -import Rel8.Kind.Algebra +import Rel8.Internal.Generic.Table ( GGColumns ) +import Rel8.Internal.Kind.Algebra ( SAlgebra( SProduct, SSum ) , KnownAlgebra, algebraSing ) -import qualified Rel8.Kind.Algebra as K -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name( Name ) ) -import Rel8.Schema.Null ( Nullity( Null, NotNull ) ) -import Rel8.Schema.Spec ( Spec( Spec, nullity, info ) ) -import Rel8.Table +import qualified Rel8.Internal.Kind.Algebra as K +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name( Name ) ) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.Spec ( Spec( Spec, nullity, info ) ) +import Rel8.Internal.Table ( TTable, TColumns , Table, fromColumns, toColumns ) -import Rel8.Table.Bool ( case_ ) -import Rel8.Type.Tag ( Tag ) +import Rel8.Internal.Table.Bool ( case_ ) +import Rel8.Internal.Type.Tag ( Tag ) -- semigroupoids import Data.Functor.Apply (Apply) diff --git a/src/Rel8/Generic/Construction/ADT.hs b/rel8-internal/src/Rel8/Internal/Generic/Construction/ADT.hs similarity index 95% rename from src/Rel8/Generic/Construction/ADT.hs rename to rel8-internal/src/Rel8/Internal/Generic/Construction/ADT.hs index 7b52f985..84e634a8 100644 --- a/src/Rel8/Generic/Construction/ADT.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Construction/ADT.hs @@ -13,7 +13,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Construction.ADT +module Rel8.Internal.Generic.Construction.ADT ( GConstructableADT , GBuildADT, gbuildADT, gunbuildADT , GConstructADT, gconstructADT, gdeconstructADT @@ -41,23 +41,23 @@ import GHC.TypeLits import Prelude hiding ( null ) -- rel8 -import Rel8.FCF ( Exp ) -import Rel8.Generic.Construction.Record +import Rel8.Internal.FCF ( Exp ) +import Rel8.Internal.Generic.Construction.Record ( GConstruct, GConstructable, gconstruct, gdeconstruct , GFields, Representable, gtabulate, gindex , FromColumns, ToColumns ) -import Rel8.Generic.Table.ADT ( GColumnsADT, GColumnsADT' ) -import Rel8.Generic.Table.Record ( GColumns ) -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Identity ( HIdentity ) -import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel ) -import Rel8.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify ) -import Rel8.Schema.HTable.Product ( HProduct( HProduct ) ) -import Rel8.Schema.Null ( Nullify ) -import Rel8.Schema.Spec ( Spec ) -import qualified Rel8.Schema.Kind as K -import Rel8.Type.Tag ( Tag( Tag ) ) +import Rel8.Internal.Generic.Table.ADT ( GColumnsADT, GColumnsADT' ) +import Rel8.Internal.Generic.Table.Record ( GColumns ) +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity ) +import Rel8.Internal.Schema.HTable.Label ( HLabel, hlabel, hunlabel ) +import Rel8.Internal.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify ) +import Rel8.Internal.Schema.HTable.Product ( HProduct( HProduct ) ) +import Rel8.Internal.Schema.Null ( Nullify ) +import Rel8.Internal.Schema.Spec ( Spec ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Type.Tag ( Tag( Tag ) ) -- text import Data.Text ( pack ) diff --git a/src/Rel8/Generic/Construction/Record.hs b/rel8-internal/src/Rel8/Internal/Generic/Construction/Record.hs similarity index 93% rename from src/Rel8/Generic/Construction/Record.hs rename to rel8-internal/src/Rel8/Internal/Generic/Construction/Record.hs index 5d4f3a2f..e888134d 100644 --- a/src/Rel8/Generic/Construction/Record.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Construction/Record.hs @@ -11,7 +11,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Construction.Record +module Rel8.Internal.Generic.Construction.Record ( GConstructor, GConstruct, GConstructable, gconstruct, gdeconstruct , GFields, Representable, gtabulate, gindex , FromColumns, ToColumns @@ -32,11 +32,11 @@ import GHC.TypeLits import Prelude -- rel8 -import Rel8.FCF ( Eval, Exp ) -import Rel8.Generic.Table.Record ( GColumns ) -import Rel8.Schema.HTable.Label ( hlabel, hunlabel ) -import Rel8.Schema.HTable.Product ( HProduct( HProduct ) ) -import qualified Rel8.Schema.Kind as K +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Generic.Table.Record ( GColumns ) +import Rel8.Internal.Schema.HTable.Label ( hlabel, hunlabel ) +import Rel8.Internal.Schema.HTable.Product ( HProduct( HProduct ) ) +import qualified Rel8.Internal.Schema.Kind as K type FromColumns diff --git a/src/Rel8/Generic/Map.hs b/rel8-internal/src/Rel8/Internal/Generic/Map.hs similarity index 95% rename from src/Rel8/Generic/Map.hs rename to rel8-internal/src/Rel8/Internal/Generic/Map.hs index 5395626b..5077143d 100644 --- a/src/Rel8/Generic/Map.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Map.hs @@ -4,7 +4,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Map +module Rel8.Internal.Generic.Map ( GMap , Map ) @@ -18,7 +18,7 @@ import GHC.Generics import Prelude () -- rel8 -import Rel8.FCF ( Eval, Exp ) +import Rel8.Internal.FCF ( Eval, Exp ) type GMap :: (Type -> Exp Type) -> (Type -> Type) -> Type -> Type diff --git a/src/Rel8/Generic/Record.hs b/rel8-internal/src/Rel8/Internal/Generic/Record.hs similarity index 99% rename from src/Rel8/Generic/Record.hs rename to rel8-internal/src/Rel8/Internal/Generic/Record.hs index b0e83546..2c88501a 100644 --- a/src/Rel8/Generic/Record.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Record.hs @@ -11,7 +11,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Record +module Rel8.Internal.Generic.Record ( Record(..) , GRecordable, GRecord, grecord, gunrecord ) diff --git a/src/Rel8/Generic/Rel8able.hs b/rel8-internal/src/Rel8/Internal/Generic/Rel8able.hs similarity index 91% rename from src/Rel8/Generic/Rel8able.hs rename to rel8-internal/src/Rel8/Internal/Generic/Rel8able.hs index 365c17cb..0a36d1a5 100644 --- a/src/Rel8/Generic/Rel8able.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Rel8able.hs @@ -15,7 +15,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Rel8able +module Rel8.Internal.Generic.Rel8able ( KRel8able, Rel8able , Algebra , GRep @@ -33,25 +33,25 @@ import GHC.Generics ( Generic, Rep, from, to ) import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.FCF ( Exp, Eval ) -import Rel8.Generic.Record ( Record(..) ) -import Rel8.Generic.Table ( GAlgebra ) -import qualified Rel8.Generic.Table.Record as G -import qualified Rel8.Kind.Algebra as K ( Algebra(..) ) -import Rel8.Kind.Context ( SContext(..) ) -import Rel8.Schema.Field ( Field ) -import Rel8.Schema.HTable ( HTable ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name ) -import Rel8.Schema.Result ( Result ) -import Rel8.Table +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.FCF ( Exp, Eval ) +import Rel8.Internal.Generic.Record ( Record(..) ) +import Rel8.Internal.Generic.Table ( GAlgebra ) +import qualified Rel8.Internal.Generic.Table.Record as G +import qualified Rel8.Internal.Kind.Algebra as K ( Algebra(..) ) +import Rel8.Internal.Kind.Context ( SContext(..) ) +import Rel8.Internal.Schema.Field ( Field ) +import Rel8.Internal.Schema.HTable ( HTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose , TTable, TColumns ) -import Rel8.Table.Transpose ( Transposes ) +import Rel8.Internal.Table.Transpose ( Transposes ) -- | The kind of 'Rel8able' types diff --git a/src/Rel8/Generic/Table.hs b/rel8-internal/src/Rel8/Internal/Generic/Table.hs similarity index 88% rename from src/Rel8/Generic/Table.hs rename to rel8-internal/src/Rel8/Internal/Generic/Table.hs index 98da2ea7..68bc9046 100644 --- a/src/Rel8/Generic/Table.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Table.hs @@ -11,7 +11,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Table +module Rel8.Internal.Generic.Table ( GGSerialize, GGColumns, ggfromResult, ggtoResult , GAlgebra ) @@ -23,18 +23,18 @@ import GHC.Generics ( (:+:), (:*:), K1, M1, U1, V1 ) import Prelude () -- rel8 -import Rel8.FCF ( Eval, Exp ) -import Rel8.Generic.Table.ADT +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Generic.Table.ADT ( GSerializeADT, GColumnsADT, gtoResultADT, gfromResultADT ) -import Rel8.Generic.Table.Record ( GSerialize, GColumns, gtoResult, gfromResult ) -import Rel8.Kind.Algebra +import Rel8.Internal.Generic.Table.Record ( GSerialize, GColumns, gtoResult, gfromResult ) +import Rel8.Internal.Kind.Algebra ( Algebra( Product, Sum ) , SAlgebra( SProduct, SSum ) , KnownAlgebra, algebraSing ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result ) data GGSerialize diff --git a/src/Rel8/Generic/Table/ADT.hs b/rel8-internal/src/Rel8/Internal/Generic/Table/ADT.hs similarity index 90% rename from src/Rel8/Generic/Table/ADT.hs rename to rel8-internal/src/Rel8/Internal/Generic/Table/ADT.hs index b9fb8c0a..485df142 100644 --- a/src/Rel8/Generic/Table/ADT.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Table/ADT.hs @@ -12,7 +12,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Table.ADT +module Rel8.Internal.Generic.Table.ADT ( GSerializeADT, GColumnsADT, gfromResultADT, gtoResultADT , GSerializeADT', GColumnsADT' ) @@ -31,16 +31,16 @@ import GHC.TypeLits ( KnownSymbol, symbolVal ) import Prelude hiding ( null ) -- rel8 -import Rel8.FCF ( Eval, Exp ) -import Rel8.Generic.Table.Record ( GSerialize, GColumns, gfromResult, gtoResult ) -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel ) -import Rel8.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify ) -import Rel8.Schema.HTable.Product ( HProduct( HProduct ) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Result ( Result, null, nullifier, unnullifier ) -import Rel8.Type.Tag ( Tag( Tag ) ) +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Generic.Table.Record ( GSerialize, GColumns, gfromResult, gtoResult ) +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import Rel8.Internal.Schema.HTable.Label ( HLabel, hlabel, hunlabel ) +import Rel8.Internal.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify ) +import Rel8.Internal.Schema.HTable.Product ( HProduct( HProduct ) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Result ( Result, null, nullifier, unnullifier ) +import Rel8.Internal.Type.Tag ( Tag( Tag ) ) -- text import Data.Text ( pack ) diff --git a/src/Rel8/Generic/Table/Record.hs b/rel8-internal/src/Rel8/Internal/Generic/Table/Record.hs similarity index 95% rename from src/Rel8/Generic/Table/Record.hs rename to rel8-internal/src/Rel8/Internal/Generic/Table/Record.hs index e9cfa368..8ab4907c 100644 --- a/src/Rel8/Generic/Table/Record.hs +++ b/rel8-internal/src/Rel8/Internal/Generic/Table/Record.hs @@ -12,7 +12,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Generic.Table.Record +module Rel8.Internal.Generic.Table.Record ( GTable, GColumns, GContext, gfromColumns, gtoColumns, gtable , GSerialize, gfromResult, gtoResult ) @@ -29,10 +29,10 @@ import GHC.Generics import Prelude hiding ( null ) -- rel8 -import Rel8.FCF ( Eval, Exp ) -import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel ) -import Rel8.Schema.HTable.Product ( HProduct(..) ) -import qualified Rel8.Schema.Kind as K +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Schema.HTable.Label ( HLabel, hlabel, hunlabel ) +import Rel8.Internal.Schema.HTable.Product ( HProduct(..) ) +import qualified Rel8.Internal.Schema.Kind as K type GColumns :: (Type -> Exp K.HTable) -> (Type -> Type) -> K.HTable diff --git a/src/Rel8/Kind/Algebra.hs b/rel8-internal/src/Rel8/Internal/Kind/Algebra.hs similarity index 95% rename from src/Rel8/Kind/Algebra.hs rename to rel8-internal/src/Rel8/Internal/Kind/Algebra.hs index f133d370..9a0d7b44 100644 --- a/src/Rel8/Kind/Algebra.hs +++ b/rel8-internal/src/Rel8/Internal/Kind/Algebra.hs @@ -3,7 +3,7 @@ {-# language GADTs #-} {-# language StandaloneKindSignatures #-} -module Rel8.Kind.Algebra +module Rel8.Internal.Kind.Algebra ( Algebra( Product, Sum ) , SAlgebra( SProduct, SSum ) , KnownAlgebra( algebraSing ) diff --git a/src/Rel8/Kind/Context.hs b/rel8-internal/src/Rel8/Internal/Kind/Context.hs similarity index 75% rename from src/Rel8/Kind/Context.hs rename to rel8-internal/src/Rel8/Internal/Kind/Context.hs index 048f096f..4af61850 100644 --- a/src/Rel8/Kind/Context.hs +++ b/rel8-internal/src/Rel8/Internal/Kind/Context.hs @@ -3,7 +3,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeSynonymInstances #-} -module Rel8.Kind.Context +module Rel8.Internal.Kind.Context ( Reifiable( contextSing ) , SContext(..) ) @@ -14,11 +14,11 @@ import Data.Kind ( Constraint, Type ) import Prelude () -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Schema.Field ( Field ) -import Rel8.Schema.Kind ( Context ) -import Rel8.Schema.Name ( Name ) -import Rel8.Schema.Result ( Result ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Schema.Field ( Field ) +import Rel8.Internal.Schema.Kind ( Context ) +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Schema.Result ( Result ) type SContext :: Context -> Type diff --git a/src/Rel8/Order.hs b/rel8-internal/src/Rel8/Internal/Order.hs similarity index 96% rename from src/Rel8/Order.hs rename to rel8-internal/src/Rel8/Internal/Order.hs index 4943b42d..b4ca07d9 100644 --- a/src/Rel8/Order.hs +++ b/rel8-internal/src/Rel8/Internal/Order.hs @@ -2,7 +2,7 @@ {-# language GeneralizedNewtypeDeriving #-} {-# language StandaloneKindSignatures #-} -module Rel8.Order +module Rel8.Internal.Order ( Order(..) ) where diff --git a/src/Rel8/Query.hs b/rel8-internal/src/Rel8/Internal/Query.hs similarity index 94% rename from src/Rel8/Query.hs rename to rel8-internal/src/Rel8/Internal/Query.hs index c9457b67..3edabf8c 100644 --- a/src/Rel8/Query.hs +++ b/rel8-internal/src/Rel8/Internal/Query.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language UndecidableInstances #-} -module Rel8.Query +module Rel8.Internal.Query ( Query( Query ) ) where @@ -22,16 +22,16 @@ import qualified Opaleye.Internal.QueryArr as Opaleye import qualified Opaleye.Internal.Tag as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Query.Set ( unionAll ) -import Rel8.Query.Opaleye ( fromOpaleye ) -import Rel8.Query.Values ( values ) -import Rel8.Table ( Table, fromColumns, toColumns ) -import Rel8.Table.Alternative +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Query.Set ( unionAll ) +import Rel8.Internal.Query.Opaleye ( fromOpaleye ) +import Rel8.Internal.Query.Values ( values ) +import Rel8.Internal.Table ( Table, fromColumns, toColumns ) +import Rel8.Internal.Table.Alternative ( AltTable, (<|>:) , AlternativeTable, emptyTable ) -import Rel8.Table.Projection ( Projectable, apply, project ) +import Rel8.Internal.Table.Projection ( Projectable, apply, project ) -- semigroupoids import Data.Functor.Apply ( Apply, (<.>) ) diff --git a/rel8-internal/src/Rel8/Internal/Query.hs-boot b/rel8-internal/src/Rel8/Internal/Query.hs-boot new file mode 100644 index 00000000..5ee821ae --- /dev/null +++ b/rel8-internal/src/Rel8/Internal/Query.hs-boot @@ -0,0 +1,19 @@ +{-# language StandaloneKindSignatures #-} + +module Rel8.Internal.Query + ( Query( Query ) + ) +where + +-- base +import Data.Kind ( Type ) +import Data.Monoid ( Any ) +import Prelude () + +-- opaleye +import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye +import qualified Opaleye.Select as Opaleye + + +type Query :: Type -> Type +newtype Query a = Query ([Opaleye.PrimExpr] -> Opaleye.Select (Any, a)) diff --git a/src/Rel8/Query/Aggregate.hs b/rel8-internal/src/Rel8/Internal/Query/Aggregate.hs similarity index 72% rename from src/Rel8/Query/Aggregate.hs rename to rel8-internal/src/Rel8/Internal/Query/Aggregate.hs index dfdf9709..a1618f46 100644 --- a/src/Rel8/Query/Aggregate.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Aggregate.hs @@ -2,7 +2,7 @@ {-# language MonoLocalBinds #-} {-# language ScopedTypeVariables #-} -module Rel8.Query.Aggregate +module Rel8.Internal.Query.Aggregate ( aggregate , aggregate1 , aggregateU @@ -20,17 +20,17 @@ import qualified Opaleye.Adaptors as Opaleye import qualified Opaleye.Aggregate as Opaleye -- rel8 -import Rel8.Aggregate (Aggregator' (Aggregator), Aggregator) -import Rel8.Aggregate.Fold (Fallback (Fallback)) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Aggregate ( countStar ) -import Rel8.Expr.Bool (true) -import Rel8.Query ( Query ) -import Rel8.Query.Maybe ( optional ) -import Rel8.Query.Opaleye ( mapOpaleye ) -import Rel8.Table (Table) -import Rel8.Table.Maybe (fromMaybeTable) -import Rel8.Table.Opaleye (unpackspec) +import Rel8.Internal.Aggregate (Aggregator' (Aggregator), Aggregator) +import Rel8.Internal.Aggregate.Fold (Fallback (Fallback)) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Aggregate ( countStar ) +import Rel8.Internal.Expr.Bool (true) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Maybe ( optional ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye ) +import Rel8.Internal.Table (Table) +import Rel8.Internal.Table.Maybe (fromMaybeTable) +import Rel8.Internal.Table.Opaleye (unpackspec) -- | Apply an 'Aggregator' to all rows returned by a 'Query'. If the 'Query' diff --git a/src/Rel8/Query/Distinct.hs b/rel8-internal/src/Rel8/Internal/Query/Distinct.hs similarity index 81% rename from src/Rel8/Query/Distinct.hs rename to rel8-internal/src/Rel8/Internal/Query/Distinct.hs index 270eaa61..18e41adf 100644 --- a/src/Rel8/Query/Distinct.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Distinct.hs @@ -1,4 +1,4 @@ -module Rel8.Query.Distinct +module Rel8.Internal.Query.Distinct ( distinct , distinctOn , distinctOnBy @@ -13,11 +13,11 @@ import qualified Opaleye.Distinct as Opaleye import qualified Opaleye.Order as Opaleye -- rel8 -import Rel8.Order ( Order( Order ) ) -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( mapOpaleye ) -import Rel8.Table.Eq ( EqTable ) -import Rel8.Table.Opaleye (distinctspec, unpackspec) +import Rel8.Internal.Order ( Order( Order ) ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye ) +import Rel8.Internal.Table.Eq ( EqTable ) +import Rel8.Internal.Table.Opaleye (distinctspec, unpackspec) -- | Select all distinct rows from a query, removing duplicates. @distinct q@ diff --git a/src/Rel8/Query/Each.hs b/rel8-internal/src/Rel8/Internal/Query/Each.hs similarity index 57% rename from src/Rel8/Query/Each.hs rename to rel8-internal/src/Rel8/Internal/Query/Each.hs index 930c102e..3d5769ae 100644 --- a/src/Rel8/Query/Each.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Each.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Query.Each +module Rel8.Internal.Query.Each ( each ) where @@ -13,12 +13,12 @@ import Prelude import qualified Opaleye.Table as Opaleye -- rel8 -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( fromOpaleye ) -import Rel8.Schema.Name ( Selects ) -import Rel8.Schema.Table ( TableSchema ) -import Rel8.Table.Cols ( fromCols, toCols ) -import Rel8.Table.Opaleye ( table, unpackspec ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( fromOpaleye ) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Schema.Table ( TableSchema ) +import Rel8.Internal.Table.Cols ( fromCols, toCols ) +import Rel8.Internal.Table.Opaleye ( table, unpackspec ) -- | Select each row from a table definition. This is equivalent to @FROM diff --git a/src/Rel8/Query/Either.hs b/rel8-internal/src/Rel8/Internal/Query/Either.hs similarity index 81% rename from src/Rel8/Query/Either.hs rename to rel8-internal/src/Rel8/Internal/Query/Either.hs index f82ffed0..aa6e797e 100644 --- a/src/Rel8/Query/Either.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Either.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Query.Either +module Rel8.Internal.Query.Either ( keepLeftTable , keepRightTable , bitraverseEitherTable @@ -14,16 +14,16 @@ import Prelude import Control.Comonad ( extract ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Eq ( (==.) ) -import Rel8.Query ( Query ) -import Rel8.Query.Filter ( where_ ) -import Rel8.Query.Maybe ( optional ) -import Rel8.Table.Either +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Eq ( (==.) ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Filter ( where_ ) +import Rel8.Internal.Query.Maybe ( optional ) +import Rel8.Internal.Table.Either ( EitherTable( EitherTable ) , isLeftTable, isRightTable ) -import Rel8.Table.Maybe ( MaybeTable( MaybeTable ), isJustTable ) +import Rel8.Internal.Table.Maybe ( MaybeTable( MaybeTable ), isJustTable ) -- | Filter 'EitherTable's, keeping only 'leftTable's. diff --git a/src/Rel8/Query/Evaluate.hs b/rel8-internal/src/Rel8/Internal/Query/Evaluate.hs similarity index 73% rename from src/Rel8/Query/Evaluate.hs rename to rel8-internal/src/Rel8/Internal/Query/Evaluate.hs index 5816387c..702e42bd 100644 --- a/src/Rel8/Query/Evaluate.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Evaluate.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language TupleSections #-} -module Rel8.Query.Evaluate +module Rel8.Internal.Query.Evaluate ( evaluate ) where @@ -17,14 +17,14 @@ import Prelude hiding ( undefined ) import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( (&&.) ) -import Rel8.Expr.Opaleye ( fromPrimExpr ) -import Rel8.Query ( Query( Query ) ) -import Rel8.Query.Rebind ( rebind ) -import Rel8.Table ( Table ) -import Rel8.Table.Bool ( case_ ) -import Rel8.Table.Undefined ( undefined ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( (&&.) ) +import Rel8.Internal.Expr.Opaleye ( fromPrimExpr ) +import Rel8.Internal.Query ( Query( Query ) ) +import Rel8.Internal.Query.Rebind ( rebind ) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Bool ( case_ ) +import Rel8.Internal.Table.Undefined ( undefined ) -- | 'evaluate' takes expressions that could potentially have side effects and diff --git a/src/Rel8/Query/Exists.hs b/rel8-internal/src/Rel8/Internal/Query/Exists.hs similarity index 83% rename from src/Rel8/Query/Exists.hs rename to rel8-internal/src/Rel8/Internal/Query/Exists.hs index 2b4b43d6..a5c0badd 100644 --- a/src/Rel8/Query/Exists.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Exists.hs @@ -1,6 +1,6 @@ {-# language DataKinds #-} -module Rel8.Query.Exists +module Rel8.Internal.Query.Exists ( exists, inQuery , present, with, withBy , absent, without, withoutBy @@ -15,12 +15,12 @@ import qualified Opaleye.Exists as Opaleye import qualified Opaleye.Operators as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye ( fromColumn, fromPrimExpr ) -import Rel8.Query ( Query ) -import Rel8.Query.Filter ( filter ) -import Rel8.Query.Opaleye ( mapOpaleye ) -import Rel8.Table.Eq ( EqTable, (==:) ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye ( fromColumn, fromPrimExpr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Filter ( filter ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye ) +import Rel8.Internal.Table.Eq ( EqTable, (==:) ) -- | Checks if a query returns at least one row. diff --git a/src/Rel8/Query/Filter.hs b/rel8-internal/src/Rel8/Internal/Query/Filter.hs similarity index 78% rename from src/Rel8/Query/Filter.hs rename to rel8-internal/src/Rel8/Internal/Query/Filter.hs index c0123fe7..fa135b7e 100644 --- a/src/Rel8/Query/Filter.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Filter.hs @@ -1,4 +1,4 @@ -module Rel8.Query.Filter +module Rel8.Internal.Query.Filter ( filter , where_ ) @@ -14,10 +14,10 @@ import qualified Opaleye.Operators as Opaleye import Data.Profunctor ( lmap ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye ( toColumn, toPrimExpr ) -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( fromOpaleye ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye ( toColumn, toPrimExpr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( fromOpaleye ) -- | @filter f x@ will be a zero-row query when @f x@ is @False@, and will diff --git a/src/Rel8/Query/Function.hs b/rel8-internal/src/Rel8/Internal/Query/Function.hs similarity index 60% rename from src/Rel8/Query/Function.hs rename to rel8-internal/src/Rel8/Internal/Query/Function.hs index f3459868..de772a11 100644 --- a/src/Rel8/Query/Function.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Function.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Query.Function +module Rel8.Internal.Query.Function ( queryFunction ) where @@ -13,13 +13,13 @@ import Prelude import qualified Opaleye.Internal.Operators as Opaleye -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Function (Arguments, primFunction) -import Rel8.Query (Query) -import Rel8.Query.Opaleye (fromOpaleye) -import Rel8.Schema.QualifiedName (QualifiedName) -import Rel8.Table (Table) -import Rel8.Table.Opaleye (castTable, relExprPP) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Function (Arguments, primFunction) +import Rel8.Internal.Query (Query) +import Rel8.Internal.Query.Opaleye (fromOpaleye) +import Rel8.Internal.Schema.QualifiedName (QualifiedName) +import Rel8.Internal.Table (Table) +import Rel8.Internal.Table.Opaleye (castTable, relExprPP) -- | Select each row from a function that returns a relation. This is diff --git a/src/Rel8/Query/Indexed.hs b/rel8-internal/src/Rel8/Internal/Query/Indexed.hs similarity index 54% rename from src/Rel8/Query/Indexed.hs rename to rel8-internal/src/Rel8/Internal/Query/Indexed.hs index a0a595d4..b0242de9 100644 --- a/src/Rel8/Query/Indexed.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Indexed.hs @@ -1,4 +1,4 @@ -module Rel8.Query.Indexed +module Rel8.Internal.Query.Indexed ( indexed ) where @@ -9,11 +9,11 @@ import Data.Int ( Int64 ) import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Window ( rowNumber ) -import Rel8.Query ( Query ) -import Rel8.Query.Window ( window ) -import Rel8.Table.Window ( currentRow ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Window ( rowNumber ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Window ( window ) +import Rel8.Internal.Table.Window ( currentRow ) -- | Pair each row of a query with its index within the query. diff --git a/src/Rel8/Query/Limit.hs b/rel8-internal/src/Rel8/Internal/Query/Limit.hs similarity index 80% rename from src/Rel8/Query/Limit.hs rename to rel8-internal/src/Rel8/Internal/Query/Limit.hs index 997eb955..f9ae6210 100644 --- a/src/Rel8/Query/Limit.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Limit.hs @@ -1,4 +1,4 @@ -module Rel8.Query.Limit +module Rel8.Internal.Query.Limit ( limit , offset ) @@ -11,8 +11,8 @@ import Prelude import qualified Opaleye -- rel8 -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( mapOpaleye ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye ) -- | @limit n@ select at most @n@ rows from a query. @limit n@ is equivalent diff --git a/src/Rel8/Query/List.hs b/rel8-internal/src/Rel8/Internal/Query/List.hs similarity index 79% rename from src/Rel8/Query/List.hs rename to rel8-internal/src/Rel8/Internal/Query/List.hs index 859ffab4..4adcb191 100644 --- a/src/Rel8/Query/List.hs +++ b/rel8-internal/src/Rel8/Internal/Query/List.hs @@ -2,7 +2,7 @@ {-# language GADTs #-} {-# language NamedFieldPuns #-} -module Rel8.Query.List +module Rel8.Internal.Query.List ( many, some , manyExpr, someExpr , catListTable, catNonEmptyTable @@ -20,22 +20,22 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Aggregate ( listAggExpr, nonEmptyAggExpr ) -import Rel8.Expr.Opaleye ( mapPrimExpr ) -import Rel8.Query ( Query ) -import Rel8.Query.Aggregate (aggregate, aggregate1) -import Rel8.Query.Rebind (hrebind, rebind) -import Rel8.Schema.HTable (HTable, hfield, hspecs, htabulate) -import Rel8.Schema.HTable.Vectorize ( hunvectorize ) -import Rel8.Schema.Null ( Sql ) -import Rel8.Schema.Spec ( Spec( Spec, info ) ) -import Rel8.Table (Table, fromColumns, toColumns) -import Rel8.Table.Aggregate ( listAgg, nonEmptyAgg ) -import Rel8.Table.List ( ListTable( ListTable ) ) -import Rel8.Table.NonEmpty ( NonEmptyTable( NonEmptyTable ) ) -import Rel8.Type ( DBType ) -import Rel8.Type.Array ( extractArrayElement ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Aggregate ( listAggExpr, nonEmptyAggExpr ) +import Rel8.Internal.Expr.Opaleye ( mapPrimExpr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Aggregate (aggregate, aggregate1) +import Rel8.Internal.Query.Rebind (hrebind, rebind) +import Rel8.Internal.Schema.HTable (HTable, hfield, hspecs, htabulate) +import Rel8.Internal.Schema.HTable.Vectorize ( hunvectorize ) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Schema.Spec ( Spec( Spec, info ) ) +import Rel8.Internal.Table (Table, fromColumns, toColumns) +import Rel8.Internal.Table.Aggregate ( listAgg, nonEmptyAgg ) +import Rel8.Internal.Table.List ( ListTable( ListTable ) ) +import Rel8.Internal.Table.NonEmpty ( NonEmptyTable( NonEmptyTable ) ) +import Rel8.Internal.Type ( DBType ) +import Rel8.Internal.Type.Array ( extractArrayElement ) -- | Aggregate a 'Query' into a 'ListTable'. If the supplied query returns 0 diff --git a/src/Rel8/Query/Loop.hs b/rel8-internal/src/Rel8/Internal/Query/Loop.hs similarity index 90% rename from src/Rel8/Query/Loop.hs rename to rel8-internal/src/Rel8/Internal/Query/Loop.hs index 613142cb..03043851 100644 --- a/src/Rel8/Query/Loop.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Loop.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Query.Loop +module Rel8.Internal.Query.Loop ( loop , loopDistinct ) where @@ -12,11 +12,11 @@ import Prelude import Opaleye.With (withRecursiveExplicit, withRecursiveDistinctExplicit) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( fromOpaleye, toOpaleye ) -import Rel8.Table ( Table ) -import Rel8.Table.Opaleye ( binaryspec ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( fromOpaleye, toOpaleye ) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Opaleye ( binaryspec ) -- | 'loop' allows the construction of recursive queries, using Postgres' diff --git a/src/Rel8/Query/Materialize.hs b/rel8-internal/src/Rel8/Internal/Query/Materialize.hs similarity index 80% rename from src/Rel8/Query/Materialize.hs rename to rel8-internal/src/Rel8/Internal/Query/Materialize.hs index a091c2f2..7def66f9 100644 --- a/src/Rel8/Query/Materialize.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Materialize.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Query.Materialize +module Rel8.Internal.Query.Materialize ( materialize ) where @@ -12,11 +12,11 @@ import Prelude import Opaleye.With ( withMaterializedExplicit ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( fromOpaleye, toOpaleye ) -import Rel8.Table ( Table ) -import Rel8.Table.Opaleye ( unpackspec ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( fromOpaleye, toOpaleye ) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Opaleye ( unpackspec ) -- | 'materialize' takes a 'Query' and fully evaluates it and caches the diff --git a/src/Rel8/Query/Maybe.hs b/rel8-internal/src/Rel8/Internal/Query/Maybe.hs similarity index 85% rename from src/Rel8/Query/Maybe.hs rename to rel8-internal/src/Rel8/Internal/Query/Maybe.hs index ba272651..588a30bb 100644 --- a/src/Rel8/Query/Maybe.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Maybe.hs @@ -2,7 +2,7 @@ {-# language LambdaCase #-} {-# language NamedFieldPuns #-} -module Rel8.Query.Maybe +module Rel8.Internal.Query.Maybe ( optional , catMaybeTable , traverseMaybeTable @@ -19,12 +19,12 @@ import Control.Comonad ( extract ) import qualified Opaleye.Internal.MaybeFields as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Eq ( (==.) ) -import Rel8.Query ( Query ) -import Rel8.Query.Filter ( where_ ) -import Rel8.Query.Opaleye ( mapOpaleye ) -import Rel8.Table.Maybe (MaybeTable(..), isJustTable, makeMaybeTable) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Eq ( (==.) ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Filter ( where_ ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye ) +import Rel8.Internal.Table.Maybe (MaybeTable(..), isJustTable, makeMaybeTable) -- | Convert a query that might return zero rows to a query that always returns diff --git a/src/Rel8/Query/Null.hs b/rel8-internal/src/Rel8/Internal/Query/Null.hs similarity index 65% rename from src/Rel8/Query/Null.hs rename to rel8-internal/src/Rel8/Internal/Query/Null.hs index af4d0dbd..2e4537e5 100644 --- a/src/Rel8/Query/Null.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Null.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Query.Null +module Rel8.Internal.Query.Null ( catNull , catNullTable ) @@ -10,12 +10,12 @@ where import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Null ( isNonNull, unsafeUnnullify ) -import Rel8.Table ( Table ) -import Rel8.Table.Null ( NullTable, isNonNullTable, unsafeUnnullifyTable ) -import Rel8.Query ( Query ) -import Rel8.Query.Filter ( where_ ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Null ( isNonNull, unsafeUnnullify ) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Null ( NullTable, isNonNullTable, unsafeUnnullifyTable ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Filter ( where_ ) -- | Filter a 'Query' that might return @null@ to a 'Query' without any diff --git a/src/Rel8/Query/Opaleye.hs b/rel8-internal/src/Rel8/Internal/Query/Opaleye.hs similarity index 94% rename from src/Rel8/Query/Opaleye.hs rename to rel8-internal/src/Rel8/Internal/Query/Opaleye.hs index 8e1601b2..60a2997f 100644 --- a/src/Rel8/Query/Opaleye.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Opaleye.hs @@ -1,6 +1,6 @@ {-# language TupleSections #-} -module Rel8.Query.Opaleye +module Rel8.Internal.Query.Opaleye ( fromOpaleye , toOpaleye , mapOpaleye @@ -18,7 +18,7 @@ import qualified Opaleye.Internal.QueryArr as Opaleye import qualified Opaleye.Internal.Tag as Opaleye -- rel8 -import {-# SOURCE #-} Rel8.Query ( Query( Query ) ) +import {-# SOURCE #-} Rel8.Internal.Query ( Query( Query ) ) fromOpaleye :: Opaleye.Select a -> Query a diff --git a/src/Rel8/Query/Order.hs b/rel8-internal/src/Rel8/Internal/Query/Order.hs similarity index 60% rename from src/Rel8/Query/Order.hs rename to rel8-internal/src/Rel8/Internal/Query/Order.hs index b98246cc..129ee68c 100644 --- a/src/Rel8/Query/Order.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Order.hs @@ -1,4 +1,4 @@ -module Rel8.Query.Order +module Rel8.Internal.Query.Order ( orderBy ) where @@ -10,9 +10,9 @@ import Prelude () import qualified Opaleye.Order as Opaleye ( orderBy ) -- rel8 -import Rel8.Order ( Order( Order ) ) -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( mapOpaleye ) +import Rel8.Internal.Order ( Order( Order ) ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye ) -- | Order the rows returned by a query. diff --git a/src/Rel8/Query/Rebind.hs b/rel8-internal/src/Rel8/Internal/Query/Rebind.hs similarity index 64% rename from src/Rel8/Query/Rebind.hs rename to rel8-internal/src/Rel8/Internal/Query/Rebind.hs index e5629acd..90a42678 100644 --- a/src/Rel8/Query/Rebind.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Rebind.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Query.Rebind +module Rel8.Internal.Query.Rebind ( rebind , hrebind ) @@ -14,14 +14,14 @@ import Control.Arrow ((<<<)) import qualified Opaleye.Internal.Rebind as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Query ( Query ) -import Rel8.Query.Limit (offset) -import Rel8.Schema.HTable (HTable) -import Rel8.Table ( Table ) -import Rel8.Table.Cols (Cols (Cols)) -import Rel8.Table.Opaleye ( unpackspec ) -import Rel8.Query.Opaleye (fromOpaleye) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Limit (offset) +import Rel8.Internal.Schema.HTable (HTable) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Cols (Cols (Cols)) +import Rel8.Internal.Table.Opaleye ( unpackspec ) +import Rel8.Internal.Query.Opaleye (fromOpaleye) -- | 'rebind' takes a variable name, some expressions, and binds each of them diff --git a/src/Rel8/Query/SQL.hs b/rel8-internal/src/Rel8/Internal/Query/SQL.hs similarity index 69% rename from src/Rel8/Query/SQL.hs rename to rel8-internal/src/Rel8/Internal/Query/SQL.hs index 3ab27185..2ab3f65e 100644 --- a/src/Rel8/Query/SQL.hs +++ b/rel8-internal/src/Rel8/Internal/Query/SQL.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Query.SQL +module Rel8.Internal.Query.SQL ( showQuery ) where @@ -13,10 +13,10 @@ import Prelude import qualified Opaleye.Internal.Tag as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Query ( Query ) -import Rel8.Statement.Select ( ppSelect ) -import Rel8.Table ( Table ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Statement.Select ( ppSelect ) +import Rel8.Internal.Table ( Table ) -- transformers import Control.Monad.Trans.State.Strict (evalState) diff --git a/src/Rel8/Query/Set.hs b/rel8-internal/src/Rel8/Internal/Query/Set.hs similarity index 85% rename from src/Rel8/Query/Set.hs rename to rel8-internal/src/Rel8/Internal/Query/Set.hs index d384262e..9672c1bf 100644 --- a/src/Rel8/Query/Set.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Set.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Query.Set +module Rel8.Internal.Query.Set ( union, unionAll , intersect, intersectAll , except, exceptAll @@ -14,12 +14,12 @@ import Prelude () import qualified Opaleye.Binary as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import {-# SOURCE #-} Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( zipOpaleyeWith ) -import Rel8.Table ( Table ) -import Rel8.Table.Eq ( EqTable ) -import Rel8.Table.Opaleye ( binaryspec ) +import Rel8.Internal.Expr ( Expr ) +import {-# SOURCE #-} Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( zipOpaleyeWith ) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Eq ( EqTable ) +import Rel8.Internal.Table.Opaleye ( binaryspec ) -- | Combine the results of two queries of the same type, collapsing diff --git a/src/Rel8/Query/These.hs b/rel8-internal/src/Rel8/Internal/Query/These.hs similarity index 84% rename from src/Rel8/Query/These.hs rename to rel8-internal/src/Rel8/Internal/Query/These.hs index 05336628..6a985d75 100644 --- a/src/Rel8/Query/These.hs +++ b/rel8-internal/src/Rel8/Internal/Query/These.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language GADTs #-} -module Rel8.Query.These +module Rel8.Internal.Query.These ( alignBy , keepHereTable, loseHereTable , keepThereTable, loseThereTable @@ -25,23 +25,23 @@ import qualified Opaleye.Internal.QueryArr as Opaleye import qualified Opaleye.Internal.Tag as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( boolExpr, not_ ) -import Rel8.Expr.Eq ( (==.) ) -import Rel8.Expr.Opaleye ( toPrimExpr, traversePrimExpr ) -import Rel8.Expr.Serialize ( litExpr ) -import Rel8.Query ( Query ) -import Rel8.Query.Filter ( where_ ) -import Rel8.Query.Maybe ( optional ) -import Rel8.Query.Opaleye ( zipOpaleyeWith ) -import Rel8.Table.Either ( EitherTable( EitherTable ) ) -import Rel8.Table.Maybe ( MaybeTable( MaybeTable ), isJustTable ) -import Rel8.Table.These +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( boolExpr, not_ ) +import Rel8.Internal.Expr.Eq ( (==.) ) +import Rel8.Internal.Expr.Opaleye ( toPrimExpr, traversePrimExpr ) +import Rel8.Internal.Expr.Serialize ( litExpr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Filter ( where_ ) +import Rel8.Internal.Query.Maybe ( optional ) +import Rel8.Internal.Query.Opaleye ( zipOpaleyeWith ) +import Rel8.Internal.Table.Either ( EitherTable( EitherTable ) ) +import Rel8.Internal.Table.Maybe ( MaybeTable( MaybeTable ), isJustTable ) +import Rel8.Internal.Table.These ( TheseTable( TheseTable, here, there ) , hasHereTable, hasThereTable , isThisTable, isThatTable, isThoseTable ) -import Rel8.Type.Tag ( EitherTag( IsLeft, IsRight ) ) +import Rel8.Internal.Type.Tag ( EitherTag( IsLeft, IsRight ) ) -- | Corresponds to a @FULL OUTER JOIN@ between two queries. diff --git a/src/Rel8/Query/Values.hs b/rel8-internal/src/Rel8/Internal/Query/Values.hs similarity index 65% rename from src/Rel8/Query/Values.hs rename to rel8-internal/src/Rel8/Internal/Query/Values.hs index 728eac25..9cbcf3c6 100644 --- a/src/Rel8/Query/Values.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Values.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Query.Values +module Rel8.Internal.Query.Values ( values ) where @@ -13,11 +13,11 @@ import Prelude import qualified Opaleye.Values as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import {-# SOURCE #-} Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( fromOpaleye ) -import Rel8.Table ( Table ) -import Rel8.Table.Opaleye ( valuesspec ) +import Rel8.Internal.Expr ( Expr ) +import {-# SOURCE #-} Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( fromOpaleye ) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Opaleye ( valuesspec ) -- | Construct a query that returns the given input list of rows. This is like diff --git a/src/Rel8/Query/Window.hs b/rel8-internal/src/Rel8/Internal/Query/Window.hs similarity index 80% rename from src/Rel8/Query/Window.hs rename to rel8-internal/src/Rel8/Internal/Query/Window.hs index 75c1a997..7d52f0d3 100644 --- a/src/Rel8/Query/Window.hs +++ b/rel8-internal/src/Rel8/Internal/Query/Window.hs @@ -1,4 +1,4 @@ -module Rel8.Query.Window +module Rel8.Internal.Query.Window ( window ) where @@ -10,9 +10,9 @@ import Prelude () import qualified Opaleye.Window as Opaleye -- rel8 -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( mapOpaleye ) -import Rel8.Window ( Window( Window ) ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye ) +import Rel8.Internal.Window ( Window( Window ) ) -- | 'window' runs a query composed of expressions containing diff --git a/src/Rel8/Schema/Context/Nullify.hs b/rel8-internal/src/Rel8/Internal/Schema/Context/Nullify.hs similarity index 82% rename from src/Rel8/Schema/Context/Nullify.hs rename to rel8-internal/src/Rel8/Internal/Schema/Context/Nullify.hs index d980a1a9..29b8bf70 100644 --- a/src/Rel8/Schema/Context/Nullify.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Context/Nullify.hs @@ -6,7 +6,7 @@ {-# language NamedFieldPuns #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.Context.Nullify +module Rel8.Internal.Schema.Context.Nullify ( Nullifiability(..), NonNullifiability(..), nullifiableOrNot, absurd , Nullifiable, nullifiability , guarder, nullifier, unnullifier @@ -23,17 +23,17 @@ import Prelude hiding ( null ) import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( boolExpr ) -import Rel8.Expr.Null ( nullify, unsafeUnnullify ) -import Rel8.Expr.Opaleye ( fromPrimExpr ) -import Rel8.Kind.Context ( SContext(..) ) -import Rel8.Schema.Field ( Field ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name( Name ) ) -import Rel8.Schema.Null ( Nullify, Nullity( Null, NotNull ) ) -import Rel8.Schema.Result ( Result ) -import Rel8.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( boolExpr ) +import Rel8.Internal.Expr.Null ( nullify, unsafeUnnullify ) +import Rel8.Internal.Expr.Opaleye ( fromPrimExpr ) +import Rel8.Internal.Kind.Context ( SContext(..) ) +import Rel8.Internal.Schema.Field ( Field ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name( Name ) ) +import Rel8.Internal.Schema.Null ( Nullify, Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) type Nullifiability :: K.Context -> Type diff --git a/src/Rel8/Schema/Dict.hs b/rel8-internal/src/Rel8/Internal/Schema/Dict.hs similarity index 90% rename from src/Rel8/Schema/Dict.hs rename to rel8-internal/src/Rel8/Internal/Schema/Dict.hs index 90a2fddb..7e678e00 100644 --- a/src/Rel8/Schema/Dict.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Dict.hs @@ -3,7 +3,7 @@ {-# language PolyKinds #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.Dict +module Rel8.Internal.Schema.Dict ( Dict( Dict ) ) where diff --git a/src/Rel8/Schema/Escape.hs b/rel8-internal/src/Rel8/Internal/Schema/Escape.hs similarity index 88% rename from src/Rel8/Schema/Escape.hs rename to rel8-internal/src/Rel8/Internal/Schema/Escape.hs index a0931a22..814190f4 100644 --- a/src/Rel8/Schema/Escape.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Escape.hs @@ -1,6 +1,6 @@ {-# language LambdaCase #-} -module Rel8.Schema.Escape +module Rel8.Internal.Schema.Escape ( escape ) where diff --git a/src/Rel8/Schema/Field.hs b/rel8-internal/src/Rel8/Internal/Schema/Field.hs similarity index 75% rename from src/Rel8/Schema/Field.hs rename to rel8-internal/src/Rel8/Internal/Schema/Field.hs index 5e8f5d6a..63cd620a 100644 --- a/src/Rel8/Schema/Field.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Field.hs @@ -4,7 +4,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilies #-} -module Rel8.Schema.Field +module Rel8.Internal.Schema.Field ( Field(..) , fields ) @@ -16,17 +16,17 @@ import Data.Kind ( Type ) import Prelude -- rel8 -import Rel8.Schema.HTable ( HField, htabulate ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import Rel8.Schema.Kind as K -import Rel8.Schema.Null ( Sql ) -import Rel8.Table +import Rel8.Internal.Schema.HTable ( HField, htabulate ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Transpose ( Transposes ) -import Rel8.Type ( DBType ) +import Rel8.Internal.Table.Transpose ( Transposes ) +import Rel8.Internal.Type ( DBType ) -- | A special context used in the construction of 'Rel8.Projection's. diff --git a/src/Rel8/Schema/HTable.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable.hs similarity index 96% rename from src/Rel8/Schema/HTable.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable.hs index 2642f205..87cabcc6 100644 --- a/src/Rel8/Schema/HTable.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable.hs @@ -13,7 +13,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Schema.HTable +module Rel8.Internal.Schema.HTable ( HTable (HField, HConstrainTable) , hfield, htabulate, hdicts, hspecs , hfoldMap, hmap, htabulateA, htabulateP @@ -42,10 +42,10 @@ import Data.Profunctor ( rmap, Profunctor (lmap) ) import Data.Profunctor.Product ( ProductProfunctor ((****)) ) -- rel8 -import Rel8.Schema.Dict ( Dict ) -import Rel8.Schema.Spec ( Spec ) -import Rel8.Schema.HTable.Product ( HProduct( HProduct ) ) -import qualified Rel8.Schema.Kind as K +import Rel8.Internal.Schema.Dict ( Dict ) +import Rel8.Internal.Schema.Spec ( Spec ) +import Rel8.Internal.Schema.HTable.Product ( HProduct( HProduct ) ) +import qualified Rel8.Internal.Schema.Kind as K -- semigroupoids import Data.Functor.Apply (Apply, (<.>), liftF2) diff --git a/src/Rel8/Schema/HTable/Either.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/Either.hs similarity index 63% rename from src/Rel8/Schema/HTable/Either.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/Either.hs index a3ff5a75..ff7118ec 100644 --- a/src/Rel8/Schema/HTable/Either.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/Either.hs @@ -4,7 +4,7 @@ {-# language DerivingStrategies #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.HTable.Either +module Rel8.Internal.Schema.HTable.Either ( HEitherTable(..) ) where @@ -14,12 +14,12 @@ import GHC.Generics ( Generic ) import Prelude () -- rel8 -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Identity ( HIdentity ) -import Rel8.Schema.HTable.Label ( HLabel ) -import Rel8.Schema.HTable.Nullify ( HNullify ) -import qualified Rel8.Schema.Kind as K -import Rel8.Type.Tag ( EitherTag ) +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity ) +import Rel8.Internal.Schema.HTable.Label ( HLabel ) +import Rel8.Internal.Schema.HTable.Nullify ( HNullify ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Type.Tag ( EitherTag ) type HEitherTable :: K.HTable -> K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/Identity.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/Identity.hs similarity index 73% rename from src/Rel8/Schema/HTable/Identity.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/Identity.hs index 3f96a346..fc224e18 100644 --- a/src/Rel8/Schema/HTable/Identity.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/Identity.hs @@ -4,7 +4,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Schema.HTable.Identity +module Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity, unHIdentity ) ) where @@ -15,15 +15,15 @@ import Data.Type.Equality ( (:~:)( Refl ) ) import Prelude -- rel8 -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable ( HTable, HConstrainTable, HField , hfield, htabulate, htraverse, hdicts, hspecs ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Null ( Sql ) -import Rel8.Schema.Spec ( specification ) -import Rel8.Type ( DBType ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Schema.Spec ( specification ) +import Rel8.Internal.Type ( DBType ) type HIdentity :: Type -> K.HTable diff --git a/src/Rel8/Schema/HTable/Label.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/Label.hs similarity index 91% rename from src/Rel8/Schema/HTable/Label.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/Label.hs index 43c1843f..701120f7 100644 --- a/src/Rel8/Schema/HTable/Label.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/Label.hs @@ -6,7 +6,7 @@ {-# language TypeApplications #-} {-# language TypeFamilies #-} -module Rel8.Schema.HTable.Label +module Rel8.Internal.Schema.HTable.Label ( HLabel, hlabel, hrelabel, hunlabel , hproject ) @@ -19,12 +19,12 @@ import GHC.TypeLits ( KnownSymbol, Symbol, symbolVal ) import Prelude -- rel8 -import Rel8.Schema.HTable +import Rel8.Internal.Schema.HTable ( HTable, HConstrainTable, HField , htabulate, hfield, htraverse, hdicts, hspecs ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Spec ( Spec(..) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Spec ( Spec(..) ) type HLabel :: Symbol -> K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/List.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/List.hs similarity index 58% rename from src/Rel8/Schema/HTable/List.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/List.hs index afba46c4..0f38283c 100644 --- a/src/Rel8/Schema/HTable/List.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/List.hs @@ -1,7 +1,7 @@ {-# language DataKinds #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.HTable.List +module Rel8.Internal.Schema.HTable.List ( HListTable ) where @@ -10,8 +10,8 @@ where import Prelude () -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.HTable.Vectorize ( HVectorize ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.HTable.Vectorize ( HVectorize ) type HListTable :: K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/MapTable.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/MapTable.hs similarity index 90% rename from src/Rel8/Schema/HTable/MapTable.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/MapTable.hs index df7970a1..daa94b64 100644 --- a/src/Rel8/Schema/HTable/MapTable.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/MapTable.hs @@ -14,7 +14,7 @@ {-# language UndecidableInstances #-} {-# language UndecidableSuperClasses #-} -module Rel8.Schema.HTable.MapTable +module Rel8.Internal.Schema.HTable.MapTable ( HMapTable(..) , MapSpec(..) , Precompose(..) @@ -28,14 +28,14 @@ import Data.Kind ( Constraint, Type ) import Prelude -- rel8 -import Rel8.FCF ( Exp, Eval ) -import Rel8.Schema.HTable +import Rel8.Internal.FCF ( Exp, Eval ) +import Rel8.Internal.Schema.HTable ( HTable, HConstrainTable, HField , hfield, htabulate, htraverse, hdicts, hspecs ) -import Rel8.Schema.Spec ( Spec ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.Spec ( Spec ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) type HMapTable :: (Type -> Exp Type) -> K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/Maybe.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/Maybe.hs similarity index 60% rename from src/Rel8/Schema/HTable/Maybe.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/Maybe.hs index f8f62e16..7d492c2a 100644 --- a/src/Rel8/Schema/HTable/Maybe.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/Maybe.hs @@ -4,7 +4,7 @@ {-# language DerivingStrategies #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.HTable.Maybe +module Rel8.Internal.Schema.HTable.Maybe ( HMaybeTable(..) ) where @@ -14,12 +14,12 @@ import GHC.Generics ( Generic ) import Prelude -- rel8 -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Identity ( HIdentity ) -import Rel8.Schema.HTable.Label ( HLabel ) -import Rel8.Schema.HTable.Nullify ( HNullify ) -import qualified Rel8.Schema.Kind as K -import Rel8.Type.Tag ( MaybeTag ) +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity ) +import Rel8.Internal.Schema.HTable.Label ( HLabel ) +import Rel8.Internal.Schema.HTable.Nullify ( HNullify ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Type.Tag ( MaybeTag ) type HMaybeTable :: K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/NonEmpty.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/NonEmpty.hs similarity index 63% rename from src/Rel8/Schema/HTable/NonEmpty.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/NonEmpty.hs index cfbc6877..6a4647a1 100644 --- a/src/Rel8/Schema/HTable/NonEmpty.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/NonEmpty.hs @@ -1,7 +1,7 @@ {-# language DataKinds #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.HTable.NonEmpty +module Rel8.Internal.Schema.HTable.NonEmpty ( HNonEmptyTable ) where @@ -11,8 +11,8 @@ import Data.List.NonEmpty ( NonEmpty ) import Prelude () -- rel8 -import Rel8.Schema.HTable.Vectorize ( HVectorize ) -import qualified Rel8.Schema.Kind as K +import Rel8.Internal.Schema.HTable.Vectorize ( HVectorize ) +import qualified Rel8.Internal.Schema.Kind as K type HNonEmptyTable :: K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/Nullify.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/Nullify.hs similarity index 86% rename from src/Rel8/Schema/HTable/Nullify.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/Nullify.hs index 4b3fa653..787131ec 100644 --- a/src/Rel8/Schema/HTable/Nullify.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/Nullify.hs @@ -16,7 +16,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Schema.HTable.Nullify +module Rel8.Internal.Schema.HTable.Nullify ( HNullify( HNullify ) , Nullify , hguard @@ -39,19 +39,19 @@ import Data.Profunctor (lmap, rmap) import Data.Profunctor.Product (ProductProfunctor) -- rel8 -import Rel8.FCF ( Eval, Exp ) -import Rel8.Schema.HTable +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Schema.HTable ( HTable, hfield, hspecs, htabulate, htabulateA, htabulateP ) -import Rel8.Schema.HTable.MapTable +import Rel8.Internal.Schema.HTable.MapTable ( HMapTable, HMapTableField( HMapTableField ) , MapSpec, mapInfo ) -import qualified Rel8.Schema.HTable.MapTable as HMapTable ( hproject ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Null ( Nullity( Null, NotNull ) ) -import qualified Rel8.Schema.Null as Type ( Nullify ) -import Rel8.Schema.Spec ( Spec(..) ) +import qualified Rel8.Internal.Schema.HTable.MapTable as HMapTable ( hproject ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ) ) +import qualified Rel8.Internal.Schema.Null as Type ( Nullify ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) -- semigroupoids import Data.Functor.Apply ( Apply ) diff --git a/src/Rel8/Schema/HTable/Product.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/Product.hs similarity index 72% rename from src/Rel8/Schema/HTable/Product.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/Product.hs index b1e779c5..05511cd6 100644 --- a/src/Rel8/Schema/HTable/Product.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/Product.hs @@ -1,7 +1,7 @@ {-# language DataKinds #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.HTable.Product +module Rel8.Internal.Schema.HTable.Product ( HProduct(..) ) where @@ -10,7 +10,7 @@ where import Prelude () -- rel8 -import qualified Rel8.Schema.Kind as K +import qualified Rel8.Internal.Schema.Kind as K type HProduct :: K.HTable -> K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/These.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/These.hs similarity index 66% rename from src/Rel8/Schema/HTable/These.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/These.hs index 95282fea..c93ddbd9 100644 --- a/src/Rel8/Schema/HTable/These.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/These.hs @@ -4,7 +4,7 @@ {-# language DerivingStrategies #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.HTable.These +module Rel8.Internal.Schema.HTable.These ( HTheseTable(..) ) where @@ -14,12 +14,12 @@ import GHC.Generics ( Generic ) import Prelude -- rel8 -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Identity ( HIdentity ) -import Rel8.Schema.HTable.Label ( HLabel ) -import Rel8.Schema.HTable.Nullify ( HNullify ) -import qualified Rel8.Schema.Kind as K -import Rel8.Type.Tag ( MaybeTag ) +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity ) +import Rel8.Internal.Schema.HTable.Label ( HLabel ) +import Rel8.Internal.Schema.HTable.Nullify ( HNullify ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Type.Tag ( MaybeTag ) type HTheseTable :: K.HTable -> K.HTable -> K.HTable diff --git a/src/Rel8/Schema/HTable/Vectorize.hs b/rel8-internal/src/Rel8/Internal/Schema/HTable/Vectorize.hs similarity index 88% rename from src/Rel8/Schema/HTable/Vectorize.hs rename to rel8-internal/src/Rel8/Internal/Schema/HTable/Vectorize.hs index 0bfca2e0..70d395e2 100644 --- a/src/Rel8/Schema/HTable/Vectorize.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/HTable/Vectorize.hs @@ -19,7 +19,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Schema.HTable.Vectorize +module Rel8.Internal.Schema.HTable.Vectorize ( HVectorize , hvectorize, hvectorizeA, hunvectorize , hnullify @@ -45,25 +45,25 @@ import Data.Profunctor.Product (ProductProfunctor) import Data.Profunctor (dimap) -- rel8 -import Rel8.FCF ( Eval, Exp ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.HTable +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.HTable ( HField, HTable, hfield, htabulate, htabulateA, hspecs , htraversePWithField ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import Rel8.Schema.HTable.MapTable +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import Rel8.Internal.Schema.HTable.MapTable ( HMapTable( HMapTable ), HMapTableField( HMapTableField ) , MapSpec, mapInfo , Precompose( Precompose ) ) -import qualified Rel8.Schema.HTable.MapTable as HMapTable ( hproject ) -import Rel8.Schema.HTable.Nullify (HNullify (HNullify)) -import Rel8.Schema.Null (Nullify, Unnullify, NotNull, Nullity (NotNull)) -import Rel8.Schema.Spec ( Spec(..) ) -import Rel8.Type.Array ( listTypeInformation, nonEmptyTypeInformation ) -import Rel8.Type.Information ( TypeInformation ) +import qualified Rel8.Internal.Schema.HTable.MapTable as HMapTable ( hproject ) +import Rel8.Internal.Schema.HTable.Nullify (HNullify (HNullify)) +import Rel8.Internal.Schema.Null (Nullify, Unnullify, NotNull, Nullity (NotNull)) +import Rel8.Internal.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Type.Array ( listTypeInformation, nonEmptyTypeInformation ) +import Rel8.Internal.Type.Information ( TypeInformation ) -- semialign import Data.Align (Semialign, alignWith) diff --git a/src/Rel8/Schema/Kind.hs b/rel8-internal/src/Rel8/Internal/Schema/Kind.hs similarity index 90% rename from src/Rel8/Schema/Kind.hs rename to rel8-internal/src/Rel8/Internal/Schema/Kind.hs index 9ef74cc2..cf95e72a 100644 --- a/src/Rel8/Schema/Kind.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Kind.hs @@ -1,6 +1,6 @@ {-# language StandaloneKindSignatures #-} -module Rel8.Schema.Kind +module Rel8.Internal.Schema.Kind ( Rel8able , Context , HTable diff --git a/src/Rel8/Schema/Name.hs b/rel8-internal/src/Rel8/Internal/Schema/Name.hs similarity index 84% rename from src/Rel8/Schema/Name.hs rename to rel8-internal/src/Rel8/Internal/Schema/Name.hs index 1ceac682..e24bca30 100644 --- a/src/Rel8/Schema/Name.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Name.hs @@ -10,7 +10,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Schema.Name +module Rel8.Internal.Schema.Name ( Name(..) , Selects , ppColumn @@ -31,17 +31,17 @@ import qualified Opaleye.Internal.HaskellDB.Sql.Print as Opaleye import Text.PrettyPrint ( Doc ) -- rel8 -import Rel8.Expr ( Expr ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import Rel8.Schema.Null ( Sql ) -import Rel8.Table +import Rel8.Internal.Expr ( Expr ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Transpose ( Transposes ) -import Rel8.Type ( DBType ) +import Rel8.Internal.Table.Transpose ( Transposes ) +import Rel8.Internal.Type ( DBType ) -- | A @Name@ is the name of a column, as it would be defined in a table's diff --git a/src/Rel8/Schema/Null.hs b/rel8-internal/src/Rel8/Internal/Schema/Null.hs similarity index 98% rename from src/Rel8/Schema/Null.hs rename to rel8-internal/src/Rel8/Internal/Schema/Null.hs index 9f1c0492..ab16c515 100644 --- a/src/Rel8/Schema/Null.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Null.hs @@ -11,7 +11,7 @@ {-# language UndecidableInstances #-} {-# language UndecidableSuperClasses #-} -module Rel8.Schema.Null +module Rel8.Internal.Schema.Null ( Nullify, Unnullify , NotNull , Homonullable diff --git a/src/Rel8/Schema/QualifiedName.hs b/rel8-internal/src/Rel8/Internal/Schema/QualifiedName.hs similarity index 95% rename from src/Rel8/Schema/QualifiedName.hs rename to rel8-internal/src/Rel8/Internal/Schema/QualifiedName.hs index ce55b090..adafe872 100644 --- a/src/Rel8/Schema/QualifiedName.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/QualifiedName.hs @@ -4,7 +4,7 @@ {-# language StandaloneKindSignatures #-} {-# language StrictData #-} -module Rel8.Schema.QualifiedName +module Rel8.Internal.Schema.QualifiedName ( QualifiedName (..) , ppQualifiedName , showQualifiedName @@ -21,7 +21,7 @@ import Prelude import Text.PrettyPrint (Doc, parens, text) -- rel8 -import Rel8.Schema.Escape (escape) +import Rel8.Internal.Schema.Escape (escape) -- | A name of an object (such as a table, view, function or sequence) diff --git a/src/Rel8/Schema/Result.hs b/rel8-internal/src/Rel8/Internal/Schema/Result.hs similarity index 86% rename from src/Rel8/Schema/Result.hs rename to rel8-internal/src/Rel8/Internal/Schema/Result.hs index 6801a43e..98f98f9b 100644 --- a/src/Rel8/Schema/Result.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Result.hs @@ -4,7 +4,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilies #-} -module Rel8.Schema.Result +module Rel8.Internal.Schema.Result ( Result , null, nullifier, unnullifier , vectorizer, unvectorizer @@ -16,9 +16,9 @@ import Data.Functor.Identity ( Identity( Identity), runIdentity ) import Prelude hiding ( null ) -- rel8 -import Rel8.Schema.Kind ( Context ) -import Rel8.Schema.Null ( Nullify, Nullity( Null, NotNull ) ) -import Rel8.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Schema.Kind ( Context ) +import Rel8.Internal.Schema.Null ( Nullify, Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) -- | The @Result@ context is the context used for decoded query results. diff --git a/src/Rel8/Schema/Spec.hs b/rel8-internal/src/Rel8/Internal/Schema/Spec.hs similarity index 70% rename from src/Rel8/Schema/Spec.hs rename to rel8-internal/src/Rel8/Internal/Schema/Spec.hs index 0d41f655..ccb83b65 100644 --- a/src/Rel8/Schema/Spec.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Spec.hs @@ -2,7 +2,7 @@ {-# language MonoLocalBinds #-} {-# language StandaloneKindSignatures #-} -module Rel8.Schema.Spec +module Rel8.Internal.Schema.Spec ( Spec( Spec, labels, info, nullity ) , specification ) @@ -13,9 +13,9 @@ import Data.Kind ( Type ) import Prelude -- rel8 -import Rel8.Schema.Null ( Nullity, Sql, Unnullify, nullable ) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Information ( TypeInformation ) +import Rel8.Internal.Schema.Null ( Nullity, Sql, Unnullify, nullable ) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Information ( TypeInformation ) type Spec :: Type -> Type diff --git a/src/Rel8/Schema/Table.hs b/rel8-internal/src/Rel8/Internal/Schema/Table.hs similarity index 90% rename from src/Rel8/Schema/Table.hs rename to rel8-internal/src/Rel8/Internal/Schema/Table.hs index 02d6aab1..877c1a6f 100644 --- a/src/Rel8/Schema/Table.hs +++ b/rel8-internal/src/Rel8/Internal/Schema/Table.hs @@ -5,7 +5,7 @@ {-# language StandaloneKindSignatures #-} {-# language StrictData #-} -module Rel8.Schema.Table +module Rel8.Internal.Schema.Table ( TableSchema(..) , ppTable ) @@ -19,7 +19,7 @@ import Prelude import Text.PrettyPrint ( Doc ) -- rel8 -import Rel8.Schema.QualifiedName (QualifiedName, ppQualifiedName) +import Rel8.Internal.Schema.QualifiedName (QualifiedName, ppQualifiedName) -- | The schema for a table. This is used to specify the name and schema that a diff --git a/src/Rel8/Statement.hs b/rel8-internal/src/Rel8/Internal/Statement.hs similarity index 94% rename from src/Rel8/Statement.hs rename to rel8-internal/src/Rel8/Internal/Statement.hs index 6887a55b..32e3f3e8 100644 --- a/src/Rel8/Statement.hs +++ b/rel8-internal/src/Rel8/Internal/Statement.hs @@ -11,7 +11,7 @@ {-# language TypeAbstractions #-} {-# language TypeApplications #-} -module Rel8.Statement +module Rel8.Internal.Statement ( Statement , statementReturning , statementNoReturning @@ -50,18 +50,18 @@ import Text.PrettyPrint ) -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Bool (false) -import Rel8.Query (Query) -import Rel8.Query.Aggregate (countRows) -import Rel8.Query.Each (each) -import Rel8.Schema.Escape (escape) -import Rel8.Schema.Table (TableSchema (..)) -import Rel8.Statement.Rows (Rows (..)) -import Rel8.Table (Table) -import Rel8.Table.Cols (fromCols) -import Rel8.Table.Name (namesFromLabelsTagged, showNames) -import Rel8.Table.Serialize (parse) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Bool (false) +import Rel8.Internal.Query (Query) +import Rel8.Internal.Query.Aggregate (countRows) +import Rel8.Internal.Query.Each (each) +import Rel8.Internal.Schema.Escape (escape) +import Rel8.Internal.Schema.Table (TableSchema (..)) +import Rel8.Internal.Statement.Rows (Rows (..)) +import Rel8.Internal.Table (Table) +import Rel8.Internal.Table.Cols (fromCols) +import Rel8.Internal.Table.Name (namesFromLabelsTagged, showNames) +import Rel8.Internal.Table.Serialize (parse) -- semigroupoids import Data.Functor.Apply (Apply, WrappedApplicative (..)) diff --git a/src/Rel8/Statement/Delete.hs b/rel8-internal/src/Rel8/Internal/Statement/Delete.hs similarity index 79% rename from src/Rel8/Statement/Delete.hs rename to rel8-internal/src/Rel8/Internal/Statement/Delete.hs index 45fbc237..e2111fa4 100644 --- a/src/Rel8/Statement/Delete.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Delete.hs @@ -6,7 +6,7 @@ {-# language StandaloneKindSignatures #-} {-# language StrictData #-} -module Rel8.Statement.Delete +module Rel8.Internal.Statement.Delete ( Delete(..) , delete , ppDelete @@ -24,14 +24,14 @@ import qualified Opaleye.Internal.Tag as Opaleye import Text.PrettyPrint ( Doc, (<+>), ($$), text ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Query ( Query ) -import Rel8.Schema.Name ( Selects ) -import Rel8.Schema.Table ( TableSchema, ppTable ) -import Rel8.Statement (Statement) -import Rel8.Statement.Returning (Returning, ppReturning, runReturning) -import Rel8.Statement.Using ( ppUsing ) -import Rel8.Statement.Where ( ppWhere ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Schema.Table ( TableSchema, ppTable ) +import Rel8.Internal.Statement (Statement) +import Rel8.Internal.Statement.Returning (Returning, ppReturning, runReturning) +import Rel8.Internal.Statement.Using ( ppUsing ) +import Rel8.Internal.Statement.Where ( ppWhere ) -- transformers import Control.Monad.Trans.State.Strict (State) diff --git a/src/Rel8/Statement/Insert.hs b/rel8-internal/src/Rel8/Internal/Statement/Insert.hs similarity index 77% rename from src/Rel8/Statement/Insert.hs rename to rel8-internal/src/Rel8/Internal/Statement/Insert.hs index 3e6ef14f..cdc6fdc4 100644 --- a/src/Rel8/Statement/Insert.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Insert.hs @@ -6,7 +6,7 @@ {-# language StandaloneKindSignatures #-} {-# language StrictData #-} -module Rel8.Statement.Insert +module Rel8.Internal.Statement.Insert ( Insert(..) , insert , ppInsert @@ -27,15 +27,15 @@ import qualified Opaleye.Internal.Tag as Opaleye import Text.PrettyPrint ( Doc, (<+>), ($$), parens, text ) -- rel8 -import Rel8.Query ( Query ) -import Rel8.Schema.Name ( Name, Selects, ppColumn ) -import Rel8.Schema.Table ( TableSchema(..), ppTable ) -import Rel8.Statement (Statement) -import Rel8.Statement.OnConflict ( OnConflict, ppOnConflict ) -import Rel8.Statement.Returning (Returning, ppReturning, runReturning) -import Rel8.Statement.Select ( ppRows ) -import Rel8.Table ( Table ) -import Rel8.Table.Name ( showNames ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Schema.Name ( Name, Selects, ppColumn ) +import Rel8.Internal.Schema.Table ( TableSchema(..), ppTable ) +import Rel8.Internal.Statement (Statement) +import Rel8.Internal.Statement.OnConflict ( OnConflict, ppOnConflict ) +import Rel8.Internal.Statement.Returning (Returning, ppReturning, runReturning) +import Rel8.Internal.Statement.Select ( ppRows ) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Name ( showNames ) -- transformers import Control.Monad.Trans.State.Strict (State) diff --git a/src/Rel8/Statement/OnConflict.hs b/rel8-internal/src/Rel8/Internal/Statement/OnConflict.hs similarity index 90% rename from src/Rel8/Statement/OnConflict.hs rename to rel8-internal/src/Rel8/Internal/Statement/OnConflict.hs index b5d1132e..87e60ef0 100644 --- a/src/Rel8/Statement/OnConflict.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/OnConflict.hs @@ -9,7 +9,7 @@ {-# language StrictData #-} {-# language TypeOperators #-} -module Rel8.Statement.OnConflict +module Rel8.Internal.Statement.OnConflict ( OnConflict(..) , Conflict (..) , Index (..) @@ -30,16 +30,16 @@ import qualified Opaleye.Internal.Sql as Opaleye import Text.PrettyPrint ( Doc, (<+>), ($$), parens, text ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye (toPrimExpr) -import Rel8.Schema.Escape (escape) -import Rel8.Schema.Name ( Selects ) -import Rel8.Schema.HTable (hfoldMap) -import Rel8.Schema.Table ( TableSchema(..) ) -import Rel8.Statement.Set ( ppSet ) -import Rel8.Statement.Where ( ppWhere ) -import Rel8.Table ( Table, toColumns ) -import Rel8.Table.Opaleye (attributes, view) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye (toPrimExpr) +import Rel8.Internal.Schema.Escape (escape) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Schema.HTable (hfoldMap) +import Rel8.Internal.Schema.Table ( TableSchema(..) ) +import Rel8.Internal.Statement.Set ( ppSet ) +import Rel8.Internal.Statement.Where ( ppWhere ) +import Rel8.Internal.Table ( Table, toColumns ) +import Rel8.Internal.Table.Opaleye (attributes, view) -- | 'OnConflict' represents the @ON CONFLICT@ clause of an @INSERT@ diff --git a/src/Rel8/Statement/Prepared.hs b/rel8-internal/src/Rel8/Internal/Statement/Prepared.hs similarity index 78% rename from src/Rel8/Statement/Prepared.hs rename to rel8-internal/src/Rel8/Internal/Statement/Prepared.hs index 2f54638a..848614e2 100644 --- a/src/Rel8/Statement/Prepared.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Prepared.hs @@ -6,7 +6,7 @@ {-# language ScopedTypeVariables #-} {-# language TypeApplications #-} -module Rel8.Statement.Prepared ( +module Rel8.Internal.Statement.Prepared ( input, prepared, ) where @@ -25,16 +25,16 @@ import qualified Hasql.Statement as Hasql import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Opaleye (fromPrimExpr, scastExpr) -import Rel8.Schema.HTable (hfield, hspecs, htabulateA) -import Rel8.Schema.Null (Nullity (Null, NotNull)) -import Rel8.Schema.Spec (Spec (..)) -import Rel8.Statement (Statement) -import Rel8.Table (Table, fromColumns, toResult) -import Rel8.Table.Serialize (Serializable) -import Rel8.Type.Encoder (binary) -import Rel8.Type.Information (encode) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Opaleye (fromPrimExpr, scastExpr) +import Rel8.Internal.Schema.HTable (hfield, hspecs, htabulateA) +import Rel8.Internal.Schema.Null (Nullity (Null, NotNull)) +import Rel8.Internal.Schema.Spec (Spec (..)) +import Rel8.Internal.Statement (Statement) +import Rel8.Internal.Table (Table, fromColumns, toResult) +import Rel8.Internal.Table.Serialize (Serializable) +import Rel8.Internal.Type.Encoder (binary) +import Rel8.Internal.Type.Information (encode) -- transformers import Control.Monad.Trans.State.Strict (evalState, state) @@ -47,7 +47,7 @@ import Control.Monad.Trans.State.Strict (evalState, state) The parameters @i@ are sent to the database directly via PostgreSQL's binary format. For large amounts of data this can be significantly more efficient -than embedding the values in the statement with 'Rel8.lit'. +than embedding the values in the statement with 'Rel8.Internal.lit'. -} prepared :: forall a b i o. Serializable a i => diff --git a/src/Rel8/Statement/Returning.hs b/rel8-internal/src/Rel8/Internal/Statement/Returning.hs similarity index 84% rename from src/Rel8/Statement/Returning.hs rename to rel8-internal/src/Rel8/Internal/Statement/Returning.hs index 30418e5a..2dd47d5f 100644 --- a/src/Rel8/Statement/Returning.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Returning.hs @@ -9,7 +9,7 @@ {-# language StrictData #-} {-# language TypeApplications #-} -module Rel8.Statement.Returning +module Rel8.Internal.Statement.Returning ( Returning( NoReturning, Returning ) , runReturning , ppReturning @@ -32,13 +32,13 @@ import qualified Opaleye.Internal.Tag as Opaleye import Text.PrettyPrint ( Doc, (<+>), text ) -- rel8 -import Rel8.Expr (Expr) -import Rel8.Query (Query) -import Rel8.Schema.Name ( Selects ) -import Rel8.Schema.Table ( TableSchema(..) ) -import Rel8.Statement (Statement, statementNoReturning, statementReturning) -import Rel8.Table (Table) -import Rel8.Table.Opaleye ( castTable, exprs, view ) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Query (Query) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Schema.Table ( TableSchema(..) ) +import Rel8.Internal.Statement (Statement, statementNoReturning, statementReturning) +import Rel8.Internal.Table (Table) +import Rel8.Internal.Table.Opaleye ( castTable, exprs, view ) -- transformers import Control.Monad.Trans.State.Strict (State) diff --git a/src/Rel8/Statement/Rows.hs b/rel8-internal/src/Rel8/Internal/Statement/Rows.hs similarity index 83% rename from src/Rel8/Statement/Rows.hs rename to rel8-internal/src/Rel8/Internal/Statement/Rows.hs index f8f488d8..0dcc2e57 100644 --- a/src/Rel8/Statement/Rows.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Rows.hs @@ -2,7 +2,7 @@ {-# language GADTs #-} {-# language StandaloneKindSignatures #-} -module Rel8.Statement.Rows +module Rel8.Internal.Statement.Rows ( Rows (..) ) where @@ -13,8 +13,8 @@ import Data.Kind (Type) import Prelude -- rel8 -import Rel8.Query (Query) -import Rel8.Table.Serialize (Serializable) +import Rel8.Internal.Query (Query) +import Rel8.Internal.Table.Serialize (Serializable) -- vector import Data.Vector (Vector) diff --git a/src/Rel8/Statement/Run.hs b/rel8-internal/src/Rel8/Internal/Statement/Run.hs similarity index 91% rename from src/Rel8/Statement/Run.hs rename to rel8-internal/src/Rel8/Internal/Statement/Run.hs index 1c9b8223..a9328b0a 100644 --- a/src/Rel8/Statement/Run.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Run.hs @@ -1,4 +1,4 @@ -module Rel8.Statement.Run +module Rel8.Internal.Statement.Run ( run_ , runN , run1 @@ -17,11 +17,11 @@ import qualified Hasql.Encoders as Hasql import qualified Hasql.Statement as Hasql -- rel8 -import Rel8.Query (Query) -import Rel8.Statement (Statement, ppDecodeStatement) -import Rel8.Statement.Rows (Rows (..)) -import Rel8.Statement.Select (ppSelect) -import Rel8.Table.Serialize (Serializable) +import Rel8.Internal.Query (Query) +import Rel8.Internal.Statement (Statement, ppDecodeStatement) +import Rel8.Internal.Statement.Rows (Rows (..)) +import Rel8.Internal.Statement.Select (ppSelect) +import Rel8.Internal.Table.Serialize (Serializable) -- text import qualified Data.Text as Text diff --git a/src/Rel8/Statement/SQL.hs b/rel8-internal/src/Rel8/Internal/Statement/SQL.hs similarity index 70% rename from src/Rel8/Statement/SQL.hs rename to rel8-internal/src/Rel8/Internal/Statement/SQL.hs index 2ec21367..9f54a5c8 100644 --- a/src/Rel8/Statement/SQL.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/SQL.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Statement.SQL +module Rel8.Internal.Statement.SQL ( showDelete , showInsert , showUpdate @@ -16,15 +16,15 @@ import Prelude import qualified Opaleye.Internal.Tag as Opaleye -- rel8 -import Rel8.Expr (Expr) -import Rel8.Statement (Statement, ppDecodeStatement) -import Rel8.Statement.Delete ( Delete, ppDelete ) -import Rel8.Statement.Insert ( Insert, ppInsert ) -import Rel8.Statement.Prepared (input) -import Rel8.Statement.Rows (Rows (Void)) -import Rel8.Statement.Select (ppSelect) -import Rel8.Statement.Update ( Update, ppUpdate ) -import Rel8.Table (Table) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Statement (Statement, ppDecodeStatement) +import Rel8.Internal.Statement.Delete ( Delete, ppDelete ) +import Rel8.Internal.Statement.Insert ( Insert, ppInsert ) +import Rel8.Internal.Statement.Prepared (input) +import Rel8.Internal.Statement.Rows (Rows (Void)) +import Rel8.Internal.Statement.Select (ppSelect) +import Rel8.Internal.Statement.Update ( Update, ppUpdate ) +import Rel8.Internal.Table (Table) -- transformers import Control.Monad.Trans.State.Strict (evalState) diff --git a/src/Rel8/Statement/Select.hs b/rel8-internal/src/Rel8/Internal/Statement/Select.hs similarity index 85% rename from src/Rel8/Statement/Select.hs rename to rel8-internal/src/Rel8/Internal/Statement/Select.hs index 256df11d..fad9dccc 100644 --- a/src/Rel8/Statement/Select.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Select.hs @@ -7,7 +7,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeApplications #-} -module Rel8.Statement.Select +module Rel8.Internal.Statement.Select ( select , ppSelect , Optimized(..) @@ -37,19 +37,19 @@ import qualified Opaleye.Internal.Tag as Opaleye import Text.PrettyPrint ( Doc ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( false ) -import Rel8.Expr.Opaleye ( toPrimExpr ) -import Rel8.Query ( Query ) -import Rel8.Query.Opaleye ( toOpaleye ) -import Rel8.Schema.Name ( Selects ) -import Rel8.Statement (Statement, statementReturning) -import Rel8.Table ( Table ) -import Rel8.Table.Cols ( toCols ) -import Rel8.Table.Name ( namesFromLabelsTagged ) -import Rel8.Table.Opaleye ( castTable, exprsWithNames ) -import qualified Rel8.Table.Opaleye as T -import Rel8.Table.Undefined ( undefined ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( false ) +import Rel8.Internal.Expr.Opaleye ( toPrimExpr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Opaleye ( toOpaleye ) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Statement (Statement, statementReturning) +import Rel8.Internal.Table ( Table ) +import Rel8.Internal.Table.Cols ( toCols ) +import Rel8.Internal.Table.Name ( namesFromLabelsTagged ) +import Rel8.Internal.Table.Opaleye ( castTable, exprsWithNames ) +import qualified Rel8.Internal.Table.Opaleye as T +import Rel8.Internal.Table.Undefined ( undefined ) -- transformers import Control.Monad.Trans.State.Strict (State) diff --git a/src/Rel8/Statement/Set.hs b/rel8-internal/src/Rel8/Internal/Statement/Set.hs similarity index 76% rename from src/Rel8/Statement/Set.hs rename to rel8-internal/src/Rel8/Internal/Statement/Set.hs index 8ff687d7..6c78816e 100644 --- a/src/Rel8/Statement/Set.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Set.hs @@ -1,7 +1,7 @@ {-# language MonoLocalBinds #-} {-# language NamedFieldPuns #-} -module Rel8.Statement.Set +module Rel8.Internal.Statement.Set ( ppSet ) where @@ -18,9 +18,9 @@ import qualified Opaleye.Internal.Sql as Opaleye import Text.PrettyPrint ( Doc, (<+>), equals, text ) -- rel8 -import Rel8.Schema.Name ( Selects, ppColumn ) -import Rel8.Schema.Table ( TableSchema(..) ) -import Rel8.Table.Opaleye ( attributes, exprsWithNames ) +import Rel8.Internal.Schema.Name ( Selects, ppColumn ) +import Rel8.Internal.Schema.Table ( TableSchema(..) ) +import Rel8.Internal.Table.Opaleye ( attributes, exprsWithNames ) ppSet :: Selects names exprs diff --git a/src/Rel8/Statement/Update.hs b/rel8-internal/src/Rel8/Internal/Statement/Update.hs similarity index 78% rename from src/Rel8/Statement/Update.hs rename to rel8-internal/src/Rel8/Internal/Statement/Update.hs index ba95e2c1..7687890a 100644 --- a/src/Rel8/Statement/Update.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Update.hs @@ -6,7 +6,7 @@ {-# language StandaloneKindSignatures #-} {-# language StrictData #-} -module Rel8.Statement.Update +module Rel8.Internal.Statement.Update ( Update(..) , update , ppUpdate @@ -24,15 +24,15 @@ import qualified Opaleye.Internal.Tag as Opaleye import Text.PrettyPrint ( Doc, (<+>), ($$), text ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Query ( Query ) -import Rel8.Schema.Name ( Selects ) -import Rel8.Schema.Table ( TableSchema(..), ppTable ) -import Rel8.Statement (Statement) -import Rel8.Statement.Returning (Returning, ppReturning, runReturning) -import Rel8.Statement.Set ( ppSet ) -import Rel8.Statement.Using ( ppFrom ) -import Rel8.Statement.Where ( ppWhere ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Schema.Table ( TableSchema(..), ppTable ) +import Rel8.Internal.Statement (Statement) +import Rel8.Internal.Statement.Returning (Returning, ppReturning, runReturning) +import Rel8.Internal.Statement.Set ( ppSet ) +import Rel8.Internal.Statement.Using ( ppFrom ) +import Rel8.Internal.Statement.Where ( ppWhere ) -- transformers import Control.Monad.Trans.State.Strict (State) diff --git a/src/Rel8/Statement/Using.hs b/rel8-internal/src/Rel8/Internal/Statement/Using.hs similarity index 79% rename from src/Rel8/Statement/Using.hs rename to rel8-internal/src/Rel8/Internal/Statement/Using.hs index a07f8068..b395e9e7 100644 --- a/src/Rel8/Statement/Using.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Using.hs @@ -1,6 +1,6 @@ {-# language OverloadedStrings #-} -module Rel8.Statement.Using +module Rel8.Internal.Statement.Using ( ppFrom , ppUsing ) @@ -16,9 +16,9 @@ import qualified Opaleye.Internal.Tag as Opaleye import Text.PrettyPrint ( Doc, (<+>), parens, text ) -- rel8 -import Rel8.Query ( Query ) -import Rel8.Schema.Table ( TableSchema(..), ppTable ) -import Rel8.Statement.Select ( Optimized(..), ppPrimSelect ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Schema.Table ( TableSchema(..), ppTable ) +import Rel8.Internal.Statement.Select ( Optimized(..), ppPrimSelect ) -- transformers import Control.Monad.Trans.State.Strict (State) diff --git a/src/Rel8/Statement/View.hs b/rel8-internal/src/Rel8/Internal/Statement/View.hs similarity index 88% rename from src/Rel8/Statement/View.hs rename to rel8-internal/src/Rel8/Internal/Statement/View.hs index 02093330..38525bf5 100644 --- a/src/Rel8/Statement/View.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/View.hs @@ -1,7 +1,7 @@ {-# language FlexibleContexts #-} {-# language MonoLocalBinds #-} -module Rel8.Statement.View +module Rel8.Internal.Statement.View ( createView , createOrReplaceView ) @@ -22,11 +22,11 @@ import qualified Opaleye.Internal.Tag as Opaleye import Text.PrettyPrint ( Doc, (<+>), ($$), text ) -- rel8 -import Rel8.Query ( Query ) -import Rel8.Schema.Name ( Selects ) -import Rel8.Schema.Table ( TableSchema ) -import Rel8.Statement.Insert ( ppInto ) -import Rel8.Statement.Select ( ppSelect ) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Schema.Table ( TableSchema ) +import Rel8.Internal.Statement.Insert ( ppInto ) +import Rel8.Internal.Statement.Select ( ppSelect ) -- text import qualified Data.Text as Text diff --git a/src/Rel8/Statement/Where.hs b/rel8-internal/src/Rel8/Internal/Statement/Where.hs similarity index 66% rename from src/Rel8/Statement/Where.hs rename to rel8-internal/src/Rel8/Internal/Statement/Where.hs index 5d6578ad..e1d96fad 100644 --- a/src/Rel8/Statement/Where.hs +++ b/rel8-internal/src/Rel8/Internal/Statement/Where.hs @@ -1,6 +1,6 @@ {-# language MonoLocalBinds #-} -module Rel8.Statement.Where +module Rel8.Internal.Statement.Where ( ppWhere ) where @@ -16,11 +16,11 @@ import qualified Opaleye.Internal.Sql as Opaleye import Text.PrettyPrint ( Doc, (<+>), text ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye ( toPrimExpr ) -import Rel8.Schema.Name ( Selects ) -import Rel8.Schema.Table ( TableSchema ) -import Rel8.Table.Opaleye ( attributes ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye ( toPrimExpr ) +import Rel8.Internal.Schema.Name ( Selects ) +import Rel8.Internal.Schema.Table ( TableSchema ) +import Rel8.Internal.Table.Opaleye ( attributes ) ppWhere :: Selects names exprs diff --git a/src/Rel8/Table.hs b/rel8-internal/src/Rel8/Internal/Table.hs similarity index 92% rename from src/Rel8/Table.hs rename to rel8-internal/src/Rel8/Internal/Table.hs index 40278ac7..9597d92f 100644 --- a/src/Rel8/Table.hs +++ b/rel8-internal/src/Rel8/Internal/Table.hs @@ -11,7 +11,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table +module Rel8.Internal.Table ( Table ( Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult @@ -30,19 +30,19 @@ import GHC.Generics ( Generic, Rep, from, to ) import Prelude hiding ( null ) -- rel8 -import Rel8.FCF ( Eval, Exp ) -import Rel8.Generic.Map ( Map ) -import Rel8.Generic.Table.Record +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Generic.Map ( Map ) +import Rel8.Internal.Generic.Table.Record ( GTable, GColumns, GContext, gfromColumns, gtoColumns , GSerialize, gfromResult, gtoResult ) -import Rel8.Generic.Record ( Record(..) ) -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Null ( Sql ) -import Rel8.Schema.Result ( Result ) -import Rel8.Type ( DBType ) +import Rel8.Internal.Generic.Record ( Record(..) ) +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Type ( DBType ) -- | @Table@s are one of the foundational elements of Rel8, and describe data @@ -50,7 +50,7 @@ import Rel8.Type ( DBType ) -- data under a shared context, and contexts describe how to interpret the -- metadata about a column to a particular Haskell type. In Rel8, we have -- contexts for expressions (the 'Rel8.Expr' context), aggregations (the --- 'Rel8.Aggregate' context), insert values (the 'Rel8.Insert' contex), among +-- 'Rel8.Aggregate' context), insert values (the 'Rel8.Insert' context), among -- others. -- -- In typical usage of Rel8 you don't need to derive instances of 'Table' diff --git a/src/Rel8/Table/ADT.hs b/rel8-internal/src/Rel8/Internal/Table/ADT.hs similarity index 87% rename from src/Rel8/Table/ADT.hs rename to rel8-internal/src/Rel8/Internal/Table/ADT.hs index dfd4f237..fc83ee14 100644 --- a/src/Rel8/Table/ADT.hs +++ b/rel8-internal/src/Rel8/Internal/Table/ADT.hs @@ -11,7 +11,7 @@ {-# language UndecidableInstances #-} {-# language UndecidableSuperClasses #-} -module Rel8.Table.ADT +module Rel8.Internal.Table.ADT ( ADT( ADT ) , ADTable , BuildableADT @@ -31,9 +31,9 @@ import GHC.TypeLits ( Symbol ) import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.FCF ( Eval, Exp ) -import Rel8.Generic.Construction +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Generic.Construction ( GGBuildable , GGBuild, ggbuild , GGConstructable @@ -41,20 +41,20 @@ import Rel8.Generic.Construction , GGDeconstruct, ggdeconstruct, ggdeconstructA , GGName, ggname ) -import Rel8.Generic.Record ( Record( Record ), unrecord ) -import Rel8.Generic.Rel8able +import Rel8.Internal.Generic.Record ( Record( Record ), unrecord ) +import Rel8.Internal.Generic.Rel8able ( Rel8able , GRep, GColumns, gfromColumns, gtoColumns , GFromExprs, gfromResult, gtoResult , TSerialize, deserialize, serialize ) -import qualified Rel8.Generic.Table.ADT as G -import qualified Rel8.Kind.Algebra as K -import Rel8.Schema.HTable ( HTable ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name ) -import Rel8.Schema.Result ( Result ) -import Rel8.Table ( Table, TColumns ) +import qualified Rel8.Internal.Generic.Table.ADT as G +import qualified Rel8.Internal.Kind.Algebra as K +import Rel8.Internal.Schema.HTable ( HTable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table ( Table, TColumns ) -- semigroupoids import Data.Functor.Apply (Apply) diff --git a/src/Rel8/Table/Aggregate.hs b/rel8-internal/src/Rel8/Internal/Table/Aggregate.hs similarity index 86% rename from src/Rel8/Table/Aggregate.hs rename to rel8-internal/src/Rel8/Internal/Table/Aggregate.hs index a9bc14af..93959002 100644 --- a/src/Rel8/Table/Aggregate.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Aggregate.hs @@ -5,7 +5,7 @@ {-# language TypeApplications #-} {-# language TypeFamilies #-} -module Rel8.Table.Aggregate +module Rel8.Internal.Table.Aggregate ( groupBy, groupByOn , listAgg, listAggOn, nonEmptyAgg, nonEmptyAggOn , listCat, listCatOn, nonEmptyCat, nonEmptyCatOn @@ -24,9 +24,9 @@ import qualified Opaleye.Internal.Aggregate as Opaleye import Data.Profunctor (dimap, lmap) -- rel8 -import Rel8.Aggregate (Aggregator, Aggregator' (Aggregator), Aggregator1) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Aggregate +import Rel8.Internal.Aggregate (Aggregator, Aggregator' (Aggregator), Aggregator1) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Aggregate ( filterWhereExplicit , groupByExprOn , slistAggExpr @@ -34,18 +34,18 @@ import Rel8.Expr.Aggregate , snonEmptyAggExpr , snonEmptyCatExpr ) -import Rel8.Order (Order (Order)) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable (HTable, hfield, hspecs, htabulateA) -import Rel8.Schema.HTable.Vectorize (htraverseVectorP, hvectorizeA) -import Rel8.Schema.Null ( Sql ) -import Rel8.Schema.Spec ( Spec( Spec, info ) ) -import Rel8.Table (Table, toColumns, fromColumns) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.List ( ListTable ) -import Rel8.Table.NonEmpty ( NonEmptyTable ) -import Rel8.Table.Opaleye (ifPP) -import Rel8.Type.Eq ( DBEq ) +import Rel8.Internal.Order (Order (Order)) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable (HTable, hfield, hspecs, htabulateA) +import Rel8.Internal.Schema.HTable.Vectorize (htraverseVectorP, hvectorizeA) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Schema.Spec ( Spec( Spec, info ) ) +import Rel8.Internal.Table (Table, toColumns, fromColumns) +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.List ( ListTable ) +import Rel8.Internal.Table.NonEmpty ( NonEmptyTable ) +import Rel8.Internal.Table.Opaleye (ifPP) +import Rel8.Internal.Type.Eq ( DBEq ) -- | Group equal tables together. This works by aggregating each column in the diff --git a/src/Rel8/Table/Aggregate/Maybe.hs b/rel8-internal/src/Rel8/Internal/Table/Aggregate/Maybe.hs similarity index 85% rename from src/Rel8/Table/Aggregate/Maybe.hs rename to rel8-internal/src/Rel8/Internal/Table/Aggregate/Maybe.hs index aa2a2cc6..45aceed8 100644 --- a/src/Rel8/Table/Aggregate/Maybe.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Aggregate/Maybe.hs @@ -1,6 +1,6 @@ {-# language FlexibleContexts #-} -module Rel8.Table.Aggregate.Maybe +module Rel8.Internal.Table.Aggregate.Maybe ( filterWhereOptional , optionalAggregate , aggregateJustTable @@ -19,23 +19,23 @@ import qualified Opaleye.Internal.Aggregate as Opaleye import Data.Profunctor (lmap) -- rel8 -import Rel8.Aggregate +import Rel8.Internal.Aggregate ( Aggregator' (Aggregator) , Aggregator, toAggregator , Aggregator1, toAggregator1 ) -import Rel8.Aggregate.Fold (Fallback (Fallback)) -import Rel8.Expr (Expr) -import Rel8.Expr.Aggregate (groupByExprOn) -import Rel8.Expr.Opaleye (toColumn, toPrimExpr) -import Rel8.Table (Table) -import Rel8.Table.Aggregate (filterWhere) -import Rel8.Table.Maybe +import Rel8.Internal.Aggregate.Fold (Fallback (Fallback)) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Aggregate (groupByExprOn) +import Rel8.Internal.Expr.Opaleye (toColumn, toPrimExpr) +import Rel8.Internal.Table (Table) +import Rel8.Internal.Table.Aggregate (filterWhere) +import Rel8.Internal.Table.Maybe ( MaybeTable (MaybeTable, just, tag), justTable, nothingTable , isJustTable , makeMaybeTable ) -import Rel8.Table.Nullify (aggregateNullify, unsafeUnnullifyTable) +import Rel8.Internal.Table.Nullify (aggregateNullify, unsafeUnnullifyTable) -- | A variant of 'filterWhere' that can be used with an 'Aggregator1' diff --git a/src/Rel8/Table/Alternative.hs b/rel8-internal/src/Rel8/Internal/Table/Alternative.hs similarity index 89% rename from src/Rel8/Table/Alternative.hs rename to rel8-internal/src/Rel8/Internal/Table/Alternative.hs index cf331ecd..8fe31c2c 100644 --- a/src/Rel8/Table/Alternative.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Alternative.hs @@ -2,7 +2,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeFamilies #-} -module Rel8.Table.Alternative +module Rel8.Internal.Table.Alternative ( AltTable ( (<|>:) ) , AlternativeTable ( emptyTable ) ) @@ -13,8 +13,8 @@ import Data.Kind ( Constraint, Type ) import Prelude () -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Table ( Table ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Table ( Table ) -- | Like 'Alt' in Haskell. This class is purely a Rel8 concept, and allows you diff --git a/src/Rel8/Table/Bool.hs b/rel8-internal/src/Rel8/Internal/Table/Bool.hs similarity index 81% rename from src/Rel8/Table/Bool.hs rename to rel8-internal/src/Rel8/Internal/Table/Bool.hs index 62339b3f..111558f6 100644 --- a/src/Rel8/Table/Bool.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Bool.hs @@ -2,7 +2,7 @@ {-# language TypeFamilies #-} {-# language ViewPatterns #-} -module Rel8.Table.Bool +module Rel8.Internal.Table.Bool ( bool , case_ , nullable @@ -13,11 +13,11 @@ where import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( boolExpr, caseExpr ) -import Rel8.Expr.Null ( isNull, unsafeUnnullify ) -import Rel8.Schema.HTable ( htabulate, hfield ) -import Rel8.Table ( Table, fromColumns, toColumns ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( boolExpr, caseExpr ) +import Rel8.Internal.Expr.Null ( isNull, unsafeUnnullify ) +import Rel8.Internal.Schema.HTable ( htabulate, hfield ) +import Rel8.Internal.Table ( Table, fromColumns, toColumns ) -- | Case analysis for an @Expr Bool@. Corresponds to 'Data.Bool.bool'. diff --git a/src/Rel8/Table/Cols.hs b/rel8-internal/src/Rel8/Internal/Table/Cols.hs similarity index 83% rename from src/Rel8/Table/Cols.hs rename to rel8-internal/src/Rel8/Internal/Table/Cols.hs index 2a98500b..1c949f0c 100644 --- a/src/Rel8/Table/Cols.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Cols.hs @@ -6,7 +6,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.Cols +module Rel8.Internal.Table.Cols ( Cols( Cols ) , fromCols , toCols @@ -18,10 +18,10 @@ import Data.Kind ( Type ) import Prelude -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.Result ( Result ) -import Rel8.Table ( Table(..) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table ( Table(..) ) type Cols :: K.Context -> K.HTable -> Type diff --git a/src/Rel8/Table/Either.hs b/rel8-internal/src/Rel8/Internal/Table/Either.hs similarity index 87% rename from src/Rel8/Table/Either.hs rename to rel8-internal/src/Rel8/Internal/Table/Either.hs index 88f8476f..7ad0071e 100644 --- a/src/Rel8/Table/Either.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Either.hs @@ -16,7 +16,7 @@ {-# options_ghc -fno-warn-orphans #-} -module Rel8.Table.Either +module Rel8.Internal.Table.Either ( EitherTable(..) , eitherTable, leftTable, rightTable , isLeftTable, isRightTable @@ -40,36 +40,36 @@ import Control.Comonad ( extract ) import Data.Profunctor (lmap) -- rel8 -import Rel8.Aggregate (Aggregator, Aggregator', Aggregator1, toAggregator1) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Aggregate (groupByExprOn) -import Rel8.Expr.Serialize ( litExpr ) -import Rel8.Kind.Context ( Reifiable ) -import Rel8.Schema.Context.Nullify ( Nullifiable ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable.Either ( HEitherTable(..) ) -import Rel8.Schema.HTable.Identity ( HIdentity(..) ) -import Rel8.Schema.HTable.Label ( hlabel, hunlabel ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name ) -import Rel8.Table +import Rel8.Internal.Aggregate (Aggregator, Aggregator', Aggregator1, toAggregator1) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Aggregate (groupByExprOn) +import Rel8.Internal.Expr.Serialize ( litExpr ) +import Rel8.Internal.Kind.Context ( Reifiable ) +import Rel8.Internal.Schema.Context.Nullify ( Nullifiable ) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable.Either ( HEitherTable(..) ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity(..) ) +import Rel8.Internal.Schema.HTable.Label ( hlabel, hunlabel ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Aggregate (filterWhere) -import Rel8.Table.Aggregate.Maybe (filterWhereOptional) -import Rel8.Table.Bool ( bool ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Maybe (MaybeTable) -import Rel8.Table.Nullify +import Rel8.Internal.Table.Aggregate (filterWhere) +import Rel8.Internal.Table.Aggregate.Maybe (filterWhereOptional) +import Rel8.Internal.Table.Bool ( bool ) +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Maybe (MaybeTable) +import Rel8.Internal.Table.Nullify ( Nullify, aggregateNullify, guard, unsafeUnnullifyTable ) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Projection ( Biprojectable, Projectable, biproject, project ) -import Rel8.Table.Serialize ( ToExprs ) -import Rel8.Table.Undefined ( undefined ) -import Rel8.Type.Tag ( EitherTag( IsLeft, IsRight ), isLeft, isRight ) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Projection ( Biprojectable, Projectable, biproject, project ) +import Rel8.Internal.Table.Serialize ( ToExprs ) +import Rel8.Internal.Table.Undefined ( undefined ) +import Rel8.Internal.Type.Tag ( EitherTag( IsLeft, IsRight ), isLeft, isRight ) -- semigroupoids import Data.Functor.Apply ( Apply, (<.>) ) diff --git a/src/Rel8/Table/Eq.hs b/rel8-internal/src/Rel8/Internal/Table/Eq.hs similarity index 82% rename from src/Rel8/Table/Eq.hs rename to rel8-internal/src/Rel8/Internal/Table/Eq.hs index 84a36def..66eabaee 100644 --- a/src/Rel8/Table/Eq.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Eq.hs @@ -13,7 +13,7 @@ {-# language UndecidableInstances #-} {-# language ViewPatterns #-} -module Rel8.Table.Eq +module Rel8.Internal.Table.Eq ( EqTable( eqTable ), (==:), (/=:) ) where @@ -27,18 +27,18 @@ import GHC.Generics ( Rep ) import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( (||.), (&&.) ) -import Rel8.Expr.Eq ( (==.), (/=.) ) -import Rel8.FCF ( Eval, Exp ) -import Rel8.Generic.Record ( Record ) -import Rel8.Generic.Table.Record ( GTable, GColumns, gtable ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable ( htabulateA, hfield ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import Rel8.Schema.Null ( Sql ) -import Rel8.Table ( Table, Columns, toColumns, TColumns ) -import Rel8.Type.Eq ( DBEq ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( (||.), (&&.) ) +import Rel8.Internal.Expr.Eq ( (==.), (/=.) ) +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Generic.Record ( Record ) +import Rel8.Internal.Generic.Table.Record ( GTable, GColumns, gtable ) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable ( htabulateA, hfield ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Table ( Table, Columns, toColumns, TColumns ) +import Rel8.Internal.Type.Eq ( DBEq ) -- | The class of 'Table's that can be compared for equality. Equality on diff --git a/src/Rel8/Table/HKD.hs b/rel8-internal/src/Rel8/Internal/Table/HKD.hs similarity index 88% rename from src/Rel8/Table/HKD.hs rename to rel8-internal/src/Rel8/Internal/Table/HKD.hs index c10500de..abb15e15 100644 --- a/src/Rel8/Table/HKD.hs +++ b/rel8-internal/src/Rel8/Internal/Table/HKD.hs @@ -12,7 +12,7 @@ {-# language UndecidableInstances #-} {-# language UndecidableSuperClasses #-} -module Rel8.Table.HKD +module Rel8.Internal.Table.HKD ( HKD( HKD ) , HKDable , BuildableHKD @@ -32,11 +32,11 @@ import GHC.TypeLits ( Symbol ) import Prelude -- rel8 -import Rel8.Column ( TColumn ) -import Rel8.Expr ( Expr ) -import Rel8.FCF ( Eval, Exp ) -import Rel8.Kind.Algebra ( KnownAlgebra ) -import Rel8.Generic.Construction +import Rel8.Internal.Column ( TColumn ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Kind.Algebra ( KnownAlgebra ) +import Rel8.Internal.Generic.Construction ( GGBuildable , GGBuild, ggbuild , GGConstructable @@ -44,26 +44,26 @@ import Rel8.Generic.Construction , GGDeconstruct, ggdeconstruct, ggdeconstructA , GGName, ggname ) -import Rel8.Generic.Map ( GMap ) -import Rel8.Generic.Record +import Rel8.Internal.Generic.Map ( GMap ) +import Rel8.Internal.Generic.Record ( GRecord, GRecordable, grecord, gunrecord , Record( Record ), unrecord ) -import Rel8.Generic.Rel8able +import Rel8.Internal.Generic.Rel8able ( Rel8able , GColumns, gfromColumns, gtoColumns , GFromExprs, gfromResult, gtoResult ) -import Rel8.Generic.Table +import Rel8.Internal.Generic.Table ( GGSerialize, GGColumns, GAlgebra, ggfromResult, ggtoResult ) -import Rel8.Generic.Table.Record ( GTable, GContext ) -import qualified Rel8.Generic.Table.Record as G -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.Name ( Name ) -import Rel8.Schema.Result ( Result ) -import Rel8.Table +import Rel8.Internal.Generic.Table.Record ( GTable, GContext ) +import qualified Rel8.Internal.Generic.Table.Record as G +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table ( Table, fromColumns, toColumns, fromResult, toResult , TTable, TColumns, TContext , TSerialize diff --git a/src/Rel8/Table/List.hs b/rel8-internal/src/Rel8/Internal/Table/List.hs similarity index 83% rename from src/Rel8/Table/List.hs rename to rel8-internal/src/Rel8/Internal/Table/List.hs index 3c5b7202..bc97654d 100644 --- a/src/Rel8/Table/List.hs +++ b/rel8-internal/src/Rel8/Internal/Table/List.hs @@ -10,7 +10,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.List +module Rel8.Internal.Table.List ( ListTable(..) , ($*) , listTable @@ -29,39 +29,39 @@ import Data.Kind ( Type ) import Prelude hiding (head, last, length) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Array ( sappend, sempty, slistOf ) -import Rel8.Expr.List (lengthExpr, sheadExpr, sindexExpr, slastExpr) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable.List ( HListTable ) -import Rel8.Schema.HTable.Vectorize +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Array ( sappend, sempty, slistOf ) +import Rel8.Internal.Expr.List (lengthExpr, sheadExpr, sindexExpr, slastExpr) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable.List ( HListTable ) +import Rel8.Internal.Schema.HTable.Vectorize ( hvectorize, hunvectorize , hnullify , happend, hempty , hproject, hcolumn , First (..) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name( Name ) ) -import Rel8.Schema.Null ( Nullity( Null, NotNull ) ) -import Rel8.Schema.Result ( vectorizer, unvectorizer ) -import Rel8.Schema.Spec ( Spec(..) ) -import Rel8.Table +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name( Name ) ) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.Result ( vectorizer, unvectorizer ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Table ( Table, Context, Columns, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Alternative +import Rel8.Internal.Table.Alternative ( AltTable, (<|>:) , AlternativeTable, emptyTable ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Null (NullTable) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Projection +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Null (NullTable) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Projection ( Projectable, Projecting, Projection, project, apply ) -import Rel8.Table.Serialize ( ToExprs ) +import Rel8.Internal.Table.Serialize ( ToExprs ) -- | A @ListTable@ value contains zero or more instances of @a@. You construct diff --git a/src/Rel8/Table/Maybe.hs b/rel8-internal/src/Rel8/Internal/Table/Maybe.hs similarity index 84% rename from src/Rel8/Table/Maybe.hs rename to rel8-internal/src/Rel8/Internal/Table/Maybe.hs index 2b344289..3fad2c88 100644 --- a/src/Rel8/Table/Maybe.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Maybe.hs @@ -12,7 +12,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.Maybe +module Rel8.Internal.Table.Maybe ( MaybeTable(..) , maybeTable, nothingTable, justTable , isNothingTable, isJustTable @@ -39,37 +39,37 @@ import qualified Opaleye.Field as Opaleye import qualified Opaleye.SqlTypes as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( boolExpr ) -import Rel8.Expr.Null ( isNull, isNonNull, null, nullify ) -import Rel8.Expr.Opaleye (fromColumn, fromPrimExpr) -import Rel8.Kind.Context ( Reifiable ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.HTable.Identity ( HIdentity(..) ) -import Rel8.Schema.HTable.Label ( hlabel, hunlabel ) -import Rel8.Schema.HTable.Maybe ( HMaybeTable(..) ) -import Rel8.Schema.Name ( Name ) -import Rel8.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable ) -import qualified Rel8.Schema.Null as N -import Rel8.Table +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( boolExpr ) +import Rel8.Internal.Expr.Null ( isNull, isNonNull, null, nullify ) +import Rel8.Internal.Expr.Opaleye (fromColumn, fromPrimExpr) +import Rel8.Internal.Kind.Context ( Reifiable ) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.HTable.Identity ( HIdentity(..) ) +import Rel8.Internal.Schema.HTable.Label ( hlabel, hunlabel ) +import Rel8.Internal.Schema.HTable.Maybe ( HMaybeTable(..) ) +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ), Sql, nullable ) +import qualified Rel8.Internal.Schema.Null as N +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Alternative +import Rel8.Internal.Table.Alternative ( AltTable, (<|>:) , AlternativeTable, emptyTable ) -import Rel8.Table.Bool ( bool ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Projection ( Projectable, project ) -import Rel8.Table.Nullify (Nullify, guard, unsafeUnnullifyTable) -import Rel8.Table.Serialize ( ToExprs ) -import Rel8.Table.Undefined ( undefined ) -import Rel8.Type ( DBType ) -import Rel8.Type.Tag ( MaybeTag( IsJust ) ) +import Rel8.Internal.Table.Bool ( bool ) +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Projection ( Projectable, project ) +import Rel8.Internal.Table.Nullify (Nullify, guard, unsafeUnnullifyTable) +import Rel8.Internal.Table.Serialize ( ToExprs ) +import Rel8.Internal.Table.Undefined ( undefined ) +import Rel8.Internal.Type ( DBType ) +import Rel8.Internal.Type.Tag ( MaybeTag( IsJust ) ) -- semigroupoids import Data.Functor.Apply ( Apply, (<.>) ) diff --git a/src/Rel8/Table/Name.hs b/rel8-internal/src/Rel8/Internal/Table/Name.hs similarity index 94% rename from src/Rel8/Table/Name.hs rename to rel8-internal/src/Rel8/Internal/Table/Name.hs index 0b6e163d..62f59b22 100644 --- a/src/Rel8/Table/Name.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Name.hs @@ -9,7 +9,7 @@ {-# language UndecidableInstances #-} {-# language ViewPatterns #-} -module Rel8.Table.Name +module Rel8.Internal.Table.Name ( namesFromLabels , namesFromLabelsTagged , namesFromLabelsWith @@ -32,10 +32,10 @@ import Prelude import qualified Opaleye.Internal.Tag as Opaleye -- rel8 -import Rel8.Schema.HTable (htabulateA, hfield, hspecs) -import Rel8.Schema.Name ( Name( Name ) ) -import Rel8.Schema.Spec ( Spec(..) ) -import Rel8.Table ( Table(..) ) +import Rel8.Internal.Schema.HTable (htabulateA, hfield, hspecs) +import Rel8.Internal.Schema.Name ( Name( Name ) ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Table ( Table(..) ) -- semigroupoids import Data.Functor.Apply (Apply) diff --git a/src/Rel8/Table/NonEmpty.hs b/rel8-internal/src/Rel8/Internal/Table/NonEmpty.hs similarity index 82% rename from src/Rel8/Table/NonEmpty.hs rename to rel8-internal/src/Rel8/Internal/Table/NonEmpty.hs index a37e0397..f6c8e5d7 100644 --- a/src/Rel8/Table/NonEmpty.hs +++ b/rel8-internal/src/Rel8/Internal/Table/NonEmpty.hs @@ -10,7 +10,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.NonEmpty +module Rel8.Internal.Table.NonEmpty ( NonEmptyTable(..) , ($+) , nonEmptyTable @@ -30,36 +30,36 @@ import Data.List.NonEmpty ( NonEmpty ) import Prelude hiding ( id ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Array ( sappend1, snonEmptyOf ) -import Rel8.Expr.NonEmpty (length1Expr, shead1Expr, sindex1Expr, slast1Expr) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable.NonEmpty ( HNonEmptyTable ) -import Rel8.Schema.HTable.Vectorize +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Array ( sappend1, snonEmptyOf ) +import Rel8.Internal.Expr.NonEmpty (length1Expr, shead1Expr, sindex1Expr, slast1Expr) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable.NonEmpty ( HNonEmptyTable ) +import Rel8.Internal.Schema.HTable.Vectorize ( hvectorize, hunvectorize , hnullify , happend , hproject, hcolumn , First (..) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name( Name ) ) -import Rel8.Schema.Null ( Nullity( Null, NotNull ) ) -import Rel8.Schema.Result ( vectorizer, unvectorizer ) -import Rel8.Schema.Spec ( Spec(..) ) -import Rel8.Table +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name( Name ) ) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.Result ( vectorizer, unvectorizer ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Table ( Table, Context, Columns, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Alternative ( AltTable, (<|>:) ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Null (NullTable) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Projection +import Rel8.Internal.Table.Alternative ( AltTable, (<|>:) ) +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Null (NullTable) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Projection ( Projectable, Projecting, Projection, project, apply ) -import Rel8.Table.Serialize ( ToExprs ) +import Rel8.Internal.Table.Serialize ( ToExprs ) -- | A @NonEmptyTable@ value contains one or more instances of @a@. You diff --git a/src/Rel8/Table/Null.hs b/rel8-internal/src/Rel8/Internal/Table/Null.hs similarity index 84% rename from src/Rel8/Table/Null.hs rename to rel8-internal/src/Rel8/Internal/Table/Null.hs index 754dde23..ec68baac 100644 --- a/src/Rel8/Table/Null.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Null.hs @@ -9,7 +9,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.Null +module Rel8.Internal.Table.Null ( NullTable(..) , nullableTable, nullTable, nullifyTable, unsafeUnnullifyTable , isNullTable, isNonNullTable @@ -26,28 +26,28 @@ import Prelude hiding ( null, undefined ) import Control.Comonad ( extract ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( not_ ) -import Rel8.Kind.Context ( Reifiable ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name ) -import Rel8.Table +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( not_ ) +import Rel8.Internal.Kind.Context ( Reifiable ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Alternative +import Rel8.Internal.Table.Alternative ( AltTable, (<|>:) , AlternativeTable, emptyTable ) -import Rel8.Table.Bool ( bool ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Maybe ( MaybeTable, justTable, maybeTable, nothingTable ) -import Rel8.Table.Nullify ( Nullify, isNull ) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Projection ( Projectable, project ) -import Rel8.Table.Serialize ( ToExprs ) -import Rel8.Table.Undefined ( undefined ) +import Rel8.Internal.Table.Bool ( bool ) +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Maybe ( MaybeTable, justTable, maybeTable, nothingTable ) +import Rel8.Internal.Table.Nullify ( Nullify, isNull ) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Projection ( Projectable, project ) +import Rel8.Internal.Table.Serialize ( ToExprs ) +import Rel8.Internal.Table.Undefined ( undefined ) -- | @NullTable t@ is the table @t@, but where all the columns in @t@ have the diff --git a/src/Rel8/Table/Nullify.hs b/rel8-internal/src/Rel8/Internal/Table/Nullify.hs similarity index 86% rename from src/Rel8/Table/Nullify.hs rename to rel8-internal/src/Rel8/Internal/Table/Nullify.hs index 799bec0d..aa9146e4 100644 --- a/src/Rel8/Table/Nullify.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Nullify.hs @@ -11,7 +11,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.Nullify +module Rel8.Internal.Table.Nullify ( Nullify , aggregateNullify , guard @@ -34,12 +34,12 @@ import Control.Comonad ( Comonad, duplicate, extract, ComonadApply, (<@>) ) import Data.Profunctor (dimap) -- rel8 -import Rel8.Aggregate (Aggregator') -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( (||.), false ) -import qualified Rel8.Expr.Null as Expr -import Rel8.Kind.Context ( Reifiable, contextSing ) -import Rel8.Schema.Context.Nullify +import Rel8.Internal.Aggregate (Aggregator') +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( (||.), false ) +import qualified Rel8.Internal.Expr.Null as Expr +import Rel8.Internal.Kind.Context ( Reifiable, contextSing ) +import Rel8.Internal.Schema.Context.Nullify ( Nullifiability( NExpr ) , NonNullifiability , Nullifiable, nullifiability @@ -48,25 +48,25 @@ import Rel8.Schema.Context.Nullify , nullifier , unnullifier ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable ( HTable ) -import Rel8.Schema.HTable.Nullify +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable ( HTable ) +import Rel8.Internal.Schema.HTable.Nullify ( HNullify, hnulls, hnullify, hunnullify , hguard , hproject ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Null ( Nullity( NotNull, Null ) ) -import qualified Rel8.Schema.Result as R -import Rel8.Table +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Null ( Nullity( NotNull, Null ) ) +import qualified Rel8.Internal.Schema.Result as R +import Rel8.Internal.Table ( Table, Columns, Context, toColumns, fromColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Schema.Spec ( Spec( Spec, nullity ) ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Projection ( Projectable, apply, project ) +import Rel8.Internal.Schema.Spec ( Spec( Spec, nullity ) ) +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Projection ( Projectable, apply, project ) -- semigroupoids import Data.Functor.Apply ( Apply, (<.>), liftF2 ) diff --git a/src/Rel8/Table/Opaleye.hs b/rel8-internal/src/Rel8/Internal/Table/Opaleye.hs similarity index 88% rename from src/Rel8/Table/Opaleye.hs rename to rel8-internal/src/Rel8/Internal/Table/Opaleye.hs index 3f468b26..49fe6f88 100644 --- a/src/Rel8/Table/Opaleye.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Opaleye.hs @@ -9,7 +9,7 @@ {-# options_ghc -Wno-deprecations #-} -module Rel8.Table.Opaleye +module Rel8.Internal.Table.Opaleye ( attributes , binaryspec , distinctspec @@ -48,22 +48,22 @@ import qualified Opaleye.Table as Opaleye import Data.Profunctor ( dimap, lmap ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye ( fromPrimExpr, toPrimExpr , scastExpr, traverseFieldP ) -import Rel8.Schema.HTable +import Rel8.Internal.Schema.HTable ( htabulateA, hfield, hspecs, htabulate , htraverseP, htraversePWithField ) -import Rel8.Schema.Name ( Name( Name ), Selects, ppColumn ) -import Rel8.Schema.QualifiedName (QualifiedName (QualifiedName)) -import Rel8.Schema.Spec ( Spec(..) ) -import Rel8.Schema.Table ( TableSchema(..), ppTable ) -import Rel8.Table ( Table, fromColumns, toColumns ) -import Rel8.Type.Information ( typeName ) -import Rel8.Type.Name (showTypeName) +import Rel8.Internal.Schema.Name ( Name( Name ), Selects, ppColumn ) +import Rel8.Internal.Schema.QualifiedName (QualifiedName (QualifiedName)) +import Rel8.Internal.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Schema.Table ( TableSchema(..), ppTable ) +import Rel8.Internal.Table ( Table, fromColumns, toColumns ) +import Rel8.Internal.Type.Information ( typeName ) +import Rel8.Internal.Type.Name (showTypeName) -- semigroupoids import Data.Functor.Apply ( WrappedApplicative(..) ) @@ -143,7 +143,7 @@ valuesspec :: Table Expr a => Opaleye.Valuesspec a a valuesspec = dimap toColumns fromColumns $ htraversePWithField (traverseFieldP . Opaleye.valuesspecFieldType . typeName) where - typeName = showTypeName . Rel8.Type.Information.typeName . info . hfield hspecs + typeName = showTypeName . Rel8.Internal.Type.Information.typeName . info . hfield hspecs view :: Selects names exprs => names -> exprs diff --git a/src/Rel8/Table/Ord.hs b/rel8-internal/src/Rel8/Internal/Table/Ord.hs similarity index 84% rename from src/Rel8/Table/Ord.hs rename to rel8-internal/src/Rel8/Internal/Table/Ord.hs index ac73fcdc..c1497608 100644 --- a/src/Rel8/Table/Ord.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Ord.hs @@ -12,7 +12,7 @@ {-# language UndecidableInstances #-} {-# language ViewPatterns #-} -module Rel8.Table.Ord +module Rel8.Internal.Table.Ord ( OrdTable( ordTable ), (<:), (<=:), (>:), (>=:), least, greatest ) where @@ -24,21 +24,21 @@ import GHC.Generics ( Rep ) import Prelude hiding ( seq ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( (||.), (&&.), false, true ) -import Rel8.Expr.Eq ( (==.) ) -import Rel8.Expr.Ord ( (<.), (>.) ) -import Rel8.FCF ( Eval, Exp ) -import Rel8.Generic.Record ( Record ) -import Rel8.Generic.Table.Record ( GTable, GColumns, gtable ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable ( htabulateA, hfield ) -import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) ) -import Rel8.Schema.Null (Sql) -import Rel8.Table ( Columns, toColumns, TColumns ) -import Rel8.Table.Bool ( bool ) -import Rel8.Table.Eq ( EqTable ) -import Rel8.Type.Ord ( DBOrd ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( (||.), (&&.), false, true ) +import Rel8.Internal.Expr.Eq ( (==.) ) +import Rel8.Internal.Expr.Ord ( (<.), (>.) ) +import Rel8.Internal.FCF ( Eval, Exp ) +import Rel8.Internal.Generic.Record ( Record ) +import Rel8.Internal.Generic.Table.Record ( GTable, GColumns, gtable ) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable ( htabulateA, hfield ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity( HIdentity ) ) +import Rel8.Internal.Schema.Null (Sql) +import Rel8.Internal.Table ( Columns, toColumns, TColumns ) +import Rel8.Internal.Table.Bool ( bool ) +import Rel8.Internal.Table.Eq ( EqTable ) +import Rel8.Internal.Type.Ord ( DBOrd ) -- | The class of 'Table's that can be ordered. Ordering on tables is defined diff --git a/src/Rel8/Table/Order.hs b/rel8-internal/src/Rel8/Internal/Table/Order.hs similarity index 73% rename from src/Rel8/Table/Order.hs rename to rel8-internal/src/Rel8/Internal/Table/Order.hs index c4a20655..8684bb2b 100644 --- a/src/Rel8/Table/Order.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Order.hs @@ -4,7 +4,7 @@ {-# language TypeApplications #-} {-# language TypeFamilies #-} -module Rel8.Table.Order +module Rel8.Internal.Table.Order ( ascTable , descTable ) @@ -16,14 +16,14 @@ import Data.Functor.Contravariant ( (>$<), contramap ) import Prelude -- rel8 -import Rel8.Expr.Order ( asc, desc, nullsFirst, nullsLast ) -import Rel8.Order ( Order ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable (htabulateA, hfield, hspecs) -import Rel8.Schema.Null ( Nullity( Null, NotNull ) ) -import Rel8.Schema.Spec ( Spec( Spec, nullity ) ) -import Rel8.Table ( Columns, toColumns ) -import Rel8.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Expr.Order ( asc, desc, nullsFirst, nullsLast ) +import Rel8.Internal.Order ( Order ) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable (htabulateA, hfield, hspecs) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.Spec ( Spec( Spec, nullity ) ) +import Rel8.Internal.Table ( Columns, toColumns ) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) -- | Construct an 'Order' for a 'Table' by sorting all columns into ascending diff --git a/src/Rel8/Table/Projection.hs b/rel8-internal/src/Rel8/Internal/Table/Projection.hs similarity index 88% rename from src/Rel8/Table/Projection.hs rename to rel8-internal/src/Rel8/Internal/Table/Projection.hs index efdf9fcc..4a225675 100644 --- a/src/Rel8/Table/Projection.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Projection.hs @@ -5,7 +5,7 @@ {-# language StandaloneKindSignatures #-} {-# language UndecidableInstances #-} -module Rel8.Table.Projection +module Rel8.Internal.Table.Projection ( Projection , Projectable( project ) , Biprojectable( biproject ) @@ -19,10 +19,10 @@ import Data.Kind ( Constraint, Type ) import Prelude -- rel8 -import Rel8.Schema.Field ( Field( Field ), fields ) -import Rel8.Schema.HTable ( hfield, htabulate ) -import Rel8.Table ( Columns, Context, Transpose, toColumns ) -import Rel8.Table.Transpose ( Transposes ) +import Rel8.Internal.Schema.Field ( Field( Field ), fields ) +import Rel8.Internal.Schema.HTable ( hfield, htabulate ) +import Rel8.Internal.Table ( Columns, Context, Transpose, toColumns ) +import Rel8.Internal.Table.Transpose ( Transposes ) -- | The constraint @'Projecting' a b@ ensures that @'Projection' a b@ is a diff --git a/src/Rel8/Table/Rel8able.hs b/rel8-internal/src/Rel8/Internal/Table/Rel8able.hs similarity index 71% rename from src/Rel8/Table/Rel8able.hs rename to rel8-internal/src/Rel8/Internal/Table/Rel8able.hs index bd8a2b62..0b1bdcc6 100644 --- a/src/Rel8/Table/Rel8able.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Rel8able.hs @@ -10,7 +10,7 @@ {-# options_ghc -fno-warn-orphans #-} -module Rel8.Table.Rel8able +module Rel8.Internal.Table.Rel8able ( ) where @@ -22,29 +22,29 @@ import Prelude () import Data.Type.Equality.Compat -- rel8 -import Rel8.Expr ( Expr ) -import qualified Rel8.Kind.Algebra as K -import Rel8.Kind.Context ( Reifiable, contextSing ) -import Rel8.Generic.Rel8able +import Rel8.Internal.Expr ( Expr ) +import qualified Rel8.Internal.Kind.Algebra as K +import Rel8.Internal.Kind.Context ( Reifiable, contextSing ) +import Rel8.Internal.Generic.Rel8able ( Rel8able, Algebra , GColumns, gfromColumns, gtoColumns , GFromExprs, gfromResult, gtoResult ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.HTable ( HConstrainTable, hdicts ) -import Rel8.Schema.Null ( Sql ) -import Rel8.Schema.Result ( Result ) -import Rel8.Table +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.HTable ( HConstrainTable, hdicts ) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.ADT ( ADT ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Serialize ( ToExprs ) -import Rel8.Type.Eq ( DBEq ) -import Rel8.Type.Ord ( DBOrd ) +import Rel8.Internal.Table.ADT ( ADT ) +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Serialize ( ToExprs ) +import Rel8.Internal.Type.Eq ( DBEq ) +import Rel8.Internal.Type.Ord ( DBOrd ) instance (Rel8able t, Reifiable context, context ~ context') => diff --git a/src/Rel8/Table/Serialize.hs b/rel8-internal/src/Rel8/Internal/Table/Serialize.hs similarity index 88% rename from src/Rel8/Table/Serialize.hs rename to rel8-internal/src/Rel8/Internal/Table/Serialize.hs index cd746b1b..f9392880 100644 --- a/src/Rel8/Table/Serialize.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Serialize.hs @@ -10,7 +10,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.Serialize +module Rel8.Internal.Table.Serialize ( Serializable, lit, litHTable, parse , ToExprs ) @@ -26,14 +26,14 @@ import Prelude import qualified Hasql.Decoders as Hasql -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Serialize ( slitExpr, sparseValue ) -import Rel8.Schema.HTable ( HTable, htabulate, htabulateA, hfield, hspecs ) -import Rel8.Schema.Null ( NotNull, Sql ) -import Rel8.Schema.Result ( Result ) -import Rel8.Schema.Spec ( Spec(..) ) -import Rel8.Table ( Table, fromColumns, FromExprs, fromResult, toResult ) -import Rel8.Type ( DBType ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Serialize ( slitExpr, sparseValue ) +import Rel8.Internal.Schema.HTable ( HTable, htabulate, htabulateA, hfield, hspecs ) +import Rel8.Internal.Schema.Null ( NotNull, Sql ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Table ( Table, fromColumns, FromExprs, fromResult, toResult ) +import Rel8.Internal.Type ( DBType ) -- semigroupoids import Data.Functor.Apply ( WrappedApplicative(..) ) diff --git a/src/Rel8/Table/These.hs b/rel8-internal/src/Rel8/Internal/Table/These.hs similarity index 92% rename from src/Rel8/Table/These.hs rename to rel8-internal/src/Rel8/Internal/Table/These.hs index 9809f2b8..29a6505c 100644 --- a/src/Rel8/Table/These.hs +++ b/rel8-internal/src/Rel8/Internal/Table/These.hs @@ -15,7 +15,7 @@ {-# options_ghc -fno-warn-orphans #-} -module Rel8.Table.These +module Rel8.Internal.Table.These ( TheseTable(..) , theseTable, thisTable, thatTable, thoseTable , isThisTable, isThatTable, isThoseTable @@ -43,44 +43,44 @@ import Prelude hiding ( null, undefined ) import Data.Profunctor (lmap) -- rel8 -import Rel8.Aggregate (Aggregator, Aggregator', Aggregator1) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Bool ( (&&.), (||.), boolExpr, not_ ) -import Rel8.Expr.Null ( null, isNonNull ) -import Rel8.Kind.Context ( Reifiable ) -import Rel8.Schema.Context.Nullify ( Nullifiable ) -import Rel8.Schema.Dict ( Dict( Dict ) ) -import Rel8.Schema.HTable.Label ( hlabel, hrelabel, hunlabel ) -import Rel8.Schema.HTable.Identity ( HIdentity(..) ) -import Rel8.Schema.HTable.Maybe ( HMaybeTable(..) ) -import Rel8.Schema.HTable.These ( HTheseTable(..) ) -import qualified Rel8.Schema.Kind as K -import Rel8.Schema.Name ( Name ) -import Rel8.Table +import Rel8.Internal.Aggregate (Aggregator, Aggregator', Aggregator1) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Bool ( (&&.), (||.), boolExpr, not_ ) +import Rel8.Internal.Expr.Null ( null, isNonNull ) +import Rel8.Internal.Kind.Context ( Reifiable ) +import Rel8.Internal.Schema.Context.Nullify ( Nullifiable ) +import Rel8.Internal.Schema.Dict ( Dict( Dict ) ) +import Rel8.Internal.Schema.HTable.Label ( hlabel, hrelabel, hunlabel ) +import Rel8.Internal.Schema.HTable.Identity ( HIdentity(..) ) +import Rel8.Internal.Schema.HTable.Maybe ( HMaybeTable(..) ) +import Rel8.Internal.Schema.HTable.These ( HTheseTable(..) ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Schema.Name ( Name ) +import Rel8.Internal.Table ( Table, Columns, Context, fromColumns, toColumns , FromExprs, fromResult, toResult , Transpose ) -import Rel8.Table.Aggregate (filterWhere) -import Rel8.Table.Aggregate.Maybe +import Rel8.Internal.Table.Aggregate (filterWhere) +import Rel8.Internal.Table.Aggregate.Maybe ( aggregateJustTable, aggregateJustTable1 , aggregateMaybeTable , filterWhereOptional ) -import Rel8.Table.Eq ( EqTable, eqTable ) -import Rel8.Table.Maybe +import Rel8.Internal.Table.Eq ( EqTable, eqTable ) +import Rel8.Internal.Table.Maybe ( MaybeTable(..) , maybeTable, justTable, nothingTable , isJustTable , nameMaybeTable , unsafeFromJustTable ) -import Rel8.Table.Nullify ( Nullify, guard ) -import Rel8.Table.Ord ( OrdTable, ordTable ) -import Rel8.Table.Projection ( Biprojectable, Projectable, biproject, project ) -import Rel8.Table.Serialize ( ToExprs ) -import Rel8.Table.Undefined ( undefined ) -import Rel8.Type.Tag ( MaybeTag ) +import Rel8.Internal.Table.Nullify ( Nullify, guard ) +import Rel8.Internal.Table.Ord ( OrdTable, ordTable ) +import Rel8.Internal.Table.Projection ( Biprojectable, Projectable, biproject, project ) +import Rel8.Internal.Table.Serialize ( ToExprs ) +import Rel8.Internal.Table.Undefined ( undefined ) +import Rel8.Internal.Type.Tag ( MaybeTag ) -- semigroupoids import Data.Functor.Apply ( Apply, (<.>) ) diff --git a/src/Rel8/Table/Transpose.hs b/rel8-internal/src/Rel8/Internal/Table/Transpose.hs similarity index 88% rename from src/Rel8/Table/Transpose.hs rename to rel8-internal/src/Rel8/Internal/Table/Transpose.hs index 7a4421ed..92ab6f0f 100644 --- a/src/Rel8/Table/Transpose.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Transpose.hs @@ -6,7 +6,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Table.Transpose +module Rel8.Internal.Table.Transpose ( Transposes ) where @@ -19,8 +19,8 @@ import Prelude () import Data.Type.Equality.Compat -- rel8 -import qualified Rel8.Schema.Kind as K -import Rel8.Table ( Table, Transpose, Congruent ) +import qualified Rel8.Internal.Schema.Kind as K +import Rel8.Internal.Table ( Table, Transpose, Congruent ) -- | @'Transposes' from to a b@ means that @a@ and @b@ are 'Table's, in the diff --git a/src/Rel8/Table/Undefined.hs b/rel8-internal/src/Rel8/Internal/Table/Undefined.hs similarity index 52% rename from src/Rel8/Table/Undefined.hs rename to rel8-internal/src/Rel8/Internal/Table/Undefined.hs index 3e42ebd2..f53ef2cf 100644 --- a/src/Rel8/Table/Undefined.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Undefined.hs @@ -2,7 +2,7 @@ {-# language NamedFieldPuns #-} {-# language TypeFamilies #-} -module Rel8.Table.Undefined +module Rel8.Internal.Table.Undefined ( undefined ) where @@ -11,12 +11,12 @@ where import Prelude hiding ( undefined ) -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Null ( snull, unsafeUnnullify ) -import Rel8.Schema.HTable ( htabulate, hfield, hspecs ) -import Rel8.Schema.Null ( Nullity( Null, NotNull ) ) -import Rel8.Schema.Spec ( Spec(..) ) -import Rel8.Table ( Table, fromColumns ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Null ( snull, unsafeUnnullify ) +import Rel8.Internal.Schema.HTable ( htabulate, hfield, hspecs ) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.Spec ( Spec(..) ) +import Rel8.Internal.Table ( Table, fromColumns ) undefined :: Table Expr a => a diff --git a/rel8-internal/src/Rel8/Internal/Table/Verify.hs b/rel8-internal/src/Rel8/Internal/Table/Verify.hs new file mode 100644 index 00000000..6768f733 --- /dev/null +++ b/rel8-internal/src/Rel8/Internal/Table/Verify.hs @@ -0,0 +1,644 @@ +{-# language BlockArguments #-} +{-# language DeriveAnyClass #-} +{-# language DeriveGeneric #-} +{-# language DerivingStrategies #-} +{-# language DuplicateRecordFields #-} +{-# language FlexibleContexts #-} +{-# language FlexibleInstances #-} +{-# language GADTs #-} +{-# language GeneralizedNewtypeDeriving #-} +{-# language LambdaCase #-} +{-# language NamedFieldPuns #-} +{-# language OverloadedRecordDot #-} +{-# language OverloadedStrings #-} +{-# language RankNTypes #-} +{-# language RecordWildCards #-} +{-# language ScopedTypeVariables #-} +{-# language StandaloneDeriving #-} +{-# language TypeApplications #-} +{-# options_ghc -Wno-partial-fields #-} + +module Rel8.Internal.Table.Verify + ( getSchemaErrors + , SomeTableSchema(..) + , showCreateTable + , checkedShowCreateTable + ) +where + +-- base +import Data.Bits (shiftR, (.&.)) +import Data.Function ((&)) +import Data.Functor ((<&>)) +import Data.Functor.Const +import Data.Functor.Contravariant ( (>$<) ) +import Data.Int ( Int16, Int64 ) +import qualified Data.List as L +import Data.List.NonEmpty ( NonEmpty((:|)) ) +import qualified Data.List.NonEmpty as NonEmpty +import Data.Maybe (isJust, mapMaybe) +import Data.Text ( Text ) +import qualified Data.Text as T +import GHC.Generics +import Prelude hiding ( filter ) +import qualified Prelude as P + +-- containers +import qualified Data.Map as M + +-- hasql +import qualified Hasql.Statement as HS + +-- rel8 +import Rel8.Internal.Column ( Column ) +import Rel8.Internal.Column.List ( HList ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Eq ((==.)) +import Rel8.Internal.Expr.Ord ((>.)) +import Rel8.Internal.Expr.Order (asc) +import Rel8.Internal.Generic.Rel8able (GFromExprs, Rel8able) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Each (each) +import Rel8.Internal.Query.Filter (filter) +import Rel8.Internal.Query.List (many) +import Rel8.Internal.Query.Order (orderBy) +import Rel8.Internal.Schema.HTable +import Rel8.Internal.Schema.Name ( Name(Name) ) +import Rel8.Internal.Schema.Null hiding (nullable) +import Rel8.Internal.Schema.QualifiedName ( QualifiedName(..) ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Schema.Spec (Spec (Spec)) +import qualified Rel8.Internal.Schema.Spec +import Rel8.Internal.Schema.Table ( TableSchema(..) ) +import Rel8.Internal.Statement.Run (run1) +import Rel8.Internal.Statement.Select (select) +import Rel8.Internal.Table (Columns, toColumns) +import Rel8.Internal.Table.List ( ListTable ) +import Rel8.Internal.Table.Name (namesFromLabelsWith) +import Rel8.Internal.Table.Rel8able () +import Rel8.Internal.Table.Serialize (ToExprs, lit) +import Rel8.Internal.Type ( DBType(..) ) +import Rel8.Internal.Type.Eq ( DBEq ) +import Rel8.Internal.Type.Information (parseTypeInformation) +import qualified Rel8.Internal.Type.Information +import Rel8.Internal.Type.Name ( TypeName(..) ) + +-- semialign +import Data.Semialign (align) + +-- these +import Data.These + + +data Relkind + = OrdinaryTable + | Index + | Sequence + | ToastTable + | View + | MaterializedView + | CompositeType + | ForeignTable + | PartitionedTable + | PartitionedIndex + deriving stock (Show) + deriving anyclass (DBEq) + +instance DBType Relkind where + typeInformation = parseTypeInformation parser printer typeInformation + where + parser = \case + "r" -> pure OrdinaryTable + "i" -> pure Index + "S" -> pure Sequence + "t" -> pure ToastTable + "v" -> pure View + "m" -> pure MaterializedView + "c" -> pure CompositeType + "f" -> pure ForeignTable + "p" -> pure PartitionedTable + "I" -> pure PartitionedIndex + (x :: Text) -> Left $ "Unknown relkind: " ++ show x + + printer = \case + OrdinaryTable -> "r" + Index -> "i" + Sequence -> "S" + ToastTable -> "t" + View -> "v" + MaterializedView -> "m" + CompositeType -> "c" + ForeignTable -> "f" + PartitionedTable -> "p" + PartitionedIndex -> "I" + +newtype Oid = Oid Int64 + deriving newtype (DBType, DBEq, Show) + +data PGClass f = PGClass + { oid :: Column f Oid + , relname :: Column f Text + , relkind :: Column f Relkind + , relnamespace :: Column f Oid + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (PGClass Result) + +pgclass :: TableSchema (PGClass Name) +pgclass = TableSchema + { name = QualifiedName "pg_class" (Just "pg_catalog") + , columns = namesFromLabelsWith NonEmpty.last + } + +data PGAttribute f = PGAttribute + { attrelid :: Column f Oid + , attname :: Column f Text + , atttypid :: Column f Oid + , attnum :: Column f Int64 + , atttypmod :: Column f Int64 + , attnotnull :: Column f Bool + , attndims :: Column f Int16 + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (PGAttribute Result) + +pgattribute :: TableSchema (PGAttribute Name) +pgattribute = TableSchema + { name = QualifiedName "pg_attribute" (Just "pg_catalog") + , columns = namesFromLabelsWith NonEmpty.last + } + +data PGType f = PGType + { oid :: Column f Oid + , typname :: Column f Text + , typnamespace :: Column f Oid + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (PGType Result) + +pgtype :: TableSchema (PGType Name) +pgtype = TableSchema + { name = QualifiedName "pg_type" (Just "pg_catalog") + , columns = namesFromLabelsWith NonEmpty.last + } + +data PGNamespace f = PGNamespace + { oid :: Column f Oid + , nspname :: Column f Text + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (PGNamespace Result) + +pgnamespace :: TableSchema (PGNamespace Name) +pgnamespace = TableSchema + { name = QualifiedName "pg_namespace" (Just "pg_catalog") + , columns = namesFromLabelsWith NonEmpty.last + } + +data PGCast f = PGCast + { oid :: Column f Oid + , castsource :: Column f Oid + , casttarget :: Column f Oid + , castfunc :: Column f Oid + , castcontext :: Column f Text -- Char + , castmethod :: Column f Char + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (PGCast Result) + +pgcast :: TableSchema (PGCast Name) +pgcast = TableSchema + { name = QualifiedName "pg_cast" (Just "pg_catalog") + , columns = namesFromLabelsWith NonEmpty.last + } + +data PGTable f = PGTable + { name :: Column f Text + , columns :: HList f (Attribute f) + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (PGTable Result) + +data Attribute f = Attribute + { attribute :: PGAttribute f + , typ :: PGType f + , namespace :: PGNamespace f + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (Attribute Result) + +data Cast f = Cast + { source :: PGType f + , target :: PGType f + , context :: Column f Text -- Char + } + deriving stock (Generic) + deriving anyclass (Rel8able) + +deriving stock instance Show (Cast Result) + +fetchTables :: Query (ListTable Expr (PGTable Expr)) +fetchTables = many do + PGClass{ oid = tableOid, relname } <- orderBy (relname >$< asc) do + each pgclass + >>= filter ((lit OrdinaryTable ==.) . relkind) + + columns <- many do + attribute@PGAttribute{ atttypid } <- + each pgattribute + >>= filter ((tableOid ==.) . attrelid) + >>= filter ((>. 0) . attnum) + + typ <- + each pgtype + >>= filter (\PGType{ oid = typoid } -> atttypid ==. typoid) + + namespace <- + each pgnamespace + >>= filter (\PGNamespace{ oid = nsoid } -> nsoid ==. typ.typnamespace) + + + + return Attribute{ attribute, typ, namespace } + + return PGTable + { name = relname + , .. + } + +fetchCasts :: Query (ListTable Expr (Cast Expr)) +fetchCasts = many do + PGCast {castsource, casttarget, castcontext} <- each pgcast + src <- each pgtype >>= filter (\PGType { oid = typoid } -> typoid ==. castsource) + tgt <- each pgtype >>= filter (\PGType { oid = typoid } -> typoid ==. casttarget) + return Cast { source = src, target = tgt, context = castcontext } + + +data CheckEnv = CheckEnv + { schemaMap :: M.Map String [Attribute Result] -- map of schemas to attributes + , casts :: [(String, String)] -- list of implicit casts + } deriving (Show) + + +nullableToBool :: Nullity a -> Bool +nullableToBool Null = True +nullableToBool NotNull = False + + +attrsToMap :: [Attribute Result] -> M.Map String (Attribute Result) +attrsToMap = M.fromList . map (\attr -> (T.unpack attr.attribute.attname, attr)) + + +data TypeInfo = TypeInfo + { label :: [String] + , isNull :: Bool + , typeName :: TypeName + } +instance Show TypeInfo where + show = showTypeInfo + + +-- @'schemaToTypeMap'@ takes a schema and returns a map of database column names +-- to the type information associated with the column. It is possible (though +-- undesirable) to write a schema which has multiple columns with the same name, +-- so a list of results are returned for each key. +schemaToTypeMap :: forall k. Rel8able k => k Name -> M.Map String (NonEmpty.NonEmpty TypeInfo) +schemaToTypeMap cols = go . uncurry zip . getConst $ + htabulateA @(Columns (k Name)) $ \field -> + case (hfield hspecs field, hfield (toColumns cols) field) of + (Spec {..}, Name name) -> Const ([name], [ + TypeInfo { label = labels + , isNull = nullableToBool nullity + , typeName = info.typeName}]) + where + go :: [(String, TypeInfo)] -> M.Map String (NonEmpty.NonEmpty TypeInfo) + go = M.fromListWith (<>) . map (\(name, typeInfo) -> (name, NonEmpty.singleton typeInfo)) + +-- A checked version of @schemaToTypeMap@, which returns a list of columns with +-- duplicate names if any such columns are present. Otherwise it returns the +-- type map with no duplicates. +checkedSchemaToTypeMap :: Rel8able k + => k Name + -> Either (M.Map String (NonEmpty.NonEmpty TypeInfo)) (M.Map String TypeInfo) +checkedSchemaToTypeMap cols = + let typeMap = schemaToTypeMap cols + duplicates = M.filter (\col -> length col > 1) typeMap + in if length duplicates > 0 + then Left duplicates + else Right (typeMap & M.mapMaybe \case + a :| [] -> Just a + _ -> Nothing) + + +showCreateTable_helper :: String -> M.Map String TypeInfo -> String +showCreateTable_helper name typeMap = "CREATE TABLE " <> show name <> " (" + ++ L.intercalate "," (fmap go $ M.assocs typeMap) + ++ "\n);" + where + go :: (String, TypeInfo) -> String + go (name', typeInfo) = "\n " ++ show name' ++ " " ++ showTypeInfo typeInfo + + +-- |@'showCreateTable'@ shows an example CREATE TABLE statement for the table. +-- This does not show relationships like primary or foreign keys, but can still +-- be useful to see what types @rel8@ will expect of the underlying database. +-- +-- In the event that multiple columns have the same name, this will fail silently. To +-- handle that case, see 'checkedShowCreateTable' +showCreateTable :: Rel8able k => TableSchema (k Name) -> String +showCreateTable schema = showCreateTable_helper schema.name.name $ fmap NonEmpty.head $ schemaToTypeMap schema.columns + +-- |@'checkedShowCreateTable'@ shows an example CREATE TABLE statement for the +-- table. This does not show relationships like primary or foreign keys, but can +-- still be useful to see what types rel8 will expect of the underlying database. +-- +-- In the event that multiple columns have the same name, this will return a map of +-- names to the labels identifying the column. +checkedShowCreateTable :: Rel8able k => TableSchema (k Name) -> Either (M.Map String (NonEmpty [String])) String +checkedShowCreateTable schema = case checkedSchemaToTypeMap schema.columns of + Left e -> Left $ (fmap . fmap) (\typ -> typ.label) e + Right a -> Right $ showCreateTable_helper schema.name.name a + +-- implicit casts are ok as long as they're bidirectional +checkTypeEquality :: CheckEnv -> TypeInfo -> TypeInfo -> Maybe ColumnError +checkTypeEquality env db hs + | Prelude.and [sameDims, sameMods, toName db == toName hs || castExists] + = Nothing + | otherwise + = Just BidirectionalCastDoesNotExist + where + castExists = Prelude.and + [ (toName db, toName hs) `elem` env.casts + , (toName hs, toName db) `elem` env.casts + ] + + sameMods, sameDims :: Bool + sameMods = db.typeName.modifiers == hs.typeName.modifiers + sameDims = db.typeName.arrayDepth == hs.typeName.arrayDepth + + toName :: TypeInfo -> String + toName typeInfo = case typeInfo.typeName.name of + QualifiedName name _ -> L.dropWhile (== '_') name + +-- check types for a single table +compareTypes + :: CheckEnv + -> M.Map String (Attribute Result) + -> M.Map String TypeInfo + -> [ColumnInfo] +compareTypes env attrMap typeMap = fmap (uncurry go) $ M.assocs (disjointUnion attrMap typeMap) + where + go :: String -> These (Attribute Result) TypeInfo -> ColumnInfo + go name (These a b) = ColumnInfo + { name = name + , dbType = Just $ fromAttribute a + , hsType = Just $ b + , error = checkTypeEquality env (fromAttribute a) b + } + go name (This a) = ColumnInfo + { name = name + , dbType = Just $ fromAttribute a + , hsType = Nothing + , error = + if a.attribute.attnotnull + then Just DbTypeIsNotNullButNotPresentInHsType + else Nothing + } + go name (That b) = ColumnInfo + { name = name + , dbType = Nothing + , hsType = Just $ b + , error = Just HsTypeIsPresentButNotPresentInDbType + } + + fromAttribute :: Attribute Result -> TypeInfo + fromAttribute attr = TypeInfo + { label = [T.unpack attr.attribute.attname] + , isNull = not attr.attribute.attnotnull + , typeName = TypeName + { name = QualifiedName + (T.unpack attr.typ.typname) + (Just $ T.unpack attr.namespace.nspname) + , modifiers = toModifier + (T.dropWhile (== '_') attr.typ.typname) + attr.attribute.atttypmod + , arrayDepth = fromIntegral attr.attribute.attndims + } + } + + toModifier :: Text -> Int64 -> [String] + toModifier "bpchar" (-1) = [] + toModifier "bpchar" n = [show (n - 4)] + toModifier "numeric" (-1) = [] + toModifier "numeric" n = [show $ (n - 4) `shiftR` 16, show $ (n - 4) .&. 65535] + toModifier _ _ = [] + + disjointUnion :: Ord k => M.Map k a -> M.Map k b -> M.Map k (These a b) + disjointUnion = align + + +-- |@pShowTable@ i's a helper f'unction which takes a grid of text and prints' it' +-- as a table, with padding so that cells are lined in columns, and a bordered +-- header for the first row +pShowTable :: [[Text]] -> Text +pShowTable xs + = T.intercalate "\n" + $ addHeaderBorder + $ fmap (T.intercalate " | ") + $ L.transpose + $ zip lengths xs' <&> \(n, column) -> column <&> \cell -> T.justifyLeft n ' ' cell + where + addHeaderBorder :: [Text] -> [Text] + addHeaderBorder [] = [] + addHeaderBorder (a : as) = a : T.replicate (T.length a) "-" : as + + xs' :: [[Text]] + xs' = L.transpose xs + + lengths :: [Int] + lengths = fmap (maximum . fmap T.length) $ xs' + + +pShowErrors :: [TableInfo] -> Text +pShowErrors = T.intercalate "\n\n" . fmap go + where + go :: TableInfo -> Text + go (TableInfo {tableExists, name, columns}) = "Table: " <> T.pack name + <> if not tableExists then " does not exist\n" else "\n" + <> pShowTable (["Column Name", "Implied DB type", "Current DB type", "Error"] : (columns <&> \column -> + [ T.pack $ column.name + , T.pack $ maybe "" showTypeInfo column.hsType + , T.pack $ maybe "" showTypeInfo column.dbType + , T.pack $ maybe "" show column.error + ])) + go (DuplicateNames {name, duplicates}) = mconcat + [ "Table " + , T.pack (show name) + , " has multiple columns with the same name. This is an error with the Haskell code generating an impossible schema, rather than an error in your current setup of the database itself. Using 'namesFromLabels' can ensure each column has unique names, which is the easiest way to prevent this, but may require changing names in your database to match the new generated names." + , pShowTable (["DB name", "Haskell label"] : (M.assocs duplicates <&> \(name', typs) -> + [ T.pack name' + , T.intercalate " " $ fmap (\typ -> T.intercalate "/" $ fmap T.pack typ.label) $ NonEmpty.toList typs + ])) + ] + + +data TableInfo + = TableInfo + { tableExists :: Bool + , name :: String + , columns :: [ColumnInfo] + } + | DuplicateNames + { name :: String + , duplicates :: M.Map String (NonEmpty.NonEmpty TypeInfo) + } + deriving (Show) + +data ColumnInfo = ColumnInfo + { name :: String + , hsType :: Maybe TypeInfo + , dbType :: Maybe TypeInfo + , error :: Maybe ColumnError + } deriving (Show) + +data ColumnError + = DbTypeIsNotNullButNotPresentInHsType + | HsTypeIsPresentButNotPresentInDbType + | BidirectionalCastDoesNotExist + deriving (Show) + + +showTypeInfo :: TypeInfo -> String +showTypeInfo typeInfo = concat + [ name + , if Prelude.null modifiers then "" else "(" <> L.intercalate "," modifiers <> ")" + , concat (replicate (fromIntegral typeInfo.typeName.arrayDepth) "[]") + , if typeInfo.isNull then "" else " NOT NULL" + ] + where + name = case typeInfo.typeName.name of + QualifiedName a Nothing -> show (dropWhile (== '_') a) + QualifiedName a (Just b) -> show b <> "." <> show (dropWhile (== '_') a) + + modifiers :: [String] + modifiers = typeInfo.typeName.modifiers + + +verifySchema :: Rel8able k => CheckEnv -> TableSchema (k Name) -> TableInfo +verifySchema env schema = case checkedSchemaToTypeMap schema.columns of + Left dups -> DuplicateNames schema.name.name dups + Right typeMap -> go typeMap maybeTable + where + maybeTable = M.lookup schema.name.name env.schemaMap + go typeMap Nothing = TableInfo + { tableExists = False + , name = schema.name.name + , columns = compareTypes env mempty typeMap + } + go typeMap (Just attrs) = TableInfo + { tableExists = True + , name = schema.name.name + , columns = compareTypes env (attrsToMap attrs) typeMap + } + + +fetchCheckEnv :: HS.Statement () CheckEnv +fetchCheckEnv = fetchSchema <&> \(tbls, casts) -> + let tblMap = foldMap (\PGTable {..} -> M.singleton (T.unpack name) columns) tbls + castMap = map (\Cast {..} -> (T.unpack source.typname, T.unpack target.typname)) $ L.filter (\Cast {context} -> context == "i") casts + in CheckEnv tblMap castMap + where + fetchSchema :: HS.Statement () ([PGTable Result], [Cast Result]) + fetchSchema = run1 $ select $ liftA2 (,) fetchTables fetchCasts + + +-- |@'SomeTableSchema'@ is used to allow the collection of a variety of different +-- @TableSchema@s under a single type, like: +-- +-- @ +-- userTable :: TableSchema (User Name) +-- orderTable :: TableSchema (Order Name) +-- +-- tables :: [SomeTableSchema] +-- tables = [SomeTableSchema userTable, SomeTable orderTable] +-- @ +-- +-- This is used by @'schemaErrors'@ to conveniently group every table an +-- application relies on for typechecking the postgresql schemas +-- together in a single batch. +data SomeTableSchema where + -- The ToExpr constraint isn't used here, but can be used to read from the + -- SomeTableSchema, which can be useful to combine the type checking with more + -- thorough value-level checking of the validity of existing rows in the + -- table. + SomeTableSchema + :: (ToExprs (k Expr) (GFromExprs k), Rel8able k) + => TableSchema (k Name) -> SomeTableSchema + +-- |@'getSchemaErrors'@ checks whether the provided schemas have the correct PostgreSQL +-- column names and types to allow reading and writing from their equivalent Haskell +-- types, returning a list of errors if that is not the case. The function does not +-- crash on encountering a bug, instead leaving it to the caller to decide how +-- to respond. A schema is valid if: +-- +-- 1. for every existing field, the types match +-- 2. all non-nullable columns are present in the hs type +-- 3. no nonexistent columns are present in the hs type +-- 4. no two columns in the same schema share the same name +-- +-- It's still possible for a valid schema to allow invalid data, for instance, +-- if using an ADT, which can introduce restrictions on which values are allowed +-- for the column representing the tag, and introduce restrictions on which +-- columns are non-null depending on the value of the tag. However, if the +-- schema is valid rel8 shouldn't be able to write invalid data to the table. +-- +-- However, it is possible for migrations to cause valid data to become invalid +-- in ways not detectable by this function, if the migration code changes the +-- schema correctly but doesn't handle the value-level constraints correctly. So +-- it is a good idea to both read from the tables and check the schema for errors +-- in a transaction during the migration. The former will catch value-level +-- bugs, while the latter will help ensure the schema is set up correctly to +-- be able to insert new data. +-- +-- This function does nothing to check that the conflict target of an @Upsert@ +-- are valid for the schema, nor can it prevent invalid uses of @unsafeDefault@. +-- However, it should be enough to catch the most likely errors. +getSchemaErrors :: [SomeTableSchema] -> HS.Statement () (Maybe Text) +getSchemaErrors someTables = fmap collectErrors fetchCheckEnv + where + collectErrors :: CheckEnv -> Maybe Text + collectErrors env + = fmap pShowErrors + . filterErrors + . fmap \case + SomeTableSchema t -> verifySchema env t + $ someTables + + -- removes each column which is valid for use by rel8, as well as each table + -- which contains only valid columns + filterErrors :: [TableInfo] -> Maybe [TableInfo] + filterErrors tables = case mapMaybe go tables of + [] -> Nothing + xs -> Just xs + where + go :: TableInfo -> Maybe TableInfo + go TableInfo {..} = case P.filter (\cd -> isJust cd.error) columns of + [] -> if tableExists then Nothing else Just $ TableInfo { name , tableExists , columns = [] } + xs -> Just $ TableInfo { name , tableExists , columns = xs } + go DuplicateNames {..} = Just (DuplicateNames {..}) + + diff --git a/src/Rel8/Table/Window.hs b/rel8-internal/src/Rel8/Internal/Table/Window.hs similarity index 81% rename from src/Rel8/Table/Window.hs rename to rel8-internal/src/Rel8/Internal/Table/Window.hs index 07474204..2029721d 100644 --- a/src/Rel8/Table/Window.hs +++ b/rel8-internal/src/Rel8/Internal/Table/Window.hs @@ -3,7 +3,7 @@ {-# language MonoLocalBinds #-} {-# language NamedFieldPuns #-} -module Rel8.Table.Window +module Rel8.Internal.Table.Window ( currentRow , lag, lagOn , lead, leadOn @@ -24,27 +24,27 @@ import qualified Opaleye.Window as Opaleye import Data.Profunctor (dimap, lmap) -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Null (null, nullify, snull) -import Rel8.Expr.Serialize (litExpr) -import Rel8.Expr.Window +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Null (null, nullify, snull) +import Rel8.Internal.Expr.Serialize (litExpr) +import Rel8.Internal.Expr.Window ( lagExpr, lagExprOn , leadExpr, leadExprOn , firstValueExpr , lastValueExpr , nthValueExpr, nthValueExprOn ) -import Rel8.Schema.HTable (htraverseP) -import Rel8.Schema.HTable.Identity (HIdentity (HIdentity)) -import Rel8.Schema.HTable.Label (hlabel) -import Rel8.Schema.HTable.Maybe (HMaybeTable (HMaybeTable)) -import Rel8.Schema.HTable.Nullify (hnullify) -import Rel8.Schema.Null (Nullity (NotNull, Null)) -import Rel8.Schema.Spec (Spec (..)) -import Rel8.Table (Table, fromColumns, toColumns) -import Rel8.Table.Maybe (MaybeTable) -import Rel8.Type.Tag (MaybeTag (IsJust)) -import Rel8.Window (Window (Window)) +import Rel8.Internal.Schema.HTable (htraverseP) +import Rel8.Internal.Schema.HTable.Identity (HIdentity (HIdentity)) +import Rel8.Internal.Schema.HTable.Label (hlabel) +import Rel8.Internal.Schema.HTable.Maybe (HMaybeTable (HMaybeTable)) +import Rel8.Internal.Schema.HTable.Nullify (hnullify) +import Rel8.Internal.Schema.Null (Nullity (NotNull, Null)) +import Rel8.Internal.Schema.Spec (Spec (..)) +import Rel8.Internal.Table (Table, fromColumns, toColumns) +import Rel8.Internal.Table.Maybe (MaybeTable) +import Rel8.Internal.Type.Tag (MaybeTag (IsJust)) +import Rel8.Internal.Window (Window (Window)) -- | Return every column of the current row of a window query. diff --git a/src/Rel8/Type.hs b/rel8-internal/src/Rel8/Internal/Type.hs similarity index 95% rename from src/Rel8/Type.hs rename to rel8-internal/src/Rel8/Internal/Type.hs index 0e934322..bdef5fcf 100644 --- a/src/Rel8/Type.hs +++ b/rel8-internal/src/Rel8/Internal/Type.hs @@ -10,7 +10,7 @@ {-# language TypeApplications #-} {-# language UndecidableInstances #-} -module Rel8.Type +module Rel8.Internal.Type ( DBType (typeInformation) ) where @@ -58,18 +58,18 @@ import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye import qualified Opaleye.Internal.HaskellDB.Sql.Default as Opaleye ( quote ) -- rel8 -import Rel8.Schema.Null ( NotNull, Sql, nullable ) -import Rel8.Type.Array ( listTypeInformation, nonEmptyTypeInformation ) -import Rel8.Type.Decimal (PowerOf10, resolution) -import Rel8.Type.Decoder (Decoder (..)) -import Rel8.Type.Encoder (Encoder (..)) -import Rel8.Type.Information ( TypeInformation(..), mapTypeInformation, parseTypeInformation ) -import Rel8.Type.Name (TypeName (..)) -import Rel8.Type.Parser (parse) -import qualified Rel8.Type.Builder.ByteString as Builder -import qualified Rel8.Type.Parser.ByteString as Parser -import qualified Rel8.Type.Builder.Time as Builder -import qualified Rel8.Type.Parser.Time as Parser +import Rel8.Internal.Schema.Null ( NotNull, Sql, nullable ) +import Rel8.Internal.Type.Array ( listTypeInformation, nonEmptyTypeInformation ) +import Rel8.Internal.Type.Decimal (PowerOf10, resolution) +import Rel8.Internal.Type.Decoder (Decoder (..)) +import Rel8.Internal.Type.Encoder (Encoder (..)) +import Rel8.Internal.Type.Information ( TypeInformation(..), mapTypeInformation, parseTypeInformation ) +import Rel8.Internal.Type.Name (TypeName (..)) +import Rel8.Internal.Type.Parser (parse) +import qualified Rel8.Internal.Type.Builder.ByteString as Builder +import qualified Rel8.Internal.Type.Parser.ByteString as Parser +import qualified Rel8.Internal.Type.Builder.Time as Builder +import qualified Rel8.Internal.Type.Parser.Time as Parser -- scientific import Data.ByteString.Builder.Scientific (scientificBuilder) diff --git a/src/Rel8/Type/Array.hs b/rel8-internal/src/Rel8/Internal/Type/Array.hs similarity index 94% rename from src/Rel8/Type/Array.hs rename to rel8-internal/src/Rel8/Internal/Type/Array.hs index a9f55865..9edc0c99 100644 --- a/src/Rel8/Type/Array.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Array.hs @@ -6,7 +6,7 @@ {-# language TypeApplications #-} {-# language ViewPatterns #-} -module Rel8.Type.Array +module Rel8.Internal.Type.Array ( array, quoteArrayElement, extractArrayElement , arrayTypeName , listTypeInformation @@ -44,14 +44,14 @@ import qualified Hasql.Encoders as Encoders import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Schema.Null (Unnullify, Nullity (Null, NotNull)) -import Rel8.Type.Builder.Fold (interfoldMap) -import Rel8.Type.Decoder (Decoder (..), Parser) -import Rel8.Type.Encoder (Encoder (..)) -import Rel8.Type.Information (TypeInformation(..), parseTypeInformation) -import Rel8.Type.Name (TypeName (..), showTypeName) -import Rel8.Type.Nullable (NullableOrNot (..)) -import Rel8.Type.Parser (parse) +import Rel8.Internal.Schema.Null (Unnullify, Nullity (Null, NotNull)) +import Rel8.Internal.Type.Builder.Fold (interfoldMap) +import Rel8.Internal.Type.Decoder (Decoder (..), Parser) +import Rel8.Internal.Type.Encoder (Encoder (..)) +import Rel8.Internal.Type.Information (TypeInformation(..), parseTypeInformation) +import Rel8.Internal.Type.Name (TypeName (..), showTypeName) +import Rel8.Internal.Type.Nullable (NullableOrNot (..)) +import Rel8.Internal.Type.Parser (parse) -- text import qualified Data.Text as Text diff --git a/src/Rel8/Type/Builder/ByteString.hs b/rel8-internal/src/Rel8/Internal/Type/Builder/ByteString.hs similarity index 86% rename from src/Rel8/Type/Builder/ByteString.hs rename to rel8-internal/src/Rel8/Internal/Type/Builder/ByteString.hs index e149755a..e44ad308 100644 --- a/src/Rel8/Type/Builder/ByteString.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Builder/ByteString.hs @@ -1,6 +1,6 @@ {-# language OverloadedStrings #-} -module Rel8.Type.Builder.ByteString ( +module Rel8.Internal.Type.Builder.ByteString ( bytestring, ) where diff --git a/src/Rel8/Type/Builder/Fold.hs b/rel8-internal/src/Rel8/Internal/Type/Builder/Fold.hs similarity index 87% rename from src/Rel8/Type/Builder/Fold.hs rename to rel8-internal/src/Rel8/Internal/Type/Builder/Fold.hs index 49a1deaa..edc8353a 100644 --- a/src/Rel8/Type/Builder/Fold.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Builder/Fold.hs @@ -1,6 +1,6 @@ {-# language LambdaCase #-} -module Rel8.Type.Builder.Fold ( +module Rel8.Internal.Type.Builder.Fold ( interfoldMap ) where diff --git a/src/Rel8/Type/Builder/Time.hs b/rel8-internal/src/Rel8/Internal/Type/Builder/Time.hs similarity index 98% rename from src/Rel8/Type/Builder/Time.hs rename to rel8-internal/src/Rel8/Internal/Type/Builder/Time.hs index eb26d413..856494cf 100644 --- a/src/Rel8/Type/Builder/Time.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Builder/Time.hs @@ -13,7 +13,7 @@ {-# options_ghc -Wno-unused-top-binds #-} -- GHC considers the YMD pattern unused but we use its selectors -module Rel8.Type.Builder.Time ( +module Rel8.Internal.Type.Builder.Time ( calendarDiffTime, day, localTime, diff --git a/src/Rel8/Type/Composite.hs b/rel8-internal/src/Rel8/Internal/Type/Composite.hs similarity index 84% rename from src/Rel8/Type/Composite.hs rename to rel8-internal/src/Rel8/Internal/Type/Composite.hs index f4a2e4fa..d819302f 100644 --- a/src/Rel8/Type/Composite.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Composite.hs @@ -14,7 +14,7 @@ {-# language UndecidableSuperClasses #-} {-# language ViewPatterns #-} -module Rel8.Type.Composite +module Rel8.Internal.Type.Composite ( Composite( Composite ) , DBComposite( compositeFields, compositeTypeName ) , compose, decompose @@ -50,31 +50,31 @@ import qualified Hasql.Encoders as Encoders import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Opaleye ( castExpr, fromPrimExpr, toPrimExpr ) -import Rel8.Schema.HTable ( HTable, hfield, hspecs, htabulate, htabulateA ) -import Rel8.Schema.Name ( Name( Name ) ) -import Rel8.Schema.Null ( Nullity( Null, NotNull ) ) -import Rel8.Schema.QualifiedName (QualifiedName) -import Rel8.Schema.Result ( Result ) -import Rel8.Schema.Spec ( Spec( Spec, nullity, info ) ) -import Rel8.Table ( fromColumns, toColumns, fromResult, toResult ) -import Rel8.Table.Eq ( EqTable ) -import Rel8.Table.HKD ( HKD, HKDable ) -import Rel8.Table.Ord ( OrdTable ) -import Rel8.Table.Rel8able () -import Rel8.Table.Serialize ( litHTable ) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Builder.Fold (interfoldMap) -import Rel8.Type.Decoder (Decoder (Decoder), Parser) -import qualified Rel8.Type.Decoder as Decoder -import Rel8.Type.Encoder (Encoder (Encoder)) -import qualified Rel8.Type.Encoder as Encoder -import Rel8.Type.Eq ( DBEq ) -import Rel8.Type.Information ( TypeInformation(..) ) -import Rel8.Type.Name (TypeName (..)) -import Rel8.Type.Ord ( DBOrd, DBMax, DBMin ) -import Rel8.Type.Parser (parse) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Opaleye ( castExpr, fromPrimExpr, toPrimExpr ) +import Rel8.Internal.Schema.HTable ( HTable, hfield, hspecs, htabulate, htabulateA ) +import Rel8.Internal.Schema.Name ( Name( Name ) ) +import Rel8.Internal.Schema.Null ( Nullity( Null, NotNull ) ) +import Rel8.Internal.Schema.QualifiedName (QualifiedName) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Schema.Spec ( Spec( Spec, nullity, info ) ) +import Rel8.Internal.Table ( fromColumns, toColumns, fromResult, toResult ) +import Rel8.Internal.Table.Eq ( EqTable ) +import Rel8.Internal.Table.HKD ( HKD, HKDable ) +import Rel8.Internal.Table.Ord ( OrdTable ) +import Rel8.Internal.Table.Rel8able () +import Rel8.Internal.Table.Serialize ( litHTable ) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Builder.Fold (interfoldMap) +import Rel8.Internal.Type.Decoder (Decoder (Decoder), Parser) +import qualified Rel8.Internal.Type.Decoder as Decoder +import Rel8.Internal.Type.Encoder (Encoder (Encoder)) +import qualified Rel8.Internal.Type.Encoder as Encoder +import Rel8.Internal.Type.Eq ( DBEq ) +import Rel8.Internal.Type.Information ( TypeInformation(..) ) +import Rel8.Internal.Type.Name (TypeName (..)) +import Rel8.Internal.Type.Ord ( DBOrd, DBMax, DBMin ) +import Rel8.Internal.Type.Parser (parse) -- semigroupoids import Data.Functor.Apply ( WrappedApplicative(..) ) diff --git a/src/Rel8/Type/Decimal.hs b/rel8-internal/src/Rel8/Internal/Type/Decimal.hs similarity index 98% rename from src/Rel8/Type/Decimal.hs rename to rel8-internal/src/Rel8/Internal/Type/Decimal.hs index 6fcd323f..24c4989b 100644 --- a/src/Rel8/Type/Decimal.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Decimal.hs @@ -13,7 +13,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Type.Decimal +module Rel8.Internal.Type.Decimal ( PowerOf10 , resolution ) diff --git a/src/Rel8/Type/Decoder.hs b/rel8-internal/src/Rel8/Internal/Type/Decoder.hs similarity index 97% rename from src/Rel8/Type/Decoder.hs rename to rel8-internal/src/Rel8/Internal/Type/Decoder.hs index c04ac7f1..4fab0da8 100644 --- a/src/Rel8/Type/Decoder.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Decoder.hs @@ -4,7 +4,7 @@ {-# language StandaloneKindSignatures #-} {-# language DuplicateRecordFields #-} -module Rel8.Type.Decoder ( +module Rel8.Internal.Type.Decoder ( Decoder (..), Parser, parseDecoder, diff --git a/src/Rel8/Type/Encoder.hs b/rel8-internal/src/Rel8/Internal/Type/Encoder.hs similarity index 96% rename from src/Rel8/Type/Encoder.hs rename to rel8-internal/src/Rel8/Internal/Type/Encoder.hs index 3d0dbbb0..4af9e93a 100644 --- a/src/Rel8/Type/Encoder.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Encoder.hs @@ -5,7 +5,7 @@ {-# language StrictData #-} {-# language DuplicateRecordFields #-} -module Rel8.Type.Encoder ( +module Rel8.Internal.Type.Encoder ( Encoder (..), ) where diff --git a/src/Rel8/Type/Enum.hs b/rel8-internal/src/Rel8/Internal/Type/Enum.hs similarity index 91% rename from src/Rel8/Type/Enum.hs rename to rel8-internal/src/Rel8/Internal/Type/Enum.hs index c9c0e692..0eee176a 100644 --- a/src/Rel8/Type/Enum.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Enum.hs @@ -13,7 +13,7 @@ {-# language TypeOperators #-} {-# language UndecidableInstances #-} -module Rel8.Type.Enum +module Rel8.Internal.Type.Enum ( Enum( Enum ) , DBEnum( enumValue, enumTypeName, enumerate ) , Enumable @@ -41,14 +41,14 @@ import qualified Hasql.Encoders as Encoders import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Schema.QualifiedName (QualifiedName) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Decoder (Decoder (..)) -import Rel8.Type.Encoder (Encoder (..)) -import Rel8.Type.Eq ( DBEq ) -import Rel8.Type.Information ( TypeInformation(..) ) -import Rel8.Type.Name (TypeName (..)) -import Rel8.Type.Ord ( DBOrd, DBMax, DBMin ) +import Rel8.Internal.Schema.QualifiedName (QualifiedName) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Decoder (Decoder (..)) +import Rel8.Internal.Type.Encoder (Encoder (..)) +import Rel8.Internal.Type.Eq ( DBEq ) +import Rel8.Internal.Type.Information ( TypeInformation(..) ) +import Rel8.Internal.Type.Name (TypeName (..)) +import Rel8.Internal.Type.Ord ( DBOrd, DBMax, DBMin ) -- text import Data.Text (pack) diff --git a/src/Rel8/Type/Eq.hs b/rel8-internal/src/Rel8/Internal/Type/Eq.hs similarity index 92% rename from src/Rel8/Type/Eq.hs rename to rel8-internal/src/Rel8/Internal/Type/Eq.hs index 426f8c65..07a7f184 100644 --- a/src/Rel8/Type/Eq.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Eq.hs @@ -5,7 +5,7 @@ {-# language StandaloneKindSignatures #-} {-# language UndecidableInstances #-} -module Rel8.Type.Eq +module Rel8.Internal.Type.Eq ( DBEq ) where @@ -28,9 +28,9 @@ import qualified Data.ByteString.Lazy as Lazy ( ByteString ) import Data.CaseInsensitive ( CI ) -- rel8 -import Rel8.Schema.Null ( Sql ) -import Rel8.Type ( DBType ) -import Rel8.Type.Decimal (PowerOf10) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Type ( DBType ) +import Rel8.Internal.Type.Decimal (PowerOf10) -- scientific import Data.Scientific ( Scientific ) diff --git a/src/Rel8/Type/Information.hs b/rel8-internal/src/Rel8/Internal/Type/Information.hs similarity index 91% rename from src/Rel8/Type/Information.hs rename to rel8-internal/src/Rel8/Internal/Type/Information.hs index 3be42165..1ca89200 100644 --- a/src/Rel8/Type/Information.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Information.hs @@ -3,7 +3,7 @@ {-# language StandaloneKindSignatures #-} {-# language StrictData #-} -module Rel8.Type.Information ( +module Rel8.Internal.Type.Information ( TypeInformation(..), mapTypeInformation, parseTypeInformation, @@ -15,9 +15,9 @@ import Data.Kind (Type) import Prelude -- rel8 -import Rel8.Type.Decoder (Decoder, parseDecoder) -import Rel8.Type.Encoder (Encoder) -import Rel8.Type.Name (TypeName) +import Rel8.Internal.Type.Decoder (Decoder, parseDecoder) +import Rel8.Internal.Type.Encoder (Encoder) +import Rel8.Internal.Type.Name (TypeName) -- | @TypeInformation@ describes how to encode and decode a Haskell type to and diff --git a/src/Rel8/Type/JSONBEncoded.hs b/rel8-internal/src/Rel8/Internal/Type/JSONBEncoded.hs similarity index 87% rename from src/Rel8/Type/JSONBEncoded.hs rename to rel8-internal/src/Rel8/Internal/Type/JSONBEncoded.hs index bd0b6d3a..f01fe5cc 100644 --- a/src/Rel8/Type/JSONBEncoded.hs +++ b/rel8-internal/src/Rel8/Internal/Type/JSONBEncoded.hs @@ -2,7 +2,7 @@ {-# language OverloadedStrings #-} {-# language StandaloneKindSignatures #-} -module Rel8.Type.JSONBEncoded ( +module Rel8.Internal.Type.JSONBEncoded ( JSONBEncoded(..), ) where @@ -27,10 +27,10 @@ import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye import qualified Opaleye.Internal.HaskellDB.Sql.Default as Opaleye (quote) -- rel8 -import Rel8.Type ( DBType(..) ) -import Rel8.Type.Decoder (Decoder (..)) -import Rel8.Type.Encoder (Encoder (..)) -import Rel8.Type.Information ( TypeInformation(..) ) +import Rel8.Internal.Type ( DBType(..) ) +import Rel8.Internal.Type.Decoder (Decoder (..)) +import Rel8.Internal.Type.Encoder (Encoder (..)) +import Rel8.Internal.Type.Information ( TypeInformation(..) ) -- text import Data.Text ( pack ) diff --git a/src/Rel8/Type/JSONEncoded.hs b/rel8-internal/src/Rel8/Internal/Type/JSONEncoded.hs similarity index 88% rename from src/Rel8/Type/JSONEncoded.hs rename to rel8-internal/src/Rel8/Internal/Type/JSONEncoded.hs index 398e73ce..91297904 100644 --- a/src/Rel8/Type/JSONEncoded.hs +++ b/rel8-internal/src/Rel8/Internal/Type/JSONEncoded.hs @@ -3,7 +3,7 @@ {-# language OverloadedStrings #-} {-# language TypeApplications #-} -module Rel8.Type.JSONEncoded ( +module Rel8.Internal.Type.JSONEncoded ( JSONEncoded(..), ) where @@ -24,10 +24,10 @@ import qualified Hasql.Decoders as Decoders import qualified Hasql.Encoders as Encoders -- rel8 -import Rel8.Type ( DBType(..) ) -import Rel8.Type.Decoder (Decoder (..)) -import Rel8.Type.Encoder (Encoder (..)) -import Rel8.Type.Information ( TypeInformation(..) ) +import Rel8.Internal.Type ( DBType(..) ) +import Rel8.Internal.Type.Decoder (Decoder (..)) +import Rel8.Internal.Type.Encoder (Encoder (..)) +import Rel8.Internal.Type.Information ( TypeInformation(..) ) -- opaleye import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye diff --git a/src/Rel8/Type/Monoid.hs b/rel8-internal/src/Rel8/Internal/Type/Monoid.hs similarity index 79% rename from src/Rel8/Type/Monoid.hs rename to rel8-internal/src/Rel8/Internal/Type/Monoid.hs index 95bde50d..df9303a3 100644 --- a/src/Rel8/Type/Monoid.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Monoid.hs @@ -7,7 +7,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Type.Monoid +module Rel8.Internal.Type.Monoid ( DBMonoid( memptyExpr ) ) where @@ -24,14 +24,14 @@ import qualified Data.ByteString.Lazy as Lazy ( ByteString ) import Data.CaseInsensitive ( CI ) -- rel8 -import Rel8.Data.Range (Multirange (Multirange)) -import {-# SOURCE #-} Rel8.Expr ( Expr ) -import Rel8.Expr.Array ( sempty ) -import Rel8.Expr.Serialize ( litExpr ) -import Rel8.Schema.Null ( Sql ) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Range (DBRange) -import Rel8.Type.Semigroup ( DBSemigroup ) +import Rel8.Internal.Data.Range (Multirange (Multirange)) +import {-# SOURCE #-} Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Array ( sempty ) +import Rel8.Internal.Expr.Serialize ( litExpr ) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Range (DBRange) +import Rel8.Internal.Type.Semigroup ( DBSemigroup ) -- text import Data.Text ( Text ) diff --git a/src/Rel8/Type/Name.hs b/rel8-internal/src/Rel8/Internal/Type/Name.hs similarity index 93% rename from src/Rel8/Type/Name.hs rename to rel8-internal/src/Rel8/Internal/Type/Name.hs index 9680a964..0c86ebd5 100644 --- a/src/Rel8/Type/Name.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Name.hs @@ -1,7 +1,7 @@ {-# language RecordWildCards #-} {-# language StrictData #-} -module Rel8.Type.Name +module Rel8.Internal.Type.Name ( TypeName (..) , showTypeName ) @@ -16,7 +16,7 @@ import Prelude import Text.PrettyPrint (Doc, comma, hcat, parens, punctuate, text) -- rel8 -import Rel8.Schema.QualifiedName (QualifiedName, ppQualifiedName) +import Rel8.Internal.Schema.QualifiedName (QualifiedName, ppQualifiedName) -- | A PostgreSQL type consists of a 'QualifiedName' (name, schema), and diff --git a/src/Rel8/Type/Nullable.hs b/rel8-internal/src/Rel8/Internal/Type/Nullable.hs similarity index 90% rename from src/Rel8/Type/Nullable.hs rename to rel8-internal/src/Rel8/Internal/Type/Nullable.hs index 95d3439f..5f0fd9f8 100644 --- a/src/Rel8/Type/Nullable.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Nullable.hs @@ -1,7 +1,7 @@ {-# language GADTs #-} {-# language StandaloneKindSignatures #-} -module Rel8.Type.Nullable ( +module Rel8.Internal.Type.Nullable ( NullableOrNot (..), ) where diff --git a/src/Rel8/Type/Num.hs b/rel8-internal/src/Rel8/Internal/Type/Num.hs similarity index 91% rename from src/Rel8/Type/Num.hs rename to rel8-internal/src/Rel8/Internal/Type/Num.hs index a1b58532..108d40b2 100644 --- a/src/Rel8/Type/Num.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Num.hs @@ -6,7 +6,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Type.Num +module Rel8.Internal.Type.Num ( DBNum, DBIntegral, DBFractional, DBFloating ) where @@ -18,9 +18,9 @@ import Data.Kind ( Constraint, Type ) import Prelude -- rel8 -import Rel8.Type ( DBType ) -import Rel8.Type.Decimal (PowerOf10) -import Rel8.Type.Ord ( DBOrd ) +import Rel8.Internal.Type ( DBType ) +import Rel8.Internal.Type.Decimal (PowerOf10) +import Rel8.Internal.Type.Ord ( DBOrd ) -- scientific import Data.Scientific ( Scientific ) diff --git a/src/Rel8/Type/Ord.hs b/rel8-internal/src/Rel8/Internal/Type/Ord.hs similarity index 95% rename from src/Rel8/Type/Ord.hs rename to rel8-internal/src/Rel8/Internal/Type/Ord.hs index 5b67d8eb..3699ec0e 100644 --- a/src/Rel8/Type/Ord.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Ord.hs @@ -5,7 +5,7 @@ {-# language StandaloneKindSignatures #-} {-# language UndecidableInstances #-} -module Rel8.Type.Ord +module Rel8.Internal.Type.Ord ( DBOrd , DBMax, DBMin ) @@ -26,9 +26,9 @@ import qualified Data.ByteString.Lazy as Lazy ( ByteString ) import Data.CaseInsensitive ( CI ) -- rel8 -import Rel8.Schema.Null ( Sql ) -import Rel8.Type.Decimal (PowerOf10) -import Rel8.Type.Eq ( DBEq ) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Type.Decimal (PowerOf10) +import Rel8.Internal.Type.Eq ( DBEq ) -- scientific import Data.Scientific ( Scientific ) diff --git a/src/Rel8/Type/Parser.hs b/rel8-internal/src/Rel8/Internal/Type/Parser.hs similarity index 88% rename from src/Rel8/Type/Parser.hs rename to rel8-internal/src/Rel8/Internal/Type/Parser.hs index 8d11423e..56c6b92c 100644 --- a/src/Rel8/Type/Parser.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Parser.hs @@ -1,4 +1,4 @@ -module Rel8.Type.Parser +module Rel8.Internal.Type.Parser ( parse ) where diff --git a/src/Rel8/Type/Parser/ByteString.hs b/rel8-internal/src/Rel8/Internal/Type/Parser/ByteString.hs similarity index 96% rename from src/Rel8/Type/Parser/ByteString.hs rename to rel8-internal/src/Rel8/Internal/Type/Parser/ByteString.hs index b5f89ecd..18490b2a 100644 --- a/src/Rel8/Type/Parser/ByteString.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Parser/ByteString.hs @@ -1,7 +1,7 @@ {-# language OverloadedStrings #-} {-# language TypeApplications #-} -module Rel8.Type.Parser.ByteString +module Rel8.Internal.Type.Parser.ByteString ( bytestring ) where diff --git a/src/Rel8/Type/Parser/Time.hs b/rel8-internal/src/Rel8/Internal/Type/Parser/Time.hs similarity index 99% rename from src/Rel8/Type/Parser/Time.hs rename to rel8-internal/src/Rel8/Internal/Type/Parser/Time.hs index abc2cb67..f2ae9efb 100644 --- a/src/Rel8/Type/Parser/Time.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Parser/Time.hs @@ -1,7 +1,7 @@ {-# language OverloadedStrings #-} {-# language TypeApplications #-} -module Rel8.Type.Parser.Time +module Rel8.Internal.Type.Parser.Time ( calendarDiffTime , day , localTime diff --git a/src/Rel8/Type/Range.hs b/rel8-internal/src/Rel8/Internal/Type/Range.hs similarity index 95% rename from src/Rel8/Type/Range.hs rename to rel8-internal/src/Rel8/Internal/Type/Range.hs index 7dfaeb39..6a03f9d6 100644 --- a/src/Rel8/Type/Range.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Range.hs @@ -1,7 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE OverloadedStrings #-} -module Rel8.Type.Range ( +module Rel8.Internal.Type.Range ( DBRange ( rangeTypeName, rangeDecoder, rangeEncoder, multirangeTypeName, multirangeDecoder, multirangeEncoder @@ -19,8 +19,8 @@ import qualified Hasql.Encoders as Encoder import qualified PostgreSQL.Binary.Range as PostgreSQL -- rel8 -import Rel8.Schema.QualifiedName (QualifiedName) -import Rel8.Type.Ord (DBOrd) +import Rel8.Internal.Schema.QualifiedName (QualifiedName) +import Rel8.Internal.Type.Ord (DBOrd) -- scientific import Data.Scientific (Scientific) diff --git a/src/Rel8/Type/ReadShow.hs b/rel8-internal/src/Rel8/Internal/Type/ReadShow.hs similarity index 84% rename from src/Rel8/Type/ReadShow.hs rename to rel8-internal/src/Rel8/Internal/Type/ReadShow.hs index a7f9d083..daab51a9 100644 --- a/src/Rel8/Type/ReadShow.hs +++ b/rel8-internal/src/Rel8/Internal/Type/ReadShow.hs @@ -3,7 +3,7 @@ {-# language TypeApplications #-} {-# language ViewPatterns #-} -module Rel8.Type.ReadShow ( ReadShow(..) ) where +module Rel8.Internal.Type.ReadShow ( ReadShow(..) ) where -- base import Data.Kind ( Type ) @@ -13,8 +13,8 @@ import Prelude import Text.Read ( readMaybe ) -- rel8 -import Rel8.Type ( DBType( typeInformation ) ) -import Rel8.Type.Information ( parseTypeInformation ) +import Rel8.Internal.Type ( DBType( typeInformation ) ) +import Rel8.Internal.Type.Information ( parseTypeInformation ) -- text import qualified Data.Text as Text diff --git a/src/Rel8/Type/Semigroup.hs b/rel8-internal/src/Rel8/Internal/Type/Semigroup.hs similarity index 85% rename from src/Rel8/Type/Semigroup.hs rename to rel8-internal/src/Rel8/Internal/Type/Semigroup.hs index 93f595d2..c9d4c0ae 100644 --- a/src/Rel8/Type/Semigroup.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Semigroup.hs @@ -7,7 +7,7 @@ {-# language TypeFamilies #-} {-# language UndecidableInstances #-} -module Rel8.Type.Semigroup +module Rel8.Internal.Type.Semigroup ( DBSemigroup( (<>.)) ) where @@ -28,13 +28,13 @@ import Data.CaseInsensitive ( CI ) import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Data.Range (Multirange) -import {-# SOURCE #-} Rel8.Expr ( Expr ) -import Rel8.Expr.Array ( sappend, sappend1 ) -import Rel8.Expr.Opaleye ( zipPrimExprsWith ) -import Rel8.Schema.Null ( Sql ) -import Rel8.Type ( DBType ) -import Rel8.Type.Range (DBRange) +import Rel8.Internal.Data.Range (Multirange) +import {-# SOURCE #-} Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Array ( sappend, sappend1 ) +import Rel8.Internal.Expr.Opaleye ( zipPrimExprsWith ) +import Rel8.Internal.Schema.Null ( Sql ) +import Rel8.Internal.Type ( DBType ) +import Rel8.Internal.Type.Range (DBRange) -- text import Data.Text ( Text ) diff --git a/src/Rel8/Type/String.hs b/rel8-internal/src/Rel8/Internal/Type/String.hs similarity index 92% rename from src/Rel8/Type/String.hs rename to rel8-internal/src/Rel8/Internal/Type/String.hs index 302022a3..51fde2c1 100644 --- a/src/Rel8/Type/String.hs +++ b/rel8-internal/src/Rel8/Internal/Type/String.hs @@ -4,7 +4,7 @@ {-# language StandaloneKindSignatures #-} {-# language UndecidableInstances #-} -module Rel8.Type.String +module Rel8.Internal.Type.String ( DBString ) where @@ -21,7 +21,7 @@ import qualified Data.ByteString.Lazy as Lazy ( ByteString ) import Data.CaseInsensitive ( CI ) -- rel8 -import Rel8.Type ( DBType ) +import Rel8.Internal.Type ( DBType ) -- text import Data.Text ( Text ) diff --git a/src/Rel8/Type/Sum.hs b/rel8-internal/src/Rel8/Internal/Type/Sum.hs similarity index 88% rename from src/Rel8/Type/Sum.hs rename to rel8-internal/src/Rel8/Internal/Type/Sum.hs index 3daeb360..fc71fc6e 100644 --- a/src/Rel8/Type/Sum.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Sum.hs @@ -6,7 +6,7 @@ {-# language StandaloneKindSignatures #-} {-# language UndecidableInstances #-} -module Rel8.Type.Sum +module Rel8.Internal.Type.Sum ( DBSum ) where @@ -18,8 +18,8 @@ import Data.Kind ( Constraint, Type ) import Prelude -- rel8 -import Rel8.Type ( DBType ) -import Rel8.Type.Decimal (PowerOf10) +import Rel8.Internal.Type ( DBType ) +import Rel8.Internal.Type.Decimal (PowerOf10) -- scientific import Data.Scientific ( Scientific ) diff --git a/src/Rel8/Type/Tag.hs b/rel8-internal/src/Rel8/Internal/Type/Tag.hs similarity index 77% rename from src/Rel8/Type/Tag.hs rename to rel8-internal/src/Rel8/Internal/Type/Tag.hs index 032dacef..8092f4fa 100644 --- a/src/Rel8/Type/Tag.hs +++ b/rel8-internal/src/Rel8/Internal/Type/Tag.hs @@ -4,7 +4,7 @@ {-# language GeneralizedNewtypeDeriving #-} {-# language StandaloneKindSignatures #-} -module Rel8.Type.Tag +module Rel8.Internal.Type.Tag ( EitherTag( IsLeft, IsRight ), isLeft, isRight , MaybeTag( IsJust ) , Tag( Tag ) @@ -21,16 +21,16 @@ import Prelude import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Eq ( (==.) ) -import Rel8.Expr.Opaleye ( zipPrimExprsWith ) -import Rel8.Expr.Serialize ( litExpr ) -import Rel8.Type.Eq ( DBEq ) -import Rel8.Type ( DBType, typeInformation ) -import Rel8.Type.Information ( mapTypeInformation, parseTypeInformation ) -import Rel8.Type.Monoid ( DBMonoid, memptyExpr ) -import Rel8.Type.Ord ( DBOrd ) -import Rel8.Type.Semigroup ( DBSemigroup, (<>.) ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Eq ( (==.) ) +import Rel8.Internal.Expr.Opaleye ( zipPrimExprsWith ) +import Rel8.Internal.Expr.Serialize ( litExpr ) +import Rel8.Internal.Type.Eq ( DBEq ) +import Rel8.Internal.Type ( DBType, typeInformation ) +import Rel8.Internal.Type.Information ( mapTypeInformation, parseTypeInformation ) +import Rel8.Internal.Type.Monoid ( DBMonoid, memptyExpr ) +import Rel8.Internal.Type.Ord ( DBOrd ) +import Rel8.Internal.Type.Semigroup ( DBSemigroup, (<>.) ) -- text import Data.Text ( Text ) diff --git a/src/Rel8/Window.hs b/rel8-internal/src/Rel8/Internal/Window.hs similarity index 91% rename from src/Rel8/Window.hs rename to rel8-internal/src/Rel8/Internal/Window.hs index 143f7bd8..ab06281c 100644 --- a/src/Rel8/Window.hs +++ b/rel8-internal/src/Rel8/Internal/Window.hs @@ -5,7 +5,7 @@ {-# language StandaloneKindSignatures #-} {-# language TypeApplications #-} -module Rel8.Window +module Rel8.Internal.Window ( Window(..) , Partition , over @@ -31,11 +31,11 @@ import Data.Profunctor ( Profunctor ) import Data.Profunctor.Product ( ProductProfunctor, (****), purePP ) -- rel8 -import Rel8.Expr.Opaleye ( toColumn, toPrimExpr ) -import Rel8.Order( Order( Order ) ) -import Rel8.Schema.HTable ( hfield, htabulateA ) -import Rel8.Table ( Columns, toColumns ) -import Rel8.Table.Eq ( EqTable ) +import Rel8.Internal.Expr.Opaleye ( toColumn, toPrimExpr ) +import Rel8.Internal.Order( Order( Order ) ) +import Rel8.Internal.Schema.HTable ( hfield, htabulateA ) +import Rel8.Internal.Table ( Columns, toColumns ) +import Rel8.Internal.Table.Eq ( EqTable ) -- semigroupoids import Data.Functor.Apply ( Apply, WrappedApplicative(..) ) diff --git a/rel8.cabal b/rel8.cabal deleted file mode 100644 index ccbd39c4..00000000 --- a/rel8.cabal +++ /dev/null @@ -1,295 +0,0 @@ -cabal-version: 2.0 -name: rel8 -version: 1.7.0.0 -synopsis: Hey! Hey! Can u rel8? -license: BSD3 -license-file: LICENSE -author: Oliver Charles -maintainer: ollie@ocharles.org.uk -homepage: https://github.com/circuithub/rel8 -bug-reports: https://github.com/circuithub/rel8/issues -build-type: Simple -extra-doc-files: - README.md - Changelog.md - -source-repository head - type: git - location: https://github.com/circuithub/rel8 - -library - build-depends: - aeson - , attoparsec - , base >= 4.16 && < 4.23 - , base16 >= 1.0 - , base-compat >= 0.11 && < 0.15 - , bifunctors - , bytestring - , case-insensitive - , comonad - , containers - , contravariant - , hasql >= 1.8 && < 1.10 - , iproute ^>= 1.7 - , opaleye ^>= 0.10.2.1 - , postgresql-binary ^>= 0.14.2 - , pretty - , profunctors - , product-profunctors - , scientific - , semialign - , semigroupoids - , text - , these - , time - , transformers - , utf8-string - , uuid - , vector - - default-language: - Haskell2010 - ghc-options: - -Werror=missing-methods -Werror=incomplete-patterns -Werror=missing-fields - -Weverything -Wno-unsafe -Wno-safe -Wno-missing-safe-haskell-mode - -Wno-missing-import-lists -Wno-prepositive-qualified-module - -Wno-monomorphism-restriction - -Wno-missing-local-signatures - -Wno-missing-kind-signatures - -Wno-missing-role-annotations - -Wno-missing-deriving-strategies - -Wno-term-variable-capture - - hs-source-dirs: - src - exposed-modules: - Rel8 - Rel8.Array - Rel8.Decoder - Rel8.Encoder - Rel8.Expr.Num - Rel8.Expr.Text - Rel8.Expr.Time - Rel8.Range - Rel8.Table.Verify - Rel8.Tabulate - - other-modules: - Rel8.Aggregate - Rel8.Aggregate.Fold - Rel8.Aggregate.Function - Rel8.Aggregate.Range - - Rel8.Column - Rel8.Column.ADT - Rel8.Column.Either - Rel8.Column.Lift - Rel8.Column.List - Rel8.Column.Maybe - Rel8.Column.NonEmpty - Rel8.Column.Null - Rel8.Column.These - - Rel8.Data.Range - - Rel8.Expr - Rel8.Expr.Aggregate - Rel8.Expr.Array - Rel8.Expr.Bool - Rel8.Expr.Default - Rel8.Expr.Eq - Rel8.Expr.Function - Rel8.Expr.List - Rel8.Expr.NonEmpty - Rel8.Expr.Null - Rel8.Expr.Opaleye - Rel8.Expr.Ord - Rel8.Expr.Order - Rel8.Expr.Range - Rel8.Expr.Read - Rel8.Expr.Sequence - Rel8.Expr.Serialize - Rel8.Expr.Show - Rel8.Expr.Subscript - Rel8.Expr.Window - - Rel8.FCF - - Rel8.Kind.Algebra - Rel8.Kind.Context - - Rel8.Generic.Construction - Rel8.Generic.Construction.ADT - Rel8.Generic.Construction.Record - Rel8.Generic.Map - Rel8.Generic.Record - Rel8.Generic.Rel8able - Rel8.Generic.Table - Rel8.Generic.Table.ADT - Rel8.Generic.Table.Record - - Rel8.Order - - Rel8.Query - Rel8.Query.Aggregate - Rel8.Query.Distinct - Rel8.Query.Each - Rel8.Query.Either - Rel8.Query.Evaluate - Rel8.Query.Exists - Rel8.Query.Filter - Rel8.Query.Function - Rel8.Query.Indexed - Rel8.Query.Limit - Rel8.Query.List - Rel8.Query.Loop - Rel8.Query.Materialize - Rel8.Query.Maybe - Rel8.Query.Null - Rel8.Query.Opaleye - Rel8.Query.Order - Rel8.Query.Rebind - Rel8.Query.Set - Rel8.Query.SQL - Rel8.Query.These - Rel8.Query.Values - Rel8.Query.Window - - Rel8.Schema.Context.Nullify - Rel8.Schema.Dict - Rel8.Schema.Escape - Rel8.Schema.Field - Rel8.Schema.HTable - Rel8.Schema.HTable.Either - Rel8.Schema.HTable.Identity - Rel8.Schema.HTable.Label - Rel8.Schema.HTable.List - Rel8.Schema.HTable.MapTable - Rel8.Schema.HTable.Maybe - Rel8.Schema.HTable.NonEmpty - Rel8.Schema.HTable.Nullify - Rel8.Schema.HTable.Product - Rel8.Schema.HTable.These - Rel8.Schema.HTable.Vectorize - Rel8.Schema.Kind - Rel8.Schema.Name - Rel8.Schema.Null - Rel8.Schema.QualifiedName - Rel8.Schema.Result - Rel8.Schema.Spec - Rel8.Schema.Table - - Rel8.Statement - Rel8.Statement.Delete - Rel8.Statement.Insert - Rel8.Statement.OnConflict - Rel8.Statement.Prepared - Rel8.Statement.Returning - Rel8.Statement.Rows - Rel8.Statement.Run - Rel8.Statement.Select - Rel8.Statement.Set - Rel8.Statement.SQL - Rel8.Statement.Update - Rel8.Statement.Using - Rel8.Statement.View - Rel8.Statement.Where - - Rel8.Table - Rel8.Table.ADT - Rel8.Table.Aggregate - Rel8.Table.Aggregate.Maybe - Rel8.Table.Alternative - Rel8.Table.Bool - Rel8.Table.Cols - Rel8.Table.Either - Rel8.Table.Eq - Rel8.Table.HKD - Rel8.Table.List - Rel8.Table.Maybe - Rel8.Table.Name - Rel8.Table.NonEmpty - Rel8.Table.Null - Rel8.Table.Nullify - Rel8.Table.Opaleye - Rel8.Table.Ord - Rel8.Table.Order - Rel8.Table.Projection - Rel8.Table.Rel8able - Rel8.Table.Serialize - Rel8.Table.These - Rel8.Table.Transpose - Rel8.Table.Undefined - Rel8.Table.Window - - Rel8.Type - Rel8.Type.Array - Rel8.Type.Builder.ByteString - Rel8.Type.Builder.Fold - Rel8.Type.Builder.Time - Rel8.Type.Composite - Rel8.Type.Decimal - Rel8.Type.Decoder - Rel8.Type.Eq - Rel8.Type.Encoder - Rel8.Type.Enum - Rel8.Type.Information - Rel8.Type.JSONEncoded - Rel8.Type.JSONBEncoded - Rel8.Type.Monoid - Rel8.Type.Name - Rel8.Type.Nullable - Rel8.Type.Num - Rel8.Type.Ord - Rel8.Type.Parser - Rel8.Type.Parser.ByteString - Rel8.Type.Parser.Time - Rel8.Type.Range - Rel8.Type.ReadShow - Rel8.Type.Semigroup - Rel8.Type.String - Rel8.Type.Sum - Rel8.Type.Tag - - Rel8.Window - - -test-suite tests - type: exitcode-stdio-1.0 - build-depends: - aeson - , base - , bytestring - , case-insensitive - , containers - , hasql - , hasql-transaction - , hedgehog >= 1.0 && < 1.6 - , mmorph - , iproute - , rel8 - , scientific - , tasty - , tasty-hedgehog - , text - , these - , time - , tmp-postgres >=1.34 && <1.36 - , transformers - , uuid - , vector - - other-modules: - Rel8.Generic.Rel8able.Test - - main-is: Main.hs - hs-source-dirs: tests - default-language: Haskell2010 - ghc-options: - -Weverything -Wno-unsafe -Wno-safe -Wno-missing-safe-haskell-mode - -Wno-missing-import-lists -Wno-prepositive-qualified-module - -Wno-deprecations -Wno-monomorphism-restriction - -Wno-missing-local-signatures -Wno-implicit-prelude - -Wno-missing-kind-signatures - -Wno-missing-role-annotations diff --git a/Changelog.md b/rel8/Changelog.md similarity index 100% rename from Changelog.md rename to rel8/Changelog.md diff --git a/rel8/LICENSE b/rel8/LICENSE new file mode 100644 index 00000000..e71c2c9b --- /dev/null +++ b/rel8/LICENSE @@ -0,0 +1,26 @@ +Copyright 2021 Oliver Charles + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/rel8/rel8.cabal b/rel8/rel8.cabal new file mode 100644 index 00000000..401b79d8 --- /dev/null +++ b/rel8/rel8.cabal @@ -0,0 +1,96 @@ +cabal-version: 3.0 +name: rel8 +version: 1.7.0.0 +synopsis: Hey! Hey! Can u rel8? +license: BSD-3-Clause +license-file: LICENSE +author: Oliver Charles +maintainer: ollie@ocharles.org.uk +homepage: https://github.com/circuithub/rel8 +bug-reports: https://github.com/circuithub/rel8/issues +build-type: Simple +extra-doc-files: + Changelog.md + +source-repository head + type: git + location: https://github.com/circuithub/rel8 + +library + build-depends: + rel8-internal ==1.7.0.0 + , base >= 4.16 && < 4.23 + , bifunctors + , bytestring + , comonad + , opaleye ^>= 0.10.2.1 + , profunctors + , product-profunctors + , semigroupoids + , time + + default-language: + Haskell2010 + ghc-options: + -Werror=missing-methods -Werror=incomplete-patterns -Werror=missing-fields + -Weverything -Wno-unsafe -Wno-safe -Wno-missing-safe-haskell-mode + -Wno-missing-import-lists -Wno-prepositive-qualified-module + -Wno-monomorphism-restriction + -Wno-missing-local-signatures + -Wno-missing-kind-signatures + -Wno-missing-role-annotations + -Wno-missing-deriving-strategies + -Wno-term-variable-capture + + hs-source-dirs: + src + exposed-modules: + Rel8 + Rel8.Array + Rel8.Decoder + Rel8.Encoder + Rel8.Expr.Num + Rel8.Expr.Text + Rel8.Expr.Time + Rel8.Range + Rel8.Tabulate + +test-suite tests + type: exitcode-stdio-1.0 + build-depends: + aeson + , base + , bytestring + , case-insensitive + , containers + , hasql + , hasql-transaction + , hedgehog >= 1.0 && < 1.6 + , mmorph + , iproute + , rel8 + , rel8-internal + , scientific + , tasty + , tasty-hedgehog + , text + , these + , time + , tmp-postgres >=1.34 && <1.36 + , transformers + , uuid + , vector + + other-modules: + Rel8.Generic.Rel8able.Test + + main-is: Main.hs + hs-source-dirs: tests + default-language: Haskell2010 + ghc-options: + -Weverything -Wno-unsafe -Wno-safe -Wno-missing-safe-haskell-mode + -Wno-missing-import-lists -Wno-prepositive-qualified-module + -Wno-deprecations -Wno-monomorphism-restriction + -Wno-missing-local-signatures -Wno-implicit-prelude + -Wno-missing-kind-signatures + -Wno-missing-role-annotations diff --git a/src/Rel8.hs b/rel8/src/Rel8.hs similarity index 78% rename from src/Rel8.hs rename to rel8/src/Rel8.hs index 6616d138..cf83d20e 100644 --- a/src/Rel8.hs +++ b/rel8/src/Rel8.hs @@ -398,115 +398,115 @@ module Rel8 import Prelude () -- rel8 -import Rel8.Aggregate -import Rel8.Aggregate.Fold -import Rel8.Aggregate.Function -import Rel8.Column -import Rel8.Column.ADT -import Rel8.Column.Either -import Rel8.Column.Lift -import Rel8.Column.List -import Rel8.Column.Maybe -import Rel8.Column.NonEmpty -import Rel8.Column.Null -import Rel8.Column.These -import Rel8.Expr -import Rel8.Expr.Aggregate -import Rel8.Expr.Array -import Rel8.Expr.Bool -import Rel8.Expr.Default -import Rel8.Expr.Eq -import Rel8.Expr.Function -import Rel8.Expr.Null -import Rel8.Expr.Opaleye (unsafeCastExpr, unsafeCoerceExpr, unsafeLiteral, unsafePrimExpr) -import Rel8.Expr.Ord -import Rel8.Expr.Order -import Rel8.Expr.Serialize -import Rel8.Expr.Sequence -import Rel8.Expr.Text ( like, ilike ) -import Rel8.Expr.Window -import Rel8.Generic.Rel8able ( KRel8able, Rel8able ) -import Rel8.Order -import Rel8.Query -import Rel8.Query.Aggregate -import Rel8.Query.Distinct -import Rel8.Query.Each -import Rel8.Query.Either -import Rel8.Query.Evaluate -import Rel8.Query.Exists -import Rel8.Query.Filter -import Rel8.Query.Function -import Rel8.Query.Indexed -import Rel8.Query.Limit -import Rel8.Query.List -import Rel8.Query.Loop -import Rel8.Query.Materialize -import Rel8.Query.Maybe -import Rel8.Query.Null -import Rel8.Query.Order -import Rel8.Query.Rebind -import Rel8.Query.SQL (showQuery) -import Rel8.Query.Set -import Rel8.Query.These -import Rel8.Query.Values -import Rel8.Query.Window -import Rel8.Schema.Field -import Rel8.Schema.HTable -import Rel8.Schema.Name -import Rel8.Schema.Null hiding ( nullable ) -import Rel8.Schema.QualifiedName -import Rel8.Schema.Result ( Result ) -import Rel8.Schema.Table -import Rel8.Statement -import Rel8.Statement.Delete -import Rel8.Statement.Insert -import Rel8.Statement.OnConflict -import Rel8.Statement.Prepared -import Rel8.Statement.Returning -import Rel8.Statement.Run -import Rel8.Statement.Select -import Rel8.Statement.SQL -import Rel8.Statement.Update -import Rel8.Statement.View -import Rel8.Table -import Rel8.Table.ADT -import Rel8.Table.Aggregate -import Rel8.Table.Aggregate.Maybe -import Rel8.Table.Alternative -import Rel8.Table.Bool -import Rel8.Table.Either -import Rel8.Table.Eq -import Rel8.Table.HKD -import Rel8.Table.List -import Rel8.Table.Maybe -import Rel8.Table.Name -import Rel8.Table.NonEmpty -import Rel8.Table.Null -import Rel8.Table.Opaleye ( castTable ) -import Rel8.Table.Ord -import Rel8.Table.Order -import Rel8.Table.Projection -import Rel8.Table.Rel8able () -import Rel8.Table.Serialize -import Rel8.Table.These -import Rel8.Table.Transpose -import Rel8.Table.Window -import Rel8.Type -import Rel8.Type.Composite -import Rel8.Type.Eq -import Rel8.Type.Enum -import Rel8.Type.Information -import Rel8.Type.JSONBEncoded -import Rel8.Type.JSONEncoded -import Rel8.Type.Monoid -import Rel8.Type.Name -import Rel8.Type.Num -import Rel8.Type.Ord -import Rel8.Type.ReadShow -import Rel8.Type.Semigroup -import Rel8.Type.String -import Rel8.Type.Sum -import Rel8.Window +import Rel8.Internal.Aggregate +import Rel8.Internal.Aggregate.Fold +import Rel8.Internal.Aggregate.Function +import Rel8.Internal.Column +import Rel8.Internal.Column.ADT +import Rel8.Internal.Column.Either +import Rel8.Internal.Column.Lift +import Rel8.Internal.Column.List +import Rel8.Internal.Column.Maybe +import Rel8.Internal.Column.NonEmpty +import Rel8.Internal.Column.Null +import Rel8.Internal.Column.These +import Rel8.Internal.Expr +import Rel8.Internal.Expr.Aggregate +import Rel8.Internal.Expr.Array +import Rel8.Internal.Expr.Bool +import Rel8.Internal.Expr.Default +import Rel8.Internal.Expr.Eq +import Rel8.Internal.Expr.Function +import Rel8.Internal.Expr.Null +import Rel8.Internal.Expr.Opaleye (unsafeCastExpr, unsafeCoerceExpr, unsafeLiteral, unsafePrimExpr) +import Rel8.Internal.Expr.Ord +import Rel8.Internal.Expr.Order +import Rel8.Internal.Expr.Serialize +import Rel8.Internal.Expr.Sequence +import Rel8.Internal.Expr.Text ( like, ilike ) +import Rel8.Internal.Expr.Window +import Rel8.Internal.Generic.Rel8able ( KRel8able, Rel8able ) +import Rel8.Internal.Order +import Rel8.Internal.Query +import Rel8.Internal.Query.Aggregate +import Rel8.Internal.Query.Distinct +import Rel8.Internal.Query.Each +import Rel8.Internal.Query.Either +import Rel8.Internal.Query.Evaluate +import Rel8.Internal.Query.Exists +import Rel8.Internal.Query.Filter +import Rel8.Internal.Query.Function +import Rel8.Internal.Query.Indexed +import Rel8.Internal.Query.Limit +import Rel8.Internal.Query.List +import Rel8.Internal.Query.Loop +import Rel8.Internal.Query.Materialize +import Rel8.Internal.Query.Maybe +import Rel8.Internal.Query.Null +import Rel8.Internal.Query.Order +import Rel8.Internal.Query.Rebind +import Rel8.Internal.Query.SQL (showQuery) +import Rel8.Internal.Query.Set +import Rel8.Internal.Query.These +import Rel8.Internal.Query.Values +import Rel8.Internal.Query.Window +import Rel8.Internal.Schema.Field +import Rel8.Internal.Schema.HTable +import Rel8.Internal.Schema.Name +import Rel8.Internal.Schema.Null hiding ( nullable ) +import Rel8.Internal.Schema.QualifiedName +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Schema.Table +import Rel8.Internal.Statement +import Rel8.Internal.Statement.Delete +import Rel8.Internal.Statement.Insert +import Rel8.Internal.Statement.OnConflict +import Rel8.Internal.Statement.Prepared +import Rel8.Internal.Statement.Returning +import Rel8.Internal.Statement.Run +import Rel8.Internal.Statement.Select +import Rel8.Internal.Statement.SQL +import Rel8.Internal.Statement.Update +import Rel8.Internal.Statement.View +import Rel8.Internal.Table +import Rel8.Internal.Table.ADT +import Rel8.Internal.Table.Aggregate +import Rel8.Internal.Table.Aggregate.Maybe +import Rel8.Internal.Table.Alternative +import Rel8.Internal.Table.Bool +import Rel8.Internal.Table.Either +import Rel8.Internal.Table.Eq +import Rel8.Internal.Table.HKD +import Rel8.Internal.Table.List +import Rel8.Internal.Table.Maybe +import Rel8.Internal.Table.Name +import Rel8.Internal.Table.NonEmpty +import Rel8.Internal.Table.Null +import Rel8.Internal.Table.Opaleye ( castTable ) +import Rel8.Internal.Table.Ord +import Rel8.Internal.Table.Order +import Rel8.Internal.Table.Projection +import Rel8.Internal.Table.Rel8able () +import Rel8.Internal.Table.Serialize +import Rel8.Internal.Table.These +import Rel8.Internal.Table.Transpose +import Rel8.Internal.Table.Window +import Rel8.Internal.Type +import Rel8.Internal.Type.Composite +import Rel8.Internal.Type.Eq +import Rel8.Internal.Type.Enum +import Rel8.Internal.Type.Information +import Rel8.Internal.Type.JSONBEncoded +import Rel8.Internal.Type.JSONEncoded +import Rel8.Internal.Type.Monoid +import Rel8.Internal.Type.Name +import Rel8.Internal.Type.Num +import Rel8.Internal.Type.Ord +import Rel8.Internal.Type.ReadShow +import Rel8.Internal.Type.Semigroup +import Rel8.Internal.Type.String +import Rel8.Internal.Type.Sum +import Rel8.Internal.Window -- $running diff --git a/src/Rel8/Array.hs b/rel8/src/Rel8/Array.hs similarity index 72% rename from src/Rel8/Array.hs rename to rel8/src/Rel8/Array.hs index d8447945..af69cb40 100644 --- a/src/Rel8/Array.hs +++ b/rel8/src/Rel8/Array.hs @@ -31,16 +31,16 @@ import Data.List.NonEmpty (NonEmpty) import Prelude hiding (elem, head, last, length) -- rel8 -import Rel8.Expr (Expr) -import Rel8.Expr.Array (listOf, nonEmptyOf) -import Rel8.Expr.Function (rawBinaryOperator) -import Rel8.Expr.List -import Rel8.Expr.NonEmpty -import Rel8.Expr.Subscript -import Rel8.Schema.Null (Sql) -import Rel8.Table.List -import Rel8.Table.NonEmpty -import Rel8.Type.Eq (DBEq) +import Rel8.Internal.Expr (Expr) +import Rel8.Internal.Expr.Array (listOf, nonEmptyOf) +import Rel8.Internal.Expr.Function (rawBinaryOperator) +import Rel8.Internal.Expr.List +import Rel8.Internal.Expr.NonEmpty +import Rel8.Internal.Expr.Subscript +import Rel8.Internal.Schema.Null (Sql) +import Rel8.Internal.Table.List +import Rel8.Internal.Table.NonEmpty +import Rel8.Internal.Type.Eq (DBEq) -- | @'elem' a as@ tests whether @a@ is an element of the list @as@. diff --git a/src/Rel8/Decoder.hs b/rel8/src/Rel8/Decoder.hs similarity index 67% rename from src/Rel8/Decoder.hs rename to rel8/src/Rel8/Decoder.hs index cbeaf312..b4a1f023 100644 --- a/src/Rel8/Decoder.hs +++ b/rel8/src/Rel8/Decoder.hs @@ -3,4 +3,4 @@ module Rel8.Decoder ( Parser, parseDecoder, ) where -import Rel8.Type.Decoder +import Rel8.Internal.Type.Decoder diff --git a/src/Rel8/Encoder.hs b/rel8/src/Rel8/Encoder.hs similarity index 57% rename from src/Rel8/Encoder.hs rename to rel8/src/Rel8/Encoder.hs index 70c2d545..0656f9fa 100644 --- a/src/Rel8/Encoder.hs +++ b/rel8/src/Rel8/Encoder.hs @@ -1,4 +1,4 @@ module Rel8.Encoder ( Encoder (..), ) where -import Rel8.Type.Encoder +import Rel8.Internal.Type.Encoder diff --git a/src/Rel8/Expr.hs-boot b/rel8/src/Rel8/Expr.hs-boot similarity index 86% rename from src/Rel8/Expr.hs-boot rename to rel8/src/Rel8/Expr.hs-boot index 0051845e..6dba2714 100644 --- a/src/Rel8/Expr.hs-boot +++ b/rel8/src/Rel8/Expr.hs-boot @@ -13,7 +13,7 @@ import Prelude () import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye -- rel8 -import Rel8.Schema.Kind ( Context ) +import Rel8.Internal.Schema.Kind ( Context ) type Expr :: Context diff --git a/src/Rel8/Expr/Num.hs b/rel8/src/Rel8/Expr/Num.hs similarity index 89% rename from src/Rel8/Expr/Num.hs rename to rel8/src/Rel8/Expr/Num.hs index f1f58767..538d59f3 100644 --- a/src/Rel8/Expr/Num.hs +++ b/rel8/src/Rel8/Expr/Num.hs @@ -17,13 +17,13 @@ where import Prelude ( (+), (-), fst, negate, signum, snd ) -- rel -import Rel8.Expr ( Expr( Expr ) ) -import Rel8.Expr.Eq ( (==.) ) -import Rel8.Expr.Function (function) -import Rel8.Expr.Opaleye ( castExpr ) -import Rel8.Schema.Null ( Homonullable, Sql ) -import Rel8.Table.Bool ( bool ) -import Rel8.Type.Num ( DBFractional, DBIntegral, DBNum ) +import Rel8.Internal.Expr ( Expr( Expr ) ) +import Rel8.Internal.Expr.Eq ( (==.) ) +import Rel8.Internal.Expr.Function (function) +import Rel8.Internal.Expr.Opaleye ( castExpr ) +import Rel8.Internal.Schema.Null ( Homonullable, Sql ) +import Rel8.Internal.Table.Bool ( bool ) +import Rel8.Internal.Type.Num ( DBFractional, DBIntegral, DBNum ) -- | Cast 'DBIntegral' types to 'DBNum' types. For example, this can be useful diff --git a/rel8/src/Rel8/Expr/Text.hs b/rel8/src/Rel8/Expr/Text.hs new file mode 100644 index 00000000..25d58aca --- /dev/null +++ b/rel8/src/Rel8/Expr/Text.hs @@ -0,0 +1,43 @@ +{-# language DataKinds #-} +{-# language OverloadedStrings #-} + +module Rel8.Expr.Text + ( + -- * String concatenation + (++.) + + -- * Regular expression operators + , (~.), (~*), (!~), (!~*) + + -- * Standard SQL functions + , bitLength, charLength, lower, octetLength, upper + + -- * PostgreSQL functions + , ascii, btrim, chr, convert, convertFrom, convertTo, decode, encode + , initcap, left, length, lengthEncoding, lpad, ltrim, md5 + , pgClientEncoding, quoteIdent, quoteLiteral, quoteNullable, regexpReplace + , regexpSplitToArray, repeat, replace, reverse, right, rpad, rtrim + , splitPart, strpos, substr, translate + + -- * @LIKE@ and @ILIKE@ + , like, ilike + ) +where + +-- base +import Data.Bool ( Bool ) +import Data.Int ( Int32 ) +import Data.Maybe ( Maybe( Nothing, Just ) ) +import Prelude ( flip ) + +-- bytestring +import Data.ByteString ( ByteString ) + +-- opaleye +import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye + +-- rel8 +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Function (binaryOperator, function) +import Rel8.Internal.Expr.Opaleye (zipPrimExprsWith) +import Rel8.Internal.Expr.Text diff --git a/src/Rel8/Expr/Time.hs b/rel8/src/Rel8/Expr/Time.hs similarity index 95% rename from src/Rel8/Expr/Time.hs rename to rel8/src/Rel8/Expr/Time.hs index 97666298..60ac281e 100644 --- a/src/Rel8/Expr/Time.hs +++ b/rel8/src/Rel8/Expr/Time.hs @@ -31,9 +31,9 @@ import Data.Int ( Int32 ) import Prelude -- rel8 -import Rel8.Expr ( Expr ) -import Rel8.Expr.Function (binaryOperator, function) -import Rel8.Expr.Opaleye ( castExpr, unsafeCastExpr, unsafeLiteral ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Function (binaryOperator, function) +import Rel8.Internal.Expr.Opaleye ( castExpr, unsafeCastExpr, unsafeLiteral ) -- time import Data.Time.Calendar ( Day ) diff --git a/src/Rel8/Query.hs-boot b/rel8/src/Rel8/Query.hs-boot similarity index 100% rename from src/Rel8/Query.hs-boot rename to rel8/src/Rel8/Query.hs-boot diff --git a/src/Rel8/Range.hs b/rel8/src/Rel8/Range.hs similarity index 77% rename from src/Rel8/Range.hs rename to rel8/src/Rel8/Range.hs index 2297291d..001aa3c2 100644 --- a/src/Rel8/Range.hs +++ b/rel8/src/Rel8/Range.hs @@ -18,14 +18,14 @@ module Rel8.Range ( import Prelude () -- rel8 -import Rel8.Aggregate.Range (rangeAgg) -import Rel8.Data.Range ( +import Rel8.Internal.Aggregate.Range (rangeAgg) +import Rel8.Internal.Data.Range ( Bound (Incl, Excl, Inf), Range (Empty, Range), Multirange (Multirange), ) -import Rel8.Expr.Range (range, multirange) -import Rel8.Type.Range ( +import Rel8.Internal.Expr.Range (range, multirange) +import Rel8.Internal.Type.Range ( DBRange ( rangeTypeName, rangeDecoder, rangeEncoder, multirangeTypeName, multirangeDecoder, multirangeEncoder diff --git a/src/Rel8/Table/Verify.hs b/rel8/src/Rel8/Table/Verify.hs similarity index 93% rename from src/Rel8/Table/Verify.hs rename to rel8/src/Rel8/Table/Verify.hs index 306c3b65..1973f6a0 100644 --- a/src/Rel8/Table/Verify.hs +++ b/rel8/src/Rel8/Table/Verify.hs @@ -50,38 +50,38 @@ import qualified Data.Map as M import qualified Hasql.Statement as HS -- rel8 -import Rel8.Column ( Column ) -import Rel8.Column.List ( HList ) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Eq ((==.)) -import Rel8.Expr.Ord ((>.)) -import Rel8.Expr.Order (asc) -import Rel8.Generic.Rel8able (GFromExprs, Rel8able) -import Rel8.Query ( Query ) -import Rel8.Query.Each (each) -import Rel8.Query.Filter (filter) -import Rel8.Query.List (many) -import Rel8.Query.Order (orderBy) -import Rel8.Schema.HTable -import Rel8.Schema.Name ( Name(Name) ) -import Rel8.Schema.Null hiding (nullable) -import Rel8.Schema.QualifiedName ( QualifiedName(..) ) -import Rel8.Schema.Result ( Result ) -import Rel8.Schema.Spec (Spec (Spec)) -import qualified Rel8.Schema.Spec -import Rel8.Schema.Table ( TableSchema(..) ) -import Rel8.Statement.Run (run1) -import Rel8.Statement.Select (select) -import Rel8.Table (Columns, toColumns) -import Rel8.Table.List ( ListTable ) -import Rel8.Table.Name (namesFromLabelsWith) -import Rel8.Table.Rel8able () -import Rel8.Table.Serialize (ToExprs, lit) -import Rel8.Type ( DBType(..) ) -import Rel8.Type.Eq ( DBEq ) -import Rel8.Type.Information (parseTypeInformation) -import qualified Rel8.Type.Information -import Rel8.Type.Name ( TypeName(..) ) +import Rel8.Internal.Column ( Column ) +import Rel8.Internal.Column.List ( HList ) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Eq ((==.)) +import Rel8.Internal.Expr.Ord ((>.)) +import Rel8.Internal.Expr.Order (asc) +import Rel8.Internal.Generic.Rel8able (GFromExprs, Rel8able) +import Rel8.Internal.Query ( Query ) +import Rel8.Internal.Query.Each (each) +import Rel8.Internal.Query.Filter (filter) +import Rel8.Internal.Query.List (many) +import Rel8.Internal.Query.Order (orderBy) +import Rel8.Internal.Schema.HTable +import Rel8.Internal.Schema.Name ( Name(Name) ) +import Rel8.Internal.Schema.Null hiding (nullable) +import Rel8.Internal.Schema.QualifiedName ( QualifiedName(..) ) +import Rel8.Internal.Schema.Result ( Result ) +import Rel8.Internal.Schema.Spec (Spec (Spec)) +import qualified Rel8.Internal.Schema.Spec +import Rel8.Internal.Schema.Table ( TableSchema(..) ) +import Rel8.Internal.Statement.Run (run1) +import Rel8.Internal.Statement.Select (select) +import Rel8.Internal.Table (Columns, toColumns) +import Rel8.Internal.Table.List ( ListTable ) +import Rel8.Internal.Table.Name (namesFromLabelsWith) +import Rel8.Internal.Table.Rel8able () +import Rel8.Internal.Table.Serialize (ToExprs, lit) +import Rel8.Internal.Type ( DBType(..) ) +import Rel8.Internal.Type.Eq ( DBEq ) +import Rel8.Internal.Type.Information (parseTypeInformation) +import qualified Rel8.Internal.Type.Information +import Rel8.Internal.Type.Name ( TypeName(..) ) -- semialign import Data.Semialign (align) diff --git a/src/Rel8/Tabulate.hs b/rel8/src/Rel8/Tabulate.hs similarity index 92% rename from src/Rel8/Tabulate.hs rename to rel8/src/Rel8/Tabulate.hs index 8ecc0fd5..77962513 100644 --- a/src/Rel8/Tabulate.hs +++ b/rel8/src/Rel8/Tabulate.hs @@ -84,41 +84,41 @@ import Data.Profunctor.Product import qualified Data.Profunctor.Product as PP -- rel8 -import Rel8.Aggregate (Aggregator' (Aggregator), Aggregator, toAggregator1) -import Rel8.Aggregate.Fold (Fallback (Fallback)) -import Rel8.Expr ( Expr ) -import Rel8.Expr.Aggregate (countStar) -import Rel8.Expr.Bool ( true ) -import Rel8.Order ( Order( Order ) ) -import Rel8.Query ( Query ) -import qualified Rel8.Query.Aggregate as Q -import qualified Rel8.Query.Exists as Q ( exists, present, absent ) -import Rel8.Query.Filter ( where_ ) -import Rel8.Query.List ( catNonEmptyTable ) -import qualified Rel8.Query.Materialize as Q -import qualified Rel8.Query.Maybe as Q ( optional ) -import Rel8.Query.Opaleye ( mapOpaleye, unsafePeekQuery ) -import Rel8.Query.Rebind ( rebind ) -import Rel8.Query.These ( alignBy ) -import Rel8.Table ( Table, fromColumns, toColumns ) -import Rel8.Table.Aggregate (groupBy, listAgg, nonEmptyAgg) -import Rel8.Table.Alternative +import Rel8.Internal.Aggregate (Aggregator' (Aggregator), Aggregator, toAggregator1) +import Rel8.Internal.Aggregate.Fold (Fallback (Fallback)) +import Rel8.Internal.Expr ( Expr ) +import Rel8.Internal.Expr.Aggregate (countStar) +import Rel8.Internal.Expr.Bool ( true ) +import Rel8.Internal.Order ( Order( Order ) ) +import Rel8.Internal.Query ( Query ) +import qualified Rel8.Internal.Query.Aggregate as Q +import qualified Rel8.Internal.Query.Exists as Q ( exists, present, absent ) +import Rel8.Internal.Query.Filter ( where_ ) +import Rel8.Internal.Query.List ( catNonEmptyTable ) +import qualified Rel8.Internal.Query.Materialize as Q +import qualified Rel8.Internal.Query.Maybe as Q ( optional ) +import Rel8.Internal.Query.Opaleye ( mapOpaleye, unsafePeekQuery ) +import Rel8.Internal.Query.Rebind ( rebind ) +import Rel8.Internal.Query.These ( alignBy ) +import Rel8.Internal.Table ( Table, fromColumns, toColumns ) +import Rel8.Internal.Table.Aggregate (groupBy, listAgg, nonEmptyAgg) +import Rel8.Internal.Table.Alternative ( AltTable, (<|>:) , AlternativeTable, emptyTable ) -import Rel8.Table.Eq (EqTable, (==:)) -import Rel8.Table.List (ListTable) -import Rel8.Table.Maybe (MaybeTable (MaybeTable), fromMaybeTable) -import Rel8.Table.NonEmpty (NonEmptyTable) -import Rel8.Table.Opaleye ( unpackspec ) -import Rel8.Table.Ord ( OrdTable ) -import Rel8.Table.Order ( ascTable ) -import Rel8.Table.Projection +import Rel8.Internal.Table.Eq (EqTable, (==:)) +import Rel8.Internal.Table.List (ListTable) +import Rel8.Internal.Table.Maybe (MaybeTable (MaybeTable), fromMaybeTable) +import Rel8.Internal.Table.NonEmpty (NonEmptyTable) +import Rel8.Internal.Table.Opaleye ( unpackspec ) +import Rel8.Internal.Table.Ord ( OrdTable ) +import Rel8.Internal.Table.Order ( ascTable ) +import Rel8.Internal.Table.Projection ( Biprojectable, biproject , Projectable, project , apply ) -import Rel8.Table.These ( TheseTable( TheseTable ), theseTable ) +import Rel8.Internal.Table.These ( TheseTable( TheseTable ), theseTable ) -- semigroupoids import Data.Functor.Apply ( Apply, liftF2 ) diff --git a/tests/Main.hs b/rel8/tests/Main.hs similarity index 99% rename from tests/Main.hs rename to rel8/tests/Main.hs index 9c2753e6..88fc656f 100644 --- a/tests/Main.hs +++ b/rel8/tests/Main.hs @@ -82,7 +82,7 @@ import Control.Monad.Morph ( hoist ) import Rel8 ( Result ) import qualified Rel8 import qualified Rel8.Generic.Rel8able.Test as Rel8able -import qualified Rel8.Table.Verify as Verify +import qualified Rel8.Internal.Table.Verify as Verify import Rel8.Range ( Bound (Incl, Excl, Inf), Range (Empty, Range), diff --git a/tests/Rel8/Generic/Rel8able/Test.hs b/rel8/tests/Rel8/Generic/Rel8able/Test.hs similarity index 100% rename from tests/Rel8/Generic/Rel8able/Test.hs rename to rel8/tests/Rel8/Generic/Rel8able/Test.hs diff --git a/src/Rel8/Aggregate/Range.hs b/src/Rel8/Aggregate/Range.hs deleted file mode 100644 index 2d7e598d..00000000 --- a/src/Rel8/Aggregate/Range.hs +++ /dev/null @@ -1,21 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Rel8.Aggregate.Range ( - rangeAgg, -) where - --- base -import Prelude - --- rel8 -import Rel8.Aggregate (Aggregator', toAggregator) -import Rel8.Aggregate.Function (aggregateFunction) -import Rel8.Data.Range (Multirange, Range) -import Rel8.Expr (Expr) -import Rel8.Type.Range (DBRange) - - -rangeAgg :: - DBRange a => - Aggregator' fold (Expr (Range a)) (Expr (Multirange a)) -rangeAgg = toAggregator mempty $ aggregateFunction "range_agg"