diff --git a/rel8.cabal b/rel8.cabal index 3929d5fd..51ea9129 100644 --- a/rel8.cabal +++ b/rel8.cabal @@ -20,7 +20,7 @@ source-repository head library build-depends: aeson - , base ^>= 4.14 || ^>=4.15 || ^>=4.16 + , base ^>=4.15 || ^>=4.16 , bifunctors , bytestring , case-insensitive diff --git a/src/Rel8/Table.hs b/src/Rel8/Table.hs index 8a58d0b1..a01b2b79 100644 --- a/src/Rel8/Table.hs +++ b/src/Rel8/Table.hs @@ -25,6 +25,7 @@ where -- base import Data.Functor.Identity ( Identity( Identity ) ) import Data.Kind ( Constraint, Type ) +import Data.Tuple ( Solo( Solo ) ) import GHC.Generics ( Generic, Rep, from, to ) import Prelude hiding ( null ) @@ -181,6 +182,18 @@ type instance Eval (TSerialize expr a) = ) +instance Table context a => Table context (Solo a) where + type Columns (Solo a) = Columns a + type Context (Solo a) = Context a + type FromExprs (Solo a) = Solo (FromExprs a) + type Transpose to (Solo a) = Solo (Transpose to a) + + toColumns (Solo a) = toColumns a + fromColumns = Solo . fromColumns + toResult (Solo a) = toResult @_ @a a + fromResult = Solo . fromResult @_ @a + + instance (Table context a, Table context b) => Table context (a, b) diff --git a/src/Rel8/Table/Eq.hs b/src/Rel8/Table/Eq.hs index 84a36def..d28e8908 100644 --- a/src/Rel8/Table/Eq.hs +++ b/src/Rel8/Table/Eq.hs @@ -23,6 +23,7 @@ import Data.Foldable ( foldl' ) import Data.Functor.Const ( Const( Const ), getConst ) import Data.Kind ( Constraint, Type ) import Data.List.NonEmpty ( NonEmpty( (:|) ) ) +import Data.Tuple ( Solo ) import GHC.Generics ( Rep ) import Prelude @@ -66,6 +67,10 @@ instance Sql DBEq a => EqTable (Expr a) where eqTable = HIdentity Dict +instance EqTable a => EqTable (Solo a) where + eqTable = eqTable @a + + instance (EqTable a, EqTable b) => EqTable (a, b) diff --git a/src/Rel8/Table/Ord.hs b/src/Rel8/Table/Ord.hs index ac73fcdc..ae4ecd4d 100644 --- a/src/Rel8/Table/Ord.hs +++ b/src/Rel8/Table/Ord.hs @@ -20,6 +20,7 @@ where -- base import Data.Functor.Const ( Const( Const ), getConst ) import Data.Kind ( Constraint, Type ) +import Data.Tuple ( Solo ) import GHC.Generics ( Rep ) import Prelude hiding ( seq ) @@ -66,6 +67,10 @@ instance Sql DBOrd a => OrdTable (Expr a) where ordTable = HIdentity Dict +instance OrdTable a => OrdTable (Solo a) where + ordTable = ordTable @a + + instance (OrdTable a, OrdTable b) => OrdTable (a, b) diff --git a/src/Rel8/Table/Serialize.hs b/src/Rel8/Table/Serialize.hs index dc88eab8..fd2b2813 100644 --- a/src/Rel8/Table/Serialize.hs +++ b/src/Rel8/Table/Serialize.hs @@ -19,6 +19,7 @@ where import Data.Functor.Identity ( Identity( Identity ) ) import Data.Kind ( Constraint, Type ) import Data.List.NonEmpty ( NonEmpty ) +import Data.Tuple (Solo) import Prelude -- hasql @@ -57,6 +58,9 @@ instance (Sql DBType a, NotNull a, x ~ Maybe a) => ToExprs (Expr x) (Maybe a) instance (Sql DBType a, NotNull a, x ~ NonEmpty a) => ToExprs (Expr x) (NonEmpty a) +instance (ToExprs exprs a, x ~ Solo exprs) => ToExprs x (Solo a) + + instance (ToExprs exprs1 a, ToExprs exprs2 b, x ~ (exprs1, exprs2)) => ToExprs x (a, b)