Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class NotNull a => DBType a where
- newtype JSONEncoded a = JSONEncoded {
- fromJSONEncoded :: a
- newtype JSONBEncoded a = JSONBEncoded {
- fromJSONBEncoded :: a
- newtype ReadShow a = ReadShow {
- fromReadShow :: a
- newtype Composite a = Composite a
- class (DBType a, HKDable a) => DBComposite a where
- compositeFields :: HKD a Name
- compositeTypeName :: String
- compose :: DBComposite a => HKD a Expr -> Expr a
- decompose :: forall a. DBComposite a => Expr a -> HKD a Expr
- newtype Enum a = Enum a
- class (DBType a, Enumable a) => DBEnum a where
- enumValue :: a -> String
- enumTypeName :: String
- class (Generic a, GEnumable (Rep a)) => Enumable a
- data TypeInformation a = TypeInformation {}
- mapTypeInformation :: (a -> b) -> (b -> a) -> TypeInformation a -> TypeInformation b
- parseTypeInformation :: (a -> Either String b) -> (b -> a) -> TypeInformation a -> TypeInformation b
- class DBType a => DBSemigroup a where
- class DBSemigroup a => DBMonoid a where
- memptyExpr :: Expr a
- class DBType a => DBNum a
- class DBNum a => DBIntegral a
- class DBNum a => DBFractional a
- class DBFractional a => DBFloating a
- class HTable (GColumns t) => Rel8able t
- type KRel8able = Rel8able
- type Column context a = Field context 'Required a
- type family Field context necessity a where ...
- data Necessity
- type Default context a = Field context 'Optional a
- type family HADT context t where ...
- type family HEither context where ...
- type family HMaybe context where ...
- type family HList context where ...
- type family HNonEmpty context where ...
- type family HThese context where ...
- type family Lift context a where ...
- class (HTable (Columns a), context ~ Context a) => Table context a | a -> context where
- class AltTable f where
- class AltTable f => AlternativeTable f where
- emptyTable :: Table Expr a => f a
- class Table Expr a => EqTable a
- (==:) :: forall a. EqTable a => a -> a -> Expr Bool
- (/=:) :: forall a. EqTable a => a -> a -> Expr Bool
- class EqTable a => OrdTable a
- ascTable :: forall a. OrdTable a => Order a
- descTable :: forall a. OrdTable a => Order a
- lit :: forall exprs a. Serializable exprs a => a -> exprs
- bool :: Table Expr a => a -> a -> Expr Bool -> a
- case_ :: Table Expr a => [(Expr Bool, a)] -> a -> a
- data MaybeTable a
- maybeTable :: Table Expr b => b -> (a -> b) -> MaybeTable a -> b
- ($?) :: forall a b. Sql DBType b => (a -> Expr b) -> MaybeTable a -> Expr (Nullify b)
- nothingTable :: Table Expr a => MaybeTable a
- justTable :: a -> MaybeTable a
- isNothingTable :: MaybeTable a -> Expr Bool
- isJustTable :: MaybeTable a -> Expr Bool
- optional :: Query a -> Query (MaybeTable a)
- catMaybeTable :: MaybeTable a -> Query a
- bindMaybeTable :: Monad m => (a -> m (MaybeTable b)) -> MaybeTable a -> m (MaybeTable b)
- traverseMaybeTable :: (a -> Query b) -> MaybeTable a -> Query (MaybeTable b)
- insertMaybeTable :: Table Insert a => Maybe a -> MaybeTable a
- nameMaybeTable :: Name (Maybe MaybeTag) -> a -> MaybeTable a
- data EitherTable a b
- eitherTable :: Table Expr c => (a -> c) -> (b -> c) -> EitherTable a b -> c
- leftTable :: Table Expr b => a -> EitherTable a b
- rightTable :: Table Expr a => b -> EitherTable a b
- isLeftTable :: EitherTable a b -> Expr Bool
- isRightTable :: EitherTable a b -> Expr Bool
- keepLeftTable :: EitherTable a b -> Query a
- keepRightTable :: EitherTable a b -> Query b
- bindEitherTable :: (Table Expr a, Functor m) => (i -> m (EitherTable a b)) -> EitherTable a i -> m (EitherTable a b)
- bitraverseEitherTable :: (a -> Query c) -> (b -> Query d) -> EitherTable a b -> Query (EitherTable c d)
- insertEitherTable :: (Table Insert a, Table Insert b) => Either a b -> EitherTable a b
- nameEitherTable :: Name EitherTag -> a -> b -> EitherTable a b
- data TheseTable a b
- theseTable :: Table Expr c => (a -> c) -> (b -> c) -> (a -> b -> c) -> TheseTable a b -> c
- thisTable :: Table Expr b => a -> TheseTable a b
- thatTable :: Table Expr a => b -> TheseTable a b
- thoseTable :: a -> b -> TheseTable a b
- isThisTable :: TheseTable a b -> Expr Bool
- isThatTable :: TheseTable a b -> Expr Bool
- isThoseTable :: TheseTable a b -> Expr Bool
- hasHereTable :: TheseTable a b -> Expr Bool
- hasThereTable :: TheseTable a b -> Expr Bool
- justHereTable :: TheseTable a b -> MaybeTable a
- justThereTable :: TheseTable a b -> MaybeTable b
- alignBy :: (Table Expr a, Table Expr b) => (a -> b -> Expr Bool) -> Query a -> Query b -> Query (TheseTable a b)
- keepHereTable :: TheseTable a b -> Query (a, MaybeTable b)
- loseHereTable :: TheseTable a b -> Query b
- keepThereTable :: TheseTable a b -> Query (MaybeTable a, b)
- loseThereTable :: TheseTable a b -> Query a
- keepThisTable :: TheseTable a b -> Query a
- loseThisTable :: TheseTable a b -> Query (MaybeTable a, b)
- keepThatTable :: TheseTable a b -> Query b
- loseThatTable :: TheseTable a b -> Query (a, MaybeTable b)
- keepThoseTable :: TheseTable a b -> Query (a, b)
- loseThoseTable :: TheseTable a b -> Query (EitherTable a b)
- bindTheseTable :: (Table Expr a, Semigroup a, Monad m) => (i -> m (TheseTable a b)) -> TheseTable a i -> m (TheseTable a b)
- bitraverseTheseTable :: (a -> Query c) -> (b -> Query d) -> TheseTable a b -> Query (TheseTable c d)
- insertTheseTable :: (Table Insert a, Table Insert b) => These a b -> TheseTable a b
- nameTheseTable :: Name (Maybe MaybeTag) -> Name (Maybe MaybeTag) -> a -> b -> TheseTable a b
- data ListTable a
- listTable :: Table Expr a => [a] -> ListTable a
- insertListTable :: Inserts exprs inserts => [exprs] -> ListTable inserts
- nameListTable :: Table Name a => a -> ListTable a
- many :: Table Expr a => Query a -> Query (ListTable a)
- manyExpr :: Sql DBType a => Query (Expr a) -> Query (Expr [a])
- catListTable :: Table Expr a => ListTable a -> Query a
- catList :: Sql DBType a => Expr [a] -> Query (Expr a)
- data NonEmptyTable a
- nonEmptyTable :: Table Expr a => NonEmpty a -> NonEmptyTable a
- insertNonEmptyTable :: Inserts exprs inserts => NonEmpty exprs -> NonEmptyTable inserts
- nameNonEmptyTable :: Table Name a => a -> NonEmptyTable a
- some :: Table Expr a => Query a -> Query (NonEmptyTable a)
- someExpr :: Sql DBType a => Query (Expr a) -> Query (Expr (NonEmpty a))
- catNonEmptyTable :: Table Expr a => NonEmptyTable a -> Query a
- catNonEmpty :: Sql DBType a => Expr (NonEmpty a) -> Query (Expr a)
- data ADT t context
- class (Generic (t Result), HTable (GColumnsADT t), GTableADT (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRecord (Rep (t (Reify Result)))), GRecordable (Rep (t (Reify Result))), GMappable (TTable (Reify Result)) (Rep (t (Reify Result))), GMap TUnreify (Rep (t (Reify Result))) ~ Rep (t Result)) => ADTable t
- fromADT :: ADTable t => ADT t Result -> t Result
- toADT :: ADTable t => t Result -> ADT t Result
- type BuildADT t name = GGBuild 'Sum name (ADTRep t) (ADT t Expr)
- buildADT :: forall t name. BuildableADT t name => BuildADT t name
- type ConstructADT t = forall r. GGConstruct 'Sum (ADTRep t) r
- constructADT :: forall t. ConstructableADT t => ConstructADT t -> ADT t Expr
- type DeconstructADT t r = GGDeconstruct 'Sum (ADTRep t) (ADT t Expr) r
- deconstructADT :: forall t r. (ConstructableADT t, Table Expr r) => DeconstructADT t r
- type InsertADT t name = GGInsert 'Sum name (ADTRep t) (ADT t Insert)
- insertADT :: forall t name. BuildableADT t name => InsertADT t name
- type NameADT t = GGName 'Sum (ADTRep t) (ADT t Name)
- nameADT :: forall t. ConstructableADT t => NameADT t
- type AggregateADT t = forall r. GGAggregate 'Sum (ADTRep t) r
- aggregateADT :: forall t. ConstructableADT t => AggregateADT t -> ADT t Expr -> ADT t Aggregate
- data HKD a f
- class (Generic a, HTable (GColumns (HKD a)), KnownAlgebra (GAlgebra (Rep a)), Eval (GGTable (GAlgebra (Rep a)) (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRecord (GMap (TColumn (Reify Result)) (Rep a)))), Eval (GGContext (GAlgebra (Rep a)) TUnreifyContext (GRecord (GMap (TColumn (Reify Result)) (Rep a)))) ~ Result, GRecordable (GMap (TColumn (Reify Result)) (Rep a)), GMappable Top (Rep a), GMappable (TTable (Reify Result)) (GMap (TColumn (Reify Result)) (Rep a)), GMap TUnreify (GMap (TColumn (Reify Result)) (Rep a)) ~ GMap (TColumn Result) (Rep a)) => HKDable a
- fromHKD :: HKDable a => HKD a Result -> a
- toHKD :: HKDable a => a -> HKD a Result
- type BuildHKD a name = GGBuild (GAlgebra (Rep a)) name (HKDRep a) (HKD a Expr)
- buildHKD :: forall a name. BuildableHKD a name => BuildHKD a name
- type ConstructHKD a = forall r. GGConstruct (GAlgebra (Rep a)) (HKDRep a) r
- constructHKD :: forall a. ConstructableHKD a => ConstructHKD a -> HKD a Expr
- type DeconstructHKD a r = GGDeconstruct (GAlgebra (Rep a)) (HKDRep a) (HKD a Expr) r
- deconstructHKD :: forall a r. (ConstructableHKD a, Table Expr r) => DeconstructHKD a r
- type InsertHKD a name = GGInsert (GAlgebra (Rep a)) name (HKDRep a) (HKD a Insert)
- insertHKD :: forall a name. BuildableHKD a name => InsertHKD a name
- type NameHKD a = GGName (GAlgebra (Rep a)) (HKDRep a) (HKD a Name)
- nameHKD :: forall a. ConstructableHKD a => NameHKD a
- type AggregateHKD a = forall r. GGAggregate (GAlgebra (Rep a)) (HKDRep a) r
- aggregateHKD :: forall a. ConstructableHKD a => AggregateHKD a -> HKD a Expr -> HKD a Aggregate
- data TableSchema names = TableSchema {}
- data Name a
- namesFromLabels :: Table Name a => a
- namesFromLabelsWith :: Table Name a => (NonEmpty String -> String) -> a
- data Expr a
- class (constraint (Unnullify a), Nullable a) => Sql constraint a
- litExpr :: Sql DBType a => a -> Expr a
- unsafeCastExpr :: Sql DBType b => Expr a -> Expr b
- null :: DBType a => Expr (Maybe a)
- nullify :: NotNull a => Expr a -> Expr (Maybe a)
- nullable :: Table Expr b => b -> (Expr a -> b) -> Expr (Maybe a) -> b
- isNull :: Expr (Maybe a) -> Expr Bool
- isNonNull :: Expr (Maybe a) -> Expr Bool
- mapNull :: DBType b => (Expr a -> Expr b) -> Expr (Maybe a) -> Expr (Maybe b)
- liftOpNull :: DBType c => (Expr a -> Expr b -> Expr c) -> Expr (Maybe a) -> Expr (Maybe b) -> Expr (Maybe c)
- catNull :: Expr (Maybe a) -> Query (Expr a)
- coalesce :: Expr (Maybe Bool) -> Expr Bool
- class DBType a => DBEq a
- true :: Expr Bool
- false :: Expr Bool
- not_ :: Expr Bool -> Expr Bool
- (&&.) :: Expr Bool -> Expr Bool -> Expr Bool
- and_ :: Foldable f => f (Expr Bool) -> Expr Bool
- (||.) :: Expr Bool -> Expr Bool -> Expr Bool
- or_ :: Foldable f => f (Expr Bool) -> Expr Bool
- (==.) :: forall a. Sql DBEq a => Expr a -> Expr a -> Expr Bool
- (/=.) :: forall a. Sql DBEq a => Expr a -> Expr a -> Expr Bool
- (==?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
- (/=?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
- in_ :: forall a f. (Sql DBEq a, Foldable f) => Expr a -> f (Expr a) -> Expr Bool
- boolExpr :: Expr a -> Expr a -> Expr Bool -> Expr a
- caseExpr :: [(Expr Bool, Expr a)] -> Expr a -> Expr a
- class DBEq a => DBOrd a
- (<.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool
- (<=.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool
- (>.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool
- (>=.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool
- (<?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
- (<=?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
- (>?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
- (>=?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool
- leastExpr :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr a
- greatestExpr :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr a
- class Function arg res
- function :: Function args result => String -> args -> result
- nullaryFunction :: Sql DBType a => String -> Expr a
- binaryOperator :: Sql DBType c => String -> Expr a -> Expr b -> Expr c
- data Query a
- showQuery :: Table Expr a => Query a -> String
- class Recontextualize Name Expr names exprs => Selects names exprs
- each :: Selects names exprs => TableSchema names -> Query exprs
- values :: (Table Expr a, Foldable f) => f a -> Query a
- filter :: (a -> Expr Bool) -> a -> Query a
- where_ :: Expr Bool -> Query ()
- whereExists :: Query a -> Query ()
- whereNotExists :: Query a -> Query ()
- distinct :: EqTable a => Query a -> Query a
- distinctOn :: EqTable b => (a -> b) -> Query a -> Query a
- distinctOnBy :: EqTable b => (a -> b) -> Order a -> Query a -> Query a
- limit :: Word -> Query a -> Query a
- offset :: Word -> Query a -> Query a
- union :: EqTable a => Query a -> Query a -> Query a
- unionAll :: Table Expr a => Query a -> Query a -> Query a
- intersect :: EqTable a => Query a -> Query a -> Query a
- intersectAll :: EqTable a => Query a -> Query a -> Query a
- except :: EqTable a => Query a -> Query a -> Query a
- exceptAll :: EqTable a => Query a -> Query a -> Query a
- exists :: Query a -> Query (Expr Bool)
- with :: (a -> Query b) -> a -> Query a
- withBy :: (a -> b -> Expr Bool) -> Query b -> a -> Query a
- without :: (a -> Query b) -> a -> Query a
- withoutBy :: (a -> b -> Expr Bool) -> Query b -> a -> Query a
- data Aggregate a
- class Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs
- aggregate :: Aggregates aggregates exprs => Query aggregates -> Query exprs
- countRows :: Query a -> Query (Expr Int64)
- groupBy :: forall exprs aggregates. (EqTable exprs, Aggregates aggregates exprs) => exprs -> aggregates
- listAgg :: Aggregates aggregates exprs => exprs -> ListTable aggregates
- listAggExpr :: Sql DBType a => Expr a -> Aggregate [a]
- nonEmptyAgg :: Aggregates aggregates exprs => exprs -> NonEmptyTable aggregates
- nonEmptyAggExpr :: Sql DBType a => Expr a -> Aggregate (NonEmpty a)
- class DBOrd a => DBMax a
- max :: Sql DBMax a => Expr a -> Aggregate a
- class DBOrd a => DBMin a
- min :: Sql DBMin a => Expr a -> Aggregate a
- class DBType a => DBSum a
- sum :: Sql DBSum a => Expr a -> Aggregate a
- sumWhere :: (Sql DBNum a, Sql DBSum a) => Expr Bool -> Expr a -> Aggregate a
- class DBType a => DBString a
- stringAgg :: Sql DBString a => Expr db -> Expr a -> Aggregate a
- count :: Expr a -> Aggregate Int64
- countStar :: Aggregate Int64
- countDistinct :: Sql DBEq a => Expr a -> Aggregate Int64
- countWhere :: Expr Bool -> Aggregate Int64
- and :: Expr Bool -> Aggregate Bool
- or :: Expr Bool -> Aggregate Bool
- orderBy :: Order a -> Query a -> Query a
- data Order a
- asc :: DBOrd a => Order (Expr a)
- desc :: DBOrd a => Order (Expr a)
- nullsFirst :: Order (Expr a) -> Order (Expr (Maybe a))
- nullsLast :: Order (Expr a) -> Order (Expr (Maybe a))
- class (ToExprs exprs a, a ~ FromExprs exprs) => Serializable exprs a | exprs -> a
- select :: forall exprs a. Serializable exprs a => Connection -> Query exprs -> IO [a]
- data Insert a where
- data OnConflict
- insert :: Connection -> Insert a -> IO a
- toInsert :: Inserts exprs inserts => exprs -> inserts
- toInsertDefaults :: Inserts exprs inserts => exprs -> inserts
- data Delete a where
- delete :: Connection -> Delete a -> IO a
- update :: Connection -> Update a -> IO a
- data Update a where
- data Returning names a where
- NumberOfRowsAffected :: Returning names Int64
- Projection :: (Selects names exprs, Serializable projection a) => (exprs -> projection) -> Returning names [a]
- createView :: Selects names exprs => TableSchema names -> Query exprs -> Connection -> IO ()
- class (Table from a, Table to b, Congruent a b, Recontextualize from from a a, Recontextualize to to b b, Recontextualize to from b a) => Recontextualize from to a b | a -> from, b -> to, a to -> b, b from -> a
- class Nullable' (IsMaybe a) a => Nullable a
- class (Nullable a, IsMaybe a ~ 'False) => NotNull a
- class HTable t
- class Interpretation context => Labelable context
- class Table Expr exprs => ToExprs exprs a where
- type family FromExprs a
- data Result a
- newtype HKDT a = HKDT {
- unHKDT :: a
Database types
DBType
class NotNull a => DBType a where Source #
Haskell types that can be represented as expressions in a database. There
should be an instance of DBType
for all column types in your database
schema (e.g., int
, timestamptz
, etc).
Rel8 comes with stock instances for most default types in PostgreSQL, so you should only need to derive instances of this class for custom database types, such as types defined in PostgreSQL extensions, or custom domain types.
Instances
Deriving-via helpers
JSONEncoded
newtype JSONEncoded a Source #
A deriving-via helper type for column types that store a Haskell value
using a JSON encoding described by aeson
's ToJSON
and FromJSON
type
classes.
Instances
(FromJSON a, ToJSON a) => DBType (JSONEncoded a) Source # | |
Defined in Rel8.Type.JSONEncoded |
newtype JSONBEncoded a Source #
Like JSONEncoded
, but works for jsonb
columns.
Instances
(FromJSON a, ToJSON a) => DBType (JSONBEncoded a) Source # | |
Defined in Rel8.Type.JSONBEncoded |
ReadShow
A deriving-via helper type for column types that store a Haskell value
using a Haskell's Read
and Show
type classes.
ReadShow | |
|
Instances
(Read a, Show a, Typeable a) => DBType (ReadShow a) Source # | |
Defined in Rel8.Type.ReadShow |
Generic
A deriving-via helper type for column types that store a Haskell product type in a single Postgres column using a Postgres composite type.
Note that this must map to a specific extant type in your database's schema
(created with CREATE TYPE
). Use DBComposite
to specify the name of this
Postgres type and the names of the individual fields (for projecting with
decompose
).
Instances
DBComposite a => DBType (Composite a) Source # | |
Defined in Rel8.Type.Composite | |
(DBComposite a, EqTable (HKD a (Expr :: X -> Type))) => DBEq (Composite a) Source # | |
Defined in Rel8.Type.Composite | |
(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBMin (Composite a) Source # | |
Defined in Rel8.Type.Composite | |
(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBMax (Composite a) Source # | |
Defined in Rel8.Type.Composite | |
(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBOrd (Composite a) Source # | |
Defined in Rel8.Type.Composite |
class (DBType a, HKDable a) => DBComposite a where Source #
compositeFields :: HKD a Name Source #
compositeTypeName :: String Source #
A deriving-via helper type for column types that store an "enum" type
(in Haskell terms, a sum type where all constructors are nullary) using a
Postgres enum
type.
Note that this should map to a specific type in your database's schema
(explicitly created with CREATE TYPE ... AS ENUM
). Use DBEnum
to
specify the name of this Postgres type and the names of the individual
values. If left unspecified, the names of the values of the Postgres
enum
are assumed to match exactly exactly the names of the constructors
of the Haskell type (up to and including case sensitivity).
Enum a |
Instances
DBEnum a => DBType (Enum a) Source # | |
Defined in Rel8.Type.Enum typeInformation :: TypeInformation (Enum a) Source # | |
DBEnum a => DBEq (Enum a) Source # | |
Defined in Rel8.Type.Enum | |
DBEnum a => DBMin (Enum a) Source # | |
Defined in Rel8.Type.Enum | |
DBEnum a => DBMax (Enum a) Source # | |
Defined in Rel8.Type.Enum | |
DBEnum a => DBOrd (Enum a) Source # | |
Defined in Rel8.Type.Enum |
class (Generic a, GEnumable (Rep a)) => Enumable a Source #
Instances
(Generic a, GEnumable (Rep a)) => Enumable a Source # | |
Defined in Rel8.Type.Enum |
TypeInformation
data TypeInformation a Source #
TypeInformation
describes how to encode and decode a Haskell type to and
from database queries. The typeName
is the name of the type in the
database, which is used to accurately type literals.
mapTypeInformation :: (a -> b) -> (b -> a) -> TypeInformation a -> TypeInformation b Source #
Simultaneously map over how a type is both encoded and decoded, while
retaining the name of the type. This operation is useful if you want to
essentially newtype
another DBType
.
The mapping is required to be total. If you have a partial mapping, see
parseTypeInformation
.
parseTypeInformation :: (a -> Either String b) -> (b -> a) -> TypeInformation a -> TypeInformation b Source #
Apply a parser to TypeInformation
.
This can be used if the data stored in the database should only be subset of
a given TypeInformation
. The parser is applied when deserializing rows
returned - the encoder assumes that the input data is already in the
appropriate form.
The DBType
hierarchy
class DBType a => DBSemigroup a where Source #
The class of DBType
s that form a semigroup. This class is purely a
Rel8 concept, and exists to mirror the Semigroup
class.
Instances
DBSemigroup ByteString Source # | |
DBSemigroup Text Source # | |
DBSemigroup ByteString Source # | |
DBSemigroup Text Source # | |
DBSemigroup CalendarDiffTime Source # | |
Sql DBType a => DBSemigroup [a] Source # | |
Sql DBType a => DBSemigroup (NonEmpty a) Source # | |
DBSemigroup (CI Text) Source # | |
DBSemigroup (CI Text) Source # | |
class DBSemigroup a => DBMonoid a where Source #
The class of DBType
s that form a semigroup. This class is purely a
Rel8 concept, and exists to mirror the Monoid
class.
memptyExpr :: Expr a Source #
Instances
DBMonoid ByteString Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr ByteString Source # | |
DBMonoid Text Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr Text Source # | |
DBMonoid ByteString Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr ByteString Source # | |
DBMonoid Text Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr Text Source # | |
DBMonoid CalendarDiffTime Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr CalendarDiffTime Source # | |
Sql DBType a => DBMonoid [a] Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr [a] Source # | |
DBMonoid (CI Text) Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr (CI Text) Source # | |
DBMonoid (CI Text) Source # | |
Defined in Rel8.Type.Monoid memptyExpr :: Expr (CI Text) Source # |
class DBType a => DBNum a Source #
The class of database types that support the +
, *
, -
operators, and
the abs
, negate
, sign
functions.
Instances
DBNum Double Source # | |
Defined in Rel8.Type.Num | |
DBNum Float Source # | |
Defined in Rel8.Type.Num | |
DBNum Int16 Source # | |
Defined in Rel8.Type.Num | |
DBNum Int32 Source # | |
Defined in Rel8.Type.Num | |
DBNum Int64 Source # | |
Defined in Rel8.Type.Num | |
DBNum Scientific Source # | |
Defined in Rel8.Type.Num |
class DBNum a => DBIntegral a Source #
The class of database types that can be coerced to from integral
expressions. This is a Rel8 concept, and allows us to provide
fromIntegral
.
Instances
DBIntegral Int16 Source # | |
Defined in Rel8.Type.Num | |
DBIntegral Int32 Source # | |
Defined in Rel8.Type.Num | |
DBIntegral Int64 Source # | |
Defined in Rel8.Type.Num |
class DBNum a => DBFractional a Source #
The class of database types that support the /
operator.
Instances
DBFractional Double Source # | |
Defined in Rel8.Type.Num | |
DBFractional Float Source # | |
Defined in Rel8.Type.Num | |
DBFractional Scientific Source # | |
Defined in Rel8.Type.Num |
class DBFractional a => DBFloating a Source #
The class of database types that support the /
operator.
Instances
DBFloating Double Source # | |
Defined in Rel8.Type.Num | |
DBFloating Float Source # | |
Defined in Rel8.Type.Num |
Tables and higher-kinded tables
class HTable (GColumns t) => Rel8able t Source #
This type class allows you to define custom Table
s using higher-kinded
data types. Higher-kinded data types are data types of the pattern:
data MyType f = MyType { field1 :: Column f T1 OR HK1 f , field2 :: Column f T2 OR HK2 f , ... , fieldN :: Column f Tn OR HKn f }
where Tn
is any Haskell type, and HKn
is any higher-kinded type.
That is, higher-kinded data are records where all fields in the record are
all either of the type Column f T
(for any T
), or are themselves
higher-kinded data:
- Nested
data Nested f = Nested { nested1 :: MyType f , nested2 :: MyType f }
The Rel8able
type class is used to give us a special mapping operation
that lets us change the type parameter f
.
- Supplying
Rel8able
instances
This type class should be derived generically for all table types in your
project. To do this, enable the DeriveAnyType
and DeriveGeneric
language
extensions:
{-# LANGUAGE DeriveAnyClass, DeriveGeneric #-} data MyType f = MyType { fieldA :: Column f T } deriving ( GHC.Generics.Generic, Rel8able )
Instances
HKDable a => Rel8able (HKD a) Source # | |
Defined in Rel8.Table.HKD type GColumns (HKD a) :: HTable gfromColumns :: forall (context :: Context). (Labelable context, Reifiable context) => GColumns (HKD a) (Col (Reify context)) -> HKD a (Reify context) gtoColumns :: forall (context :: Context). (Labelable context, Reifiable context) => HKD a (Reify context) -> GColumns (HKD a) (Col (Reify context)) greify :: forall (context :: Context). (Labelable context, Reifiable context) => HKD a context -> HKD a (Reify context) gunreify :: forall (context :: Context). (Labelable context, Reifiable context) => HKD a (Reify context) -> HKD a context | |
ADTable t => Rel8able (ADT t) Source # | |
Defined in Rel8.Table.ADT type GColumns (ADT t) :: HTable gfromColumns :: forall (context :: Context). (Labelable context, Reifiable context) => GColumns (ADT t) (Col (Reify context)) -> ADT t (Reify context) gtoColumns :: forall (context :: Context). (Labelable context, Reifiable context) => ADT t (Reify context) -> GColumns (ADT t) (Col (Reify context)) greify :: forall (context :: Context). (Labelable context, Reifiable context) => ADT t context -> ADT t (Reify context) gunreify :: forall (context :: Context). (Labelable context, Reifiable context) => ADT t (Reify context) -> ADT t context |
type Column context a = Field context 'Required a Source #
The Column
type family should be used to indicate which fields of your
data types are single columns in queries. This type family has special
support when a query is executed, allowing you to use a single data type for
both query data and rows decoded to Haskell.
type family HEither context where ... Source #
HEither (Reify context) = AHEither context | |
HEither Aggregate = EitherTable | |
HEither Expr = EitherTable | |
HEither Insert = EitherTable | |
HEither Name = EitherTable | |
HEither Result = Either |
type family HMaybe context where ... Source #
HMaybe (Reify context) = AHMaybe context | |
HMaybe Aggregate = MaybeTable | |
HMaybe Expr = MaybeTable | |
HMaybe Insert = MaybeTable | |
HMaybe Name = MaybeTable | |
HMaybe Result = Maybe |
type family HNonEmpty context where ... Source #
HNonEmpty (Reify context) = AHNonEmpty context | |
HNonEmpty Aggregate = NonEmptyTable | |
HNonEmpty Expr = NonEmptyTable | |
HNonEmpty Insert = NonEmptyTable | |
HNonEmpty Name = NonEmptyTable | |
HNonEmpty Result = NonEmpty |
type family HThese context where ... Source #
HThese (Reify context) = AHThese context | |
HThese Aggregate = TheseTable | |
HThese Expr = TheseTable | |
HThese Insert = TheseTable | |
HThese Name = TheseTable | |
HThese Result = These |
class (HTable (Columns a), context ~ Context a) => Table context a | a -> context where Source #
Table
s are one of the foundational elements of Rel8, and describe data
types that have a finite number of columns. Each of these columns contains
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 Expr
context), aggregations (the
Aggregate
context), insert values (the Insert
contex), among
others.
In typical usage of Rel8 you don't need to derive instances of Table
yourself, as anything that's an instance of Rel8able
is always a
Table
.
Nothing
type Columns a :: HTable Source #
The HTable
functor that describes the schema of this table.
type Columns a = Eval (GGColumns (GAlgebra (Rep (Record a))) TColumns (Rep (Record a)))
type Context a :: Context Source #
The common context that all columns use as an interpretation.
type Context a = Eval (GGContext (GAlgebra (Rep (Record a))) TContext (Rep (Record a)))
type Unreify a :: Type Source #
type Unreify a = DefaultUnreify a
toColumns :: a -> Columns a (Col context) Source #
default toColumns :: (Generic (Record a), KnownAlgebra (GAlgebra (Rep (Record a))), Eval (GGTable (GAlgebra (Rep (Record a))) (TTable context) TColumns (Col context) (Rep (Record a))), Columns a ~ Eval (GGColumns (GAlgebra (Rep (Record a))) TColumns (Rep (Record a))), Context a ~ Eval (GGContext (GAlgebra (Rep (Record a))) TContext (Rep (Record a)))) => a -> Columns a (Col context) Source #
fromColumns :: Columns a (Col context) -> a Source #
default fromColumns :: (Generic (Record a), KnownAlgebra (GAlgebra (Rep (Record a))), Eval (GGTable (GAlgebra (Rep (Record a))) (TTable context) TColumns (Col context) (Rep (Record a))), Columns a ~ Eval (GGColumns (GAlgebra (Rep (Record a))) TColumns (Rep (Record a))), Context a ~ Eval (GGContext (GAlgebra (Rep (Record a))) TContext (Rep (Record a)))) => Columns a (Col context) -> a Source #
reify :: (context :~: Reify ctx) -> Unreify a -> a Source #
default reify :: (Generic (Record a), Generic (Record (Unreify a)), GMappable (TTable context) (Rep (Record a)), Rep (Record (Unreify a)) ~ GMap TUnreify (Rep (Record a))) => (context :~: Reify ctx) -> Unreify a -> a Source #
unreify :: (context :~: Reify ctx) -> a -> Unreify a Source #
Instances
(Table context a, Labelable context, Nullifiable context, ConstrainTag context MaybeTag) => Table context (MaybeTable a) Source # | |
Defined in Rel8.Table.Maybe type Columns (MaybeTable a) :: HTable Source # type Context (MaybeTable a) :: Context Source # type Unreify (MaybeTable a) Source # toColumns :: MaybeTable a -> Columns (MaybeTable a) (Col context) Source # fromColumns :: Columns (MaybeTable a) (Col context) -> MaybeTable a Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (MaybeTable a) -> MaybeTable a Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> MaybeTable a -> Unreify (MaybeTable a) Source # | |
(Table context a, Unreifies context a) => Table context (NonEmptyTable a) Source # | |
Defined in Rel8.Table.NonEmpty type Columns (NonEmptyTable a) :: HTable Source # type Context (NonEmptyTable a) :: Context Source # type Unreify (NonEmptyTable a) Source # toColumns :: NonEmptyTable a -> Columns (NonEmptyTable a) (Col context) Source # fromColumns :: Columns (NonEmptyTable a) (Col context) -> NonEmptyTable a Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (NonEmptyTable a) -> NonEmptyTable a Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> NonEmptyTable a -> Unreify (NonEmptyTable a) Source # | |
(Table context a, Unreifies context a) => Table context (ListTable a) Source # | |
Defined in Rel8.Table.List toColumns :: ListTable a -> Columns (ListTable a) (Col context) Source # fromColumns :: Columns (ListTable a) (Col context) -> ListTable a Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (ListTable a) -> ListTable a Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> ListTable a -> Unreify (ListTable a) Source # | |
(Rel8able t, Labelable context, Reifiable context) => Table context (t context) Source # | |
Defined in Rel8.Table.Rel8able toColumns :: t context -> Columns (t context) (Col context) Source # fromColumns :: Columns (t context) (Col context) -> t context Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (t context) -> t context Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> t context -> Unreify (t context) Source # | |
Table Result a => Table Result [a] Source # | |
Defined in Rel8.Table | |
Table Result a => Table Result (Maybe a) Source # | |
Defined in Rel8.Table toColumns :: Maybe a -> Columns (Maybe a) (Col Result) Source # fromColumns :: Columns (Maybe a) (Col Result) -> Maybe a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (Maybe a) -> Maybe a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Maybe a -> Unreify (Maybe a) Source # | |
Table Result a => Table Result (NonEmpty a) Source # | |
Defined in Rel8.Table toColumns :: NonEmpty a -> Columns (NonEmpty a) (Col Result) Source # fromColumns :: Columns (NonEmpty a) (Col Result) -> NonEmpty a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (NonEmpty a) -> NonEmpty a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> NonEmpty a -> Unreify (NonEmpty a) Source # | |
Sql DBType a => Table Result (Identity a) Source # | |
Defined in Rel8.Table toColumns :: Identity a -> Columns (Identity a) (Col Result) Source # fromColumns :: Columns (Identity a) (Col Result) -> Identity a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (Identity a) -> Identity a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Identity a -> Unreify (Identity a) Source # | |
HKDable a => Table Result (HKDT a) Source # | |
Defined in Rel8.Table.HKD toColumns :: HKDT a -> Columns (HKDT a) (Col Result) Source # fromColumns :: Columns (HKDT a) (Col Result) -> HKDT a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (HKDT a) -> HKDT a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> HKDT a -> Unreify (HKDT a) Source # | |
(Table context a, Table context b, Labelable context) => Table context (a, b) Source # | |
Defined in Rel8.Table toColumns :: (a, b) -> Columns (a, b) (Col context) Source # fromColumns :: Columns (a, b) (Col context) -> (a, b) Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (a, b) -> (a, b) Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> (a, b) -> Unreify (a, b) Source # | |
(Table context a, Table context b, Labelable context, Nullifiable context, ConstrainTag context MaybeTag) => Table context (TheseTable a b) Source # | |
Defined in Rel8.Table.These type Columns (TheseTable a b) :: HTable Source # type Context (TheseTable a b) :: Context Source # type Unreify (TheseTable a b) Source # toColumns :: TheseTable a b -> Columns (TheseTable a b) (Col context) Source # fromColumns :: Columns (TheseTable a b) (Col context) -> TheseTable a b Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (TheseTable a b) -> TheseTable a b Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> TheseTable a b -> Unreify (TheseTable a b) Source # | |
(Table context a, Table context b, Labelable context, Nullifiable context, ConstrainTag context EitherTag) => Table context (EitherTable a b) Source # | |
Defined in Rel8.Table.Either type Columns (EitherTable a b) :: HTable Source # type Context (EitherTable a b) :: Context Source # type Unreify (EitherTable a b) Source # toColumns :: EitherTable a b -> Columns (EitherTable a b) (Col context) Source # fromColumns :: Columns (EitherTable a b) (Col context) -> EitherTable a b Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (EitherTable a b) -> EitherTable a b Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> EitherTable a b -> Unreify (EitherTable a b) Source # | |
(Table Result a, Table Result b) => Table Result (Either a b) Source # | |
Defined in Rel8.Table toColumns :: Either a b -> Columns (Either a b) (Col Result) Source # fromColumns :: Columns (Either a b) (Col Result) -> Either a b Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (Either a b) -> Either a b Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Either a b -> Unreify (Either a b) Source # | |
(Table Result a, Table Result b) => Table Result (These a b) Source # | |
Defined in Rel8.Table toColumns :: These a b -> Columns (These a b) (Col Result) Source # fromColumns :: Columns (These a b) (Col Result) -> These a b Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (These a b) -> These a b Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> These a b -> Unreify (These a b) Source # | |
(Table context a, Table context b, Table context c, Labelable context) => Table context (a, b, c) Source # | |
Defined in Rel8.Table toColumns :: (a, b, c) -> Columns (a, b, c) (Col context) Source # fromColumns :: Columns (a, b, c) (Col context) -> (a, b, c) Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (a, b, c) -> (a, b, c) Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> (a, b, c) -> Unreify (a, b, c) Source # | |
(Table context a, Table context b, Table context c, Table context d, Labelable context) => Table context (a, b, c, d) Source # | |
Defined in Rel8.Table toColumns :: (a, b, c, d) -> Columns (a, b, c, d) (Col context) Source # fromColumns :: Columns (a, b, c, d) (Col context) -> (a, b, c, d) Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (a, b, c, d) -> (a, b, c, d) Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> (a, b, c, d) -> Unreify (a, b, c, d) Source # | |
(Table context a, Table context b, Table context c, Table context d, Table context e, Labelable context) => Table context (a, b, c, d, e) Source # | |
Defined in Rel8.Table toColumns :: (a, b, c, d, e) -> Columns (a, b, c, d, e) (Col context) Source # fromColumns :: Columns (a, b, c, d, e) (Col context) -> (a, b, c, d, e) Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (a, b, c, d, e) -> (a, b, c, d, e) Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> (a, b, c, d, e) -> Unreify (a, b, c, d, e) Source # | |
(Table context a, Table context b, Table context c, Table context d, Table context e, Table context f, Labelable context) => Table context (a, b, c, d, e, f) Source # | |
Defined in Rel8.Table type Columns (a, b, c, d, e, f) :: HTable Source # toColumns :: (a, b, c, d, e, f) -> Columns (a, b, c, d, e, f) (Col context) Source # fromColumns :: Columns (a, b, c, d, e, f) (Col context) -> (a, b, c, d, e, f) Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> (a, b, c, d, e, f) -> Unreify (a, b, c, d, e, f) Source # | |
(Table context a, Table context b, Table context c, Table context d, Table context e, Table context f, Table context g, Labelable context) => Table context (a, b, c, d, e, f, g) Source # | |
Defined in Rel8.Table type Columns (a, b, c, d, e, f, g) :: HTable Source # toColumns :: (a, b, c, d, e, f, g) -> Columns (a, b, c, d, e, f, g) (Col context) Source # fromColumns :: Columns (a, b, c, d, e, f, g) (Col context) -> (a, b, c, d, e, f, g) Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> (a, b, c, d, e, f, g) -> Unreify (a, b, c, d, e, f, g) Source # |
class AltTable f where Source #
Like Alt
in Haskell. This class is purely a Rel8 concept, and allows you
to take a choice between two tables. See also AlternativeTable
.
For example, using <|>:
on MaybeTable
allows you to combine two
tables and to return the first one that is a "just" MaybeTable.
(<|>:) :: Table Expr a => f a -> f a -> f a infixl 3 Source #
An associative binary operation on Table
s.
Instances
AltTable Query Source # | |
AltTable MaybeTable Source # | |
Defined in Rel8.Table.Maybe (<|>:) :: Table Expr a => MaybeTable a -> MaybeTable a -> MaybeTable a Source # | |
AltTable NonEmptyTable Source # | |
Defined in Rel8.Table.NonEmpty (<|>:) :: Table Expr a => NonEmptyTable a -> NonEmptyTable a -> NonEmptyTable a Source # | |
AltTable ListTable Source # | |
EqTable k => AltTable (Tabulation k) Source # | |
Defined in Rel8.Tabulate (<|>:) :: Table Expr a => Tabulation k a -> Tabulation k a -> Tabulation k a Source # |
class AltTable f => AlternativeTable f where Source #
Like Alternative
in Haskell, some Table
s form a monoid on applicative
functors.
Instances
AlternativeTable Query Source # |
|
Defined in Rel8.Query | |
AlternativeTable MaybeTable Source # | |
Defined in Rel8.Table.Maybe emptyTable :: Table Expr a => MaybeTable a Source # | |
AlternativeTable ListTable Source # | |
Defined in Rel8.Table.List | |
EqTable k => AlternativeTable (Tabulation k) Source # | |
Defined in Rel8.Tabulate emptyTable :: Table Expr a => Tabulation k a Source # |
class Table Expr a => EqTable a Source #
The class of Table
s that can be compared for equality. Equality on
tables is defined by equality of all columns all columns, so this class
means "all columns in a Table
have an instance of DBEq
".
Instances
(==:) :: forall a. EqTable a => a -> a -> Expr Bool infix 4 Source #
Compare two Table
s for equality. This corresponds to comparing all
columns inside each table for equality, and combining all comparisons with
AND
.
(/=:) :: forall a. EqTable a => a -> a -> Expr Bool infix 4 Source #
Test if two Table
s are different. This corresponds to comparing all
columns inside each table for inequality, and combining all comparisons with
OR
.
class EqTable a => OrdTable a Source #
The class of Table
s that can be ordered. Ordering on tables is defined
by their lexicographic ordering of all columns, so this class means "all
columns in a Table
have an instance of DBOrd
".
Instances
ascTable :: forall a. OrdTable a => Order a Source #
Construct an Order
for a Table
by sorting all columns into ascending
orders (any nullable columns will be sorted with NULLS FIRST
).
descTable :: forall a. OrdTable a => Order a Source #
Construct an Order
for a Table
by sorting all columns into descending
orders (any nullable columns will be sorted with NULLS LAST
).
lit :: forall exprs a. Serializable exprs a => a -> exprs Source #
Use lit
to turn literal Haskell values into expressions. lit
is
capable of lifting single Expr
s to full tables.
bool :: Table Expr a => a -> a -> Expr Bool -> a Source #
An if-then-else expression on tables.
bool x y p
returns x
if p
is False
, and returns y
if p
is
True
.
case_ :: Table Expr a => [(Expr Bool, a)] -> a -> a Source #
Produce a table expression from a list of alternatives. Returns the first
table where the Expr Bool
expression is True
. If no alternatives are
true, the given default is returned.
MaybeTable
data MaybeTable a Source #
MaybeTable t
is the table t
, but as the result of an outer join. If
the outer join fails to match any rows, this is essentialy Nothing
, and if
the outer join does match rows, this is like Just
. Unfortunately, SQL
makes it impossible to distinguish whether or not an outer join matched any
rows based generally on the row contents - if you were to join a row
entirely of nulls, you can't distinguish if you matched an all null row, or
if the match failed. For this reason MaybeTable
contains an extra field -
a "nullTag" - to track whether or not the outer join produced any rows.
Instances
maybeTable :: Table Expr b => b -> (a -> b) -> MaybeTable a -> b Source #
Perform case analysis on a MaybeTable
. Like maybe
.
($?) :: forall a b. Sql DBType b => (a -> Expr b) -> MaybeTable a -> Expr (Nullify b) infixl 4 Source #
Project a single expression out of a MaybeTable
. You can think of this
operator like the $
operator, but it also has the ability to return
null
.
nothingTable :: Table Expr a => MaybeTable a Source #
The null table. Like Nothing
.
justTable :: a -> MaybeTable a Source #
Lift any table into MaybeTable
. Like Just
. Note you can also use
pure
.
isNothingTable :: MaybeTable a -> Expr Bool Source #
Check if a MaybeTable
is absent of any row. Like isNothing
.
isJustTable :: MaybeTable a -> Expr Bool Source #
Check if a MaybeTable
contains a row. Like isJust
.
optional :: Query a -> Query (MaybeTable a) Source #
Convert a query that might return zero rows to a query that always returns at least one row.
To speak in more concrete terms, optional
is most useful to write LEFT
JOIN
s.
catMaybeTable :: MaybeTable a -> Query a Source #
Filter out MaybeTable
s, returning only the tables that are not-null.
This operation can be used to "undo" the effect of optional
, which
operationally is like turning a LEFT JOIN
back into a full JOIN
. You
can think of this as analogous to catMaybes
.
bindMaybeTable :: Monad m => (a -> m (MaybeTable b)) -> MaybeTable a -> m (MaybeTable b) Source #
bindMaybeTable f x
is similar to the monadic bind (>>=
) operation. It
allows you to "extend" an optional query with another query. If either the
input or output are nothingTable
, then the result is
nothingTable
.
This is similar to traverseMaybeTable
, followed by a join
on the
resulting MaybeTable
s.
traverseMaybeTable :: (a -> Query b) -> MaybeTable a -> Query (MaybeTable b) Source #
Extend an optional query with another query. This is useful if you want
to step through multiple LEFT JOINs
.
Note that traverseMaybeTable
takes a a -> Query b
function, which means
you also have the ability to "expand" one row into multiple rows. If the
a -> Query b
function returns no rows, then the resulting query will also
have no rows. However, regardless of the given a -> Query b
function, if
the input is noTable
, you will always get exactly one noTable
back.
insertMaybeTable :: Table Insert a => Maybe a -> MaybeTable a Source #
nameMaybeTable :: Name (Maybe MaybeTag) -> a -> MaybeTable a Source #
EitherTable
data EitherTable a b Source #
Instances
Bifunctor EitherTable Source # | |
Defined in Rel8.Table.Either bimap :: (a -> b) -> (c -> d) -> EitherTable a c -> EitherTable b d first :: (a -> b) -> EitherTable a c -> EitherTable b c second :: (b -> c) -> EitherTable a b -> EitherTable a c | |
(Nullifiable from, Labelable from, ConstrainTag from EitherTag, Nullifiable to, Labelable to, ConstrainTag to EitherTag, Recontextualize from to a1 b1, Recontextualize from to a2 b2) => Recontextualize from to (EitherTable a1 a2) (EitherTable b1 b2) Source # | |
Defined in Rel8.Table.Either | |
(Table context a, Table context b, Labelable context, Nullifiable context, ConstrainTag context EitherTag) => Table context (EitherTable a b) Source # | |
Defined in Rel8.Table.Either type Columns (EitherTable a b) :: HTable Source # type Context (EitherTable a b) :: Context Source # type Unreify (EitherTable a b) Source # toColumns :: EitherTable a b -> Columns (EitherTable a b) (Col context) Source # fromColumns :: Columns (EitherTable a b) (Col context) -> EitherTable a b Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (EitherTable a b) -> EitherTable a b Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> EitherTable a b -> Unreify (EitherTable a b) Source # | |
Table (Expr :: X -> Type) a => Monad (EitherTable a) Source # | |
Defined in Rel8.Table.Either (>>=) :: EitherTable a a0 -> (a0 -> EitherTable a b) -> EitherTable a b (>>) :: EitherTable a a0 -> EitherTable a b -> EitherTable a b return :: a0 -> EitherTable a a0 | |
Functor (EitherTable a) Source # | |
Defined in Rel8.Table.Either fmap :: (a0 -> b) -> EitherTable a a0 -> EitherTable a b (<$) :: a0 -> EitherTable a b -> EitherTable a a0 | |
Table (Expr :: X -> Type) a => Applicative (EitherTable a) Source # | |
Defined in Rel8.Table.Either pure :: a0 -> EitherTable a a0 (<*>) :: EitherTable a (a0 -> b) -> EitherTable a a0 -> EitherTable a b liftA2 :: (a0 -> b -> c) -> EitherTable a a0 -> EitherTable a b -> EitherTable a c (*>) :: EitherTable a a0 -> EitherTable a b -> EitherTable a b (<*) :: EitherTable a a0 -> EitherTable a b -> EitherTable a a0 | |
Table (Expr :: X -> Type) a => Apply (EitherTable a) Source # | |
Defined in Rel8.Table.Either (<.>) :: EitherTable a (a0 -> b) -> EitherTable a a0 -> EitherTable a b (.>) :: EitherTable a a0 -> EitherTable a b -> EitherTable a b (<.) :: EitherTable a a0 -> EitherTable a b -> EitherTable a a0 liftF2 :: (a0 -> b -> c) -> EitherTable a a0 -> EitherTable a b -> EitherTable a c | |
Table (Expr :: X -> Type) a => Bind (EitherTable a) Source # | |
Defined in Rel8.Table.Either (>>-) :: EitherTable a a0 -> (a0 -> EitherTable a b) -> EitherTable a b join :: EitherTable a (EitherTable a a0) -> EitherTable a a0 | |
(Table (Expr :: X -> Type) a, Table (Expr :: X -> Type) b) => Semigroup (EitherTable a b) Source # | |
Defined in Rel8.Table.Either (<>) :: EitherTable a b -> EitherTable a b -> EitherTable a b sconcat :: NonEmpty (EitherTable a b) -> EitherTable a b stimes :: Integral b0 => b0 -> EitherTable a b -> EitherTable a b | |
(EqTable a, EqTable b) => EqTable (EitherTable a b) Source # | |
Defined in Rel8.Table.Either eqTable :: Columns (EitherTable a b) (Dict (ConstrainDBType DBEq)) | |
(OrdTable a, OrdTable b) => OrdTable (EitherTable a b) Source # | |
Defined in Rel8.Table.Either ordTable :: Columns (EitherTable a b) (Dict (ConstrainDBType DBOrd)) | |
type Columns (EitherTable a b) Source # | |
Defined in Rel8.Table.Either | |
type Context (EitherTable a b) Source # | |
Defined in Rel8.Table.Either | |
type Unreify (EitherTable a b) Source # | |
Defined in Rel8.Table.Either | |
type FromExprs (EitherTable a b) Source # | |
Defined in Rel8.Table.Either |
eitherTable :: Table Expr c => (a -> c) -> (b -> c) -> EitherTable a b -> c Source #
rightTable :: Table Expr a => b -> EitherTable a b Source #
isLeftTable :: EitherTable a b -> Expr Bool Source #
isRightTable :: EitherTable a b -> Expr Bool Source #
keepLeftTable :: EitherTable a b -> Query a Source #
keepRightTable :: EitherTable a b -> Query b Source #
bindEitherTable :: (Table Expr a, Functor m) => (i -> m (EitherTable a b)) -> EitherTable a i -> m (EitherTable a b) Source #
bitraverseEitherTable :: (a -> Query c) -> (b -> Query d) -> EitherTable a b -> Query (EitherTable c d) Source #
insertEitherTable :: (Table Insert a, Table Insert b) => Either a b -> EitherTable a b Source #
nameEitherTable :: Name EitherTag -> a -> b -> EitherTable a b Source #
TheseTable
data TheseTable a b Source #
Instances
Bifunctor TheseTable Source # | |
Defined in Rel8.Table.These bimap :: (a -> b) -> (c -> d) -> TheseTable a c -> TheseTable b d first :: (a -> b) -> TheseTable a c -> TheseTable b c second :: (b -> c) -> TheseTable a b -> TheseTable a c | |
(Labelable from, Nullifiable from, ConstrainTag from MaybeTag, Labelable to, Nullifiable to, ConstrainTag to MaybeTag, Recontextualize from to a1 b1, Recontextualize from to a2 b2) => Recontextualize from to (TheseTable a1 a2) (TheseTable b1 b2) Source # | |
Defined in Rel8.Table.These | |
(Table context a, Table context b, Labelable context, Nullifiable context, ConstrainTag context MaybeTag) => Table context (TheseTable a b) Source # | |
Defined in Rel8.Table.These type Columns (TheseTable a b) :: HTable Source # type Context (TheseTable a b) :: Context Source # type Unreify (TheseTable a b) Source # toColumns :: TheseTable a b -> Columns (TheseTable a b) (Col context) Source # fromColumns :: Columns (TheseTable a b) (Col context) -> TheseTable a b Source # reify :: forall (ctx :: Context). (context :~: Reify ctx) -> Unreify (TheseTable a b) -> TheseTable a b Source # unreify :: forall (ctx :: Context). (context :~: Reify ctx) -> TheseTable a b -> Unreify (TheseTable a b) Source # | |
(Table (Expr :: X -> Type) a, Semigroup a) => Monad (TheseTable a) Source # | |
Defined in Rel8.Table.These (>>=) :: TheseTable a a0 -> (a0 -> TheseTable a b) -> TheseTable a b (>>) :: TheseTable a a0 -> TheseTable a b -> TheseTable a b return :: a0 -> TheseTable a a0 | |
Functor (TheseTable a) Source # | |
Defined in Rel8.Table.These fmap :: (a0 -> b) -> TheseTable a a0 -> TheseTable a b (<$) :: a0 -> TheseTable a b -> TheseTable a a0 | |
(Table (Expr :: X -> Type) a, Semigroup a) => Applicative (TheseTable a) Source # | |
Defined in Rel8.Table.These pure :: a0 -> TheseTable a a0 (<*>) :: TheseTable a (a0 -> b) -> TheseTable a a0 -> TheseTable a b liftA2 :: (a0 -> b -> c) -> TheseTable a a0 -> TheseTable a b -> TheseTable a c (*>) :: TheseTable a a0 -> TheseTable a b -> TheseTable a b (<*) :: TheseTable a a0 -> TheseTable a b -> TheseTable a a0 | |
(Table (Expr :: X -> Type) a, Semigroup a) => Apply (TheseTable a) Source # | |
Defined in Rel8.Table.These (<.>) :: TheseTable a (a0 -> b) -> TheseTable a a0 -> TheseTable a b (.>) :: TheseTable a a0 -> TheseTable a b -> TheseTable a b (<.) :: TheseTable a a0 -> TheseTable a b -> TheseTable a a0 liftF2 :: (a0 -> b -> c) -> TheseTable a a0 -> TheseTable a b -> TheseTable a c | |
(Table (Expr :: X -> Type) a, Semigroup a) => Bind (TheseTable a) Source # | |
Defined in Rel8.Table.These (>>-) :: TheseTable a a0 -> (a0 -> TheseTable a b) -> TheseTable a b join :: TheseTable a (TheseTable a a0) -> TheseTable a a0 | |
(Table (Expr :: X -> Type) a, Table (Expr :: X -> Type) b, Semigroup a, Semigroup b) => Semigroup (TheseTable a b) Source # | |
Defined in Rel8.Table.These (<>) :: TheseTable a b -> TheseTable a b -> TheseTable a b sconcat :: NonEmpty (TheseTable a b) -> TheseTable a b stimes :: Integral b0 => b0 -> TheseTable a b -> TheseTable a b | |
(EqTable a, EqTable b) => EqTable (TheseTable a b) Source # | |
Defined in Rel8.Table.These eqTable :: Columns (TheseTable a b) (Dict (ConstrainDBType DBEq)) | |
(OrdTable a, OrdTable b) => OrdTable (TheseTable a b) Source # | |
Defined in Rel8.Table.These ordTable :: Columns (TheseTable a b) (Dict (ConstrainDBType DBOrd)) | |
type Columns (TheseTable a b) Source # | |
Defined in Rel8.Table.These | |
type Context (TheseTable a b) Source # | |
Defined in Rel8.Table.These | |
type Unreify (TheseTable a b) Source # | |
Defined in Rel8.Table.These | |
type FromExprs (TheseTable a b) Source # | |
Defined in Rel8.Table.These |
theseTable :: Table Expr c => (a -> c) -> (b -> c) -> (a -> b -> c) -> TheseTable a b -> c Source #
thoseTable :: a -> b -> TheseTable a b Source #
isThisTable :: TheseTable a b -> Expr Bool Source #
isThatTable :: TheseTable a b -> Expr Bool Source #
isThoseTable :: TheseTable a b -> Expr Bool Source #
hasHereTable :: TheseTable a b -> Expr Bool Source #
hasThereTable :: TheseTable a b -> Expr Bool Source #
justHereTable :: TheseTable a b -> MaybeTable a Source #
justThereTable :: TheseTable a b -> MaybeTable b Source #
alignBy :: (Table Expr a, Table Expr b) => (a -> b -> Expr Bool) -> Query a -> Query b -> Query (TheseTable a b) Source #
Corresponds to a FULL OUTER JOIN
between two queries.
keepHereTable :: TheseTable a b -> Query (a, MaybeTable b) Source #
loseHereTable :: TheseTable a b -> Query b Source #
keepThereTable :: TheseTable a b -> Query (MaybeTable a, b) Source #
loseThereTable :: TheseTable a b -> Query a Source #
keepThisTable :: TheseTable a b -> Query a Source #
loseThisTable :: TheseTable a b -> Query (MaybeTable a, b) Source #
keepThatTable :: TheseTable a b -> Query b Source #
loseThatTable :: TheseTable a b -> Query (a, MaybeTable b) Source #
keepThoseTable :: TheseTable a b -> Query (a, b) Source #
loseThoseTable :: TheseTable a b -> Query (EitherTable a b) Source #
bindTheseTable :: (Table Expr a, Semigroup a, Monad m) => (i -> m (TheseTable a b)) -> TheseTable a i -> m (TheseTable a b) Source #
bitraverseTheseTable :: (a -> Query c) -> (b -> Query d) -> TheseTable a b -> Query (TheseTable c d) Source #
insertTheseTable :: (Table Insert a, Table Insert b) => These a b -> TheseTable a b Source #
nameTheseTable :: Name (Maybe MaybeTag) -> Name (Maybe MaybeTag) -> a -> b -> TheseTable a b Source #
ListTable
A ListTable
value contains zero or more instances of a
. You construct
ListTable
s with many
or listAgg
.
Instances
insertListTable :: Inserts exprs inserts => [exprs] -> ListTable inserts Source #
many :: Table Expr a => Query a -> Query (ListTable a) Source #
Aggregate a Query
into a ListTable
. If the supplied query returns 0
rows, this function will produce a Query
that returns one row containing
the empty ListTable
. If the supplied Query
does return rows, many
will
return exactly one row, with a ListTable
collecting all returned rows.
many
is analogous to many
from
Control.Applicative
.
manyExpr :: Sql DBType a => Query (Expr a) -> Query (Expr [a]) Source #
A version of many
specialised to single expressions.
NonEmptyTable
data NonEmptyTable a Source #
A NonEmptyTable
value contains one or more instances of a
. You
construct NonEmptyTable
s with some
or nonEmptyAgg
.
Instances
nonEmptyTable :: Table Expr a => NonEmpty a -> NonEmptyTable a Source #
insertNonEmptyTable :: Inserts exprs inserts => NonEmpty exprs -> NonEmptyTable inserts Source #
nameNonEmptyTable :: Table Name a => a -> NonEmptyTable a Source #
some :: Table Expr a => Query a -> Query (NonEmptyTable a) Source #
Aggregate a Query
into a NonEmptyTable
. If the supplied query returns
0 rows, this function will produce a Query
that is empty - that is, will
produce zero NonEmptyTable
s. If the supplied Query
does return rows,
some
will return exactly one row, with a NonEmptyTable
collecting all
returned rows.
some
is analogous to some
from
Control.Applicative
.
someExpr :: Sql DBType a => Query (Expr a) -> Query (Expr (NonEmpty a)) Source #
A version of many
specialised to single expressions.
catNonEmptyTable :: Table Expr a => NonEmptyTable a -> Query a Source #
ADT
Instances
ADTable t => Rel8able (ADT t) Source # | |
Defined in Rel8.Table.ADT type GColumns (ADT t) :: HTable gfromColumns :: forall (context :: Context). (Labelable context, Reifiable context) => GColumns (ADT t) (Col (Reify context)) -> ADT t (Reify context) gtoColumns :: forall (context :: Context). (Labelable context, Reifiable context) => ADT t (Reify context) -> GColumns (ADT t) (Col (Reify context)) greify :: forall (context :: Context). (Labelable context, Reifiable context) => ADT t context -> ADT t (Reify context) gunreify :: forall (context :: Context). (Labelable context, Reifiable context) => ADT t (Reify context) -> ADT t context | |
(ADTable t, context ~ Result) => Generic (ADT t context) Source # | |
type Rep (ADT t context) Source # | |
Defined in Rel8.Table.ADT type Rep (ADT t context) = Rep (t context) |
class (Generic (t Result), HTable (GColumnsADT t), GTableADT (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRecord (Rep (t (Reify Result)))), GRecordable (Rep (t (Reify Result))), GMappable (TTable (Reify Result)) (Rep (t (Reify Result))), GMap TUnreify (Rep (t (Reify Result))) ~ Rep (t Result)) => ADTable t Source #
Instances
(Generic (t Result), HTable (GColumnsADT t), GTableADT (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRecord (Rep (t (Reify Result)))), GRecordable (Rep (t (Reify Result))), GMappable (TTable (Reify Result)) (Rep (t (Reify Result))), GMap TUnreify (Rep (t (Reify Result))) ~ Rep (t Result)) => ADTable t Source # | |
Defined in Rel8.Table.ADT |
type ConstructADT t = forall r. GGConstruct 'Sum (ADTRep t) r Source #
constructADT :: forall t. ConstructableADT t => ConstructADT t -> ADT t Expr Source #
type DeconstructADT t r = GGDeconstruct 'Sum (ADTRep t) (ADT t Expr) r Source #
deconstructADT :: forall t r. (ConstructableADT t, Table Expr r) => DeconstructADT t r Source #
type AggregateADT t = forall r. GGAggregate 'Sum (ADTRep t) r Source #
aggregateADT :: forall t. ConstructableADT t => AggregateADT t -> ADT t Expr -> ADT t Aggregate Source #
HKD
Instances
HKDable a => Rel8able (HKD a) Source # | |
Defined in Rel8.Table.HKD type GColumns (HKD a) :: HTable gfromColumns :: forall (context :: Context). (Labelable context, Reifiable context) => GColumns (HKD a) (Col (Reify context)) -> HKD a (Reify context) gtoColumns :: forall (context :: Context). (Labelable context, Reifiable context) => HKD a (Reify context) -> GColumns (HKD a) (Col (Reify context)) greify :: forall (context :: Context). (Labelable context, Reifiable context) => HKD a context -> HKD a (Reify context) gunreify :: forall (context :: Context). (Labelable context, Reifiable context) => HKD a (Reify context) -> HKD a context | |
(KnownAlgebra (GAlgebra (Rep a)), HTable (GColumnsHKD a), Eval (GGTable (GAlgebra (Rep a)) (TTable (Reify f)) TColumns (Col (Reify f)) (GRecord (GMap (TColumn (Reify f)) (Rep a)))), Eval (GGColumns (GAlgebra (Rep a)) TColumns (GRecord (GMap (TColumn (Reify f)) (Rep a)))) ~ GColumnsHKD a, Eval (GGContext (GAlgebra (Rep a)) TUnreifyContext (GRecord (GMap (TColumn (Reify f)) (Rep a)))) ~ f, GRecordable (GMap (TColumn (Reify f)) (Rep a)), GMappable (TTable (Reify f)) (GMap (TColumn (Reify f)) (Rep a)), GMap TUnreify (GMap (TColumn (Reify f)) (Rep a)) ~ GMap (TColumn f) (Rep a)) => Generic (HKD a f) Source # | |
type Rep (HKD a f) Source # | |
Defined in Rel8.Table.HKD type Rep (HKD a f) |
class (Generic a, HTable (GColumns (HKD a)), KnownAlgebra (GAlgebra (Rep a)), Eval (GGTable (GAlgebra (Rep a)) (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRecord (GMap (TColumn (Reify Result)) (Rep a)))), Eval (GGContext (GAlgebra (Rep a)) TUnreifyContext (GRecord (GMap (TColumn (Reify Result)) (Rep a)))) ~ Result, GRecordable (GMap (TColumn (Reify Result)) (Rep a)), GMappable Top (Rep a), GMappable (TTable (Reify Result)) (GMap (TColumn (Reify Result)) (Rep a)), GMap TUnreify (GMap (TColumn (Reify Result)) (Rep a)) ~ GMap (TColumn Result) (Rep a)) => HKDable a Source #
Instances
(Generic a, HTable (GColumns (HKD a)), KnownAlgebra (GAlgebra (Rep a)), Eval (GGTable (GAlgebra (Rep a)) (TTable (Reify Result)) TColumns (Col (Reify Result)) (GRecord (GMap (TColumn (Reify Result)) (Rep a)))), Eval (GGContext (GAlgebra (Rep a)) TUnreifyContext (GRecord (GMap (TColumn (Reify Result)) (Rep a)))) ~ Result, GRecordable (GMap (TColumn (Reify Result)) (Rep a)), GMappable Top (Rep a), GMappable (TTable (Reify Result)) (GMap (TColumn (Reify Result)) (Rep a)), GMap TUnreify (GMap (TColumn (Reify Result)) (Rep a)) ~ GMap (TColumn Result) (Rep a)) => HKDable a Source # | |
Defined in Rel8.Table.HKD |
type ConstructHKD a = forall r. GGConstruct (GAlgebra (Rep a)) (HKDRep a) r Source #
constructHKD :: forall a. ConstructableHKD a => ConstructHKD a -> HKD a Expr Source #
type DeconstructHKD a r = GGDeconstruct (GAlgebra (Rep a)) (HKDRep a) (HKD a Expr) r Source #
deconstructHKD :: forall a r. (ConstructableHKD a, Table Expr r) => DeconstructHKD a r Source #
type AggregateHKD a = forall r. GGAggregate (GAlgebra (Rep a)) (HKDRep a) r Source #
aggregateHKD :: forall a. ConstructableHKD a => AggregateHKD a -> HKD a Expr -> HKD a Aggregate Source #
Table schemas
data TableSchema names Source #
The schema for a table. This is used to specify the name and schema that a
table belongs to (the FROM
part of a SQL query), along with the schema of
the columns within this table.
For each selectable table in your database, you should provide a
TableSchema
in order to interact with the table via Rel8.
TableSchema | |
|
Instances
Functor TableSchema Source # | |
Defined in Rel8.Schema.Table fmap :: (a -> b) -> TableSchema a -> TableSchema b (<$) :: a -> TableSchema b -> TableSchema a |
A Name
is the name of a column, as it would be defined in a table's
schema definition. You can construct names by using the OverloadedStrings
extension and writing string literals. This is typically done when providing
a TableSchema
value.
Instances
Show (Name a) Source # | |
k ~ Type => IsString (Name a) Source # | |
Defined in Rel8.Schema.Name fromString :: String -> Name a | |
type Columns (Name a) Source # | |
Defined in Rel8.Schema.Name | |
type Context (Name a) Source # | |
Defined in Rel8.Schema.Name | |
type Unreify (Name a) Source # | |
Defined in Rel8.Schema.Name |
namesFromLabels :: Table Name a => a Source #
namesFromLabelsWith :: Table Name a => (NonEmpty String -> String) -> a Source #
Expressions
Typed SQL expressions.
Instances
class (constraint (Unnullify a), Nullable a) => Sql constraint a Source #
The Sql
type class describes both null and not null database values,
constrained by a specific class.
For example, if you see Sql DBEq a
, this means any database type that
supports equality, and a
can either be exactly an a
, or it could also be
Maybe a
.
Instances
(constraint (Unnullify a), Nullable a) => Sql constraint a Source # | |
Defined in Rel8.Schema.Null |
litExpr :: Sql DBType a => a -> Expr a Source #
Produce an expression from a literal.
Note that you can usually use lit
, but litExpr
can solve problems
of inference in polymorphic code.
unsafeCastExpr :: Sql DBType b => Expr a -> Expr b Source #
Cast an expression to a different type. Corresponds to a CAST()
function
call.
null
nullify :: NotNull a => Expr a -> Expr (Maybe a) Source #
Lift an expression that can't be null
to a type that might be null
.
This is an identity operation in terms of any generated query, and just
modifies the query's type.
nullable :: Table Expr b => b -> (Expr a -> b) -> Expr (Maybe a) -> b Source #
Like maybe
, but to eliminate null
.
mapNull :: DBType b => (Expr a -> Expr b) -> Expr (Maybe a) -> Expr (Maybe b) Source #
Lift an operation on non-null
values to an operation on possibly null
values. When given null
, mapNull f
returns null
.
This is like fmap
for Maybe
.
liftOpNull :: DBType c => (Expr a -> Expr b -> Expr c) -> Expr (Maybe a) -> Expr (Maybe b) -> Expr (Maybe c) Source #
Lift a binary operation on non-null
expressions to an equivalent binary
operator on possibly null
expressions. If either of the final arguments
are null
, liftOpNull
returns null
.
This is like liftA2
for Maybe
.
coalesce :: Expr (Maybe Bool) -> Expr Bool Source #
Convert a Expr (Maybe Bool)
to a Expr Bool
by treating Nothing
as
False
. This can be useful when combined with where_
, which expects
a Bool
, and produces expressions that optimize better than general case
analysis.
Boolean operations
class DBType a => DBEq a Source #
Database types that can be compared for equality in queries. If a type is
an instance of DBEq
, it means we can compare expressions for equality
using the SQL =
operator.
Instances
(==.) :: forall a. Sql DBEq a => Expr a -> Expr a -> Expr Bool infix 4 Source #
Compare two expressions for equality.
This corresponds to the SQL IS NOT DISTINCT FROM
operator, and will equate
null
values as true
. This differs from =
which would return null
.
This operator matches Haskell's ==
operator. For an operator identical to
SQL =
, see ==?
.
(/=.) :: forall a. Sql DBEq a => Expr a -> Expr a -> Expr Bool infix 4 Source #
Test if two expressions are different (not equal).
This corresponds to the SQL IS DISTINCT FROM
operator, and will return
false
when comparing two null
values. This differs from ordinary =
which would return null
. This operator is closer to Haskell's ==
operator. For an operator identical to SQL =
, see /=?
.
(==?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool infix 4 Source #
Test if two expressions are equal. This operator is usually the best
choice when forming join conditions, as PostgreSQL has a much harder time
optimizing a join that has multiple True
conditions.
This corresponds to the SQL =
operator, though it will always return a
Bool
.
(/=?) :: DBEq a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool infix 4 Source #
Test if two expressions are different.
This corresponds to the SQL <>
operator, though it will always return a
Bool
.
boolExpr :: Expr a -> Expr a -> Expr Bool -> Expr a Source #
Eliminate a boolean-valued expression.
Corresponds to bool
.
caseExpr :: [(Expr Bool, Expr a)] -> Expr a -> Expr a Source #
A multi-way ifthenelse statement. The first argument to caseExpr
is a
list of alternatives. The first alternative that is of the form (true, x)
will be returned. If no such alternative is found, a fallback expression is
returned.
Corresponds to a CASE
expression in SQL.
Ordering
class DBEq a => DBOrd a Source #
The class of database types that support the <
, <=
, >
and >=
operators.
Instances
(<.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool infix 4 Source #
Corresponds to the SQL <
operator. Note that this differs from SQL <
as null
will sort below any other value. For a version of <
that exactly
matches SQL, see (<?)
.
(<=.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool infix 4 Source #
Corresponds to the SQL <=
operator. Note that this differs from SQL <=
as null
will sort below any other value. For a version of <=
that exactly
matches SQL, see (<=?)
.
(>.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool infix 4 Source #
Corresponds to the SQL >
operator. Note that this differs from SQL >
as null
will sort below any other value. For a version of >
that exactly
matches SQL, see (>?)
.
(>=.) :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr Bool infix 4 Source #
Corresponds to the SQL >=
operator. Note that this differs from SQL >
as null
will sort below any other value. For a version of >=
that
exactly matches SQL, see (>=?)
.
(<?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool infix 4 Source #
Corresponds to the SQL <
operator. Returns null
if either arguments
are null
.
(<=?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool infix 4 Source #
Corresponds to the SQL <=
operator. Returns null
if either arguments
are null
.
(>?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool infix 4 Source #
Corresponds to the SQL >
operator. Returns null
if either arguments
are null
.
(>=?) :: DBOrd a => Expr (Maybe a) -> Expr (Maybe a) -> Expr Bool infix 4 Source #
Corresponds to the SQL >=
operator. Returns null
if either arguments
are null
.
leastExpr :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr a Source #
Given two expressions, return the expression that sorts less than the other.
Corresponds to the SQL least()
function.
greatestExpr :: forall a. Sql DBOrd a => Expr a -> Expr a -> Expr a Source #
Given two expressions, return the expression that sorts greater than the other.
Corresponds to the SQL greatest()
function.
Functions
class Function arg res Source #
This type class exists to allow function
to have arbitrary arity. It's
mostly an implementation detail, and typical uses of Function
shouldn't
need this to be specified.
applyArgument
Instances
(arg ~ Expr a, Function args res) => Function arg (args -> res) Source # | |
Defined in Rel8.Expr.Function applyArgument :: ([PrimExpr] -> PrimExpr) -> arg -> args -> res | |
(arg ~ Expr a, Sql DBType b) => Function arg (Expr b) Source # | |
Defined in Rel8.Expr.Function applyArgument :: ([PrimExpr] -> PrimExpr) -> arg -> Expr b |
function :: Function args result => String -> args -> result Source #
Construct an n-ary function that produces an Expr
that when called runs
a SQL function.
nullaryFunction :: Sql DBType a => String -> Expr a Source #
Construct a function call for functions with no arguments.
binaryOperator :: Sql DBType c => String -> Expr a -> Expr b -> Expr c Source #
Construct an expression by applying an infix binary operator to two operands.
Queries
The Query
monad allows you to compose a SELECT
query. This monad has
semantics similar to the list ([]
) monad.
showQuery :: Table Expr a => Query a -> String Source #
Convert a query to a String
containing the query as a SELECT
statement.
Selecting rows
class Recontextualize Name Expr names exprs => Selects names exprs Source #
Instances
Recontextualize (Name :: X -> Type) (Expr :: X -> Type) names exprs => Selects names exprs Source # | |
Defined in Rel8.Schema.Name |
each :: Selects names exprs => TableSchema names -> Query exprs Source #
Select each row from a table definition. This is equivalent to FROM
table
.
values :: (Table Expr a, Foldable f) => f a -> Query a Source #
Construct a query that returns the given input list of rows. This is like
folding a list of return
statements under union
, but uses the SQL
VALUES
expression for efficiency.
Filtering
where_ :: Expr Bool -> Query () Source #
Drop any rows that don't match a predicate. where_ expr
is equivalent
to the SQL WHERE expr
.
whereExists :: Query a -> Query () Source #
Produce the empty query if the given query returns no rows. whereExists
is equivalent to WHERE EXISTS
in SQL.
whereNotExists :: Query a -> Query () Source #
Produce the empty query if the given query returns rows. whereNotExists
is equivalent to WHERE NOT EXISTS
in SQL.
distinct :: EqTable a => Query a -> Query a Source #
Select all distinct rows from a query, removing duplicates. distinct q
is equivalent to the SQL statement SELECT DISTINCT q
.
distinctOn :: EqTable b => (a -> b) -> Query a -> Query a Source #
Select all distinct rows from a query, where rows are equivalent according
to a projection. If multiple rows have the same projection, it is
unspecified which row will be returned. If this matters, use distinctOnBy
.
distinctOnBy :: EqTable b => (a -> b) -> Order a -> Query a -> Query a Source #
Select all distinct rows from a query, where rows are equivalent according
to a projection. If there are multiple rows with the same projection, the
first row according to the specified Order
will be returned.
LIMIT
/OFFSET
limit :: Word -> Query a -> Query a Source #
limit n
select at most n
rows from a query. limit n
is equivalent
to the SQL LIMIT n
.
offset :: Word -> Query a -> Query a Source #
offset n
drops the first n
rows from a query. offset n
is equivalent
to the SQL OFFSET n
.
UNION
union :: EqTable a => Query a -> Query a -> Query a Source #
Combine the results of two queries of the same type, collapsing
duplicates. union a b
is the same as the SQL statement x UNION b
.
unionAll :: Table Expr a => Query a -> Query a -> Query a Source #
Combine the results of two queries of the same type, retaining duplicates.
unionAll a b
is the same as the SQL statement x UNION ALL b
.
INTERSECT
intersect :: EqTable a => Query a -> Query a -> Query a Source #
Find the intersection of two queries, collapsing duplicates. intersect a
b
is the same as the SQL statement x INTERSECT b
.
intersectAll :: EqTable a => Query a -> Query a -> Query a Source #
Find the intersection of two queries, retaining duplicates. intersectAll
a b
is the same as the SQL statement x INTERSECT ALL b
.
EXCEPT
except :: EqTable a => Query a -> Query a -> Query a Source #
Find the difference of two queries, collapsing duplicates except a b
is
the same as the SQL statement x INTERSECT b
.
exceptAll :: EqTable a => Query a -> Query a -> Query a Source #
Find the difference of two queries, retaining duplicates. exceptAll a b
is the same as the SQL statement x EXCEPT ALL b
.
EXISTS
withBy :: (a -> b -> Expr Bool) -> Query b -> a -> Query a Source #
Like with
, but with a custom membership test.
withoutBy :: (a -> b -> Expr Bool) -> Query b -> a -> Query a Source #
Like without
, but with a custom membership test.
Aggregation
An Aggregate a
describes how to aggregate Table
s of type a
. You can
unpack an Aggregate
back to a
by running it with aggregate
. As
Aggregate
is almost an Applicative
functor - but there is no pure
operation. This means Aggregate
is an instance of Apply
, and you can
combine Aggregate
s using the .
combinator.
class Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs Source #
Instances
Recontextualize (Aggregate :: X -> Type) (Expr :: X -> Type) aggregates exprs => Aggregates aggregates exprs Source # | |
Defined in Rel8.Aggregate |
aggregate :: Aggregates aggregates exprs => Query aggregates -> Query exprs Source #
Apply an aggregation to all rows returned by a Query
.
countRows :: Query a -> Query (Expr Int64) Source #
Count the number of rows returned by a query. Note that this is different
from countStar
, as even if the given query yields no rows, countRows
will return 0
.
groupBy :: forall exprs aggregates. (EqTable exprs, Aggregates aggregates exprs) => exprs -> aggregates Source #
Group equal tables together. This works by aggregating each column in the
given table with groupByExpr
.
listAgg :: Aggregates aggregates exprs => exprs -> ListTable aggregates Source #
Aggregate rows into a single row containing an array of all aggregated rows. This can be used to associate multiple rows with a single row, without changing the over cardinality of the query. This allows you to essentially return a tree-like structure from queries.
For example, if we have a table of orders and each orders contains multiple items, we could aggregate the table of orders, pairing each order with its items:
ordersWithItems :: Query (Order Expr, ListTable (Item Expr)) ordersWithItems = do order <- each orderSchema items aggregate $ listAgg <$ itemsFromOrder order return (order, items)
listAggExpr :: Sql DBType a => Expr a -> Aggregate [a] Source #
Collect expressions values as a list.
nonEmptyAgg :: Aggregates aggregates exprs => exprs -> NonEmptyTable aggregates Source #
Like listAgg
, but the result is guaranteed to be a non-empty list.
nonEmptyAggExpr :: Sql DBType a => Expr a -> Aggregate (NonEmpty a) Source #
Collect expressions values as a non-empty list.
class DBOrd a => DBMax a Source #
The class of database types that support the max
aggregation function.
Instances
max :: Sql DBMax a => Expr a -> Aggregate a Source #
Produce an aggregation for Expr a
using the max
function.
class DBOrd a => DBMin a Source #
The class of database types that support the min
aggregation function.
Instances
min :: Sql DBMin a => Expr a -> Aggregate a Source #
Produce an aggregation for Expr a
using the max
function.
class DBType a => DBSum a Source #
The class of database types that support the sum()
aggregation function.
Instances
DBSum Double Source # | |
Defined in Rel8.Type.Sum | |
DBSum Float Source # | |
Defined in Rel8.Type.Sum | |
DBSum Int16 Source # | |
Defined in Rel8.Type.Sum | |
DBSum Int32 Source # | |
Defined in Rel8.Type.Sum | |
DBSum Int64 Source # | |
Defined in Rel8.Type.Sum | |
DBSum Scientific Source # | |
Defined in Rel8.Type.Sum | |
DBSum CalendarDiffTime Source # | |
Defined in Rel8.Type.Sum |
sum :: Sql DBSum a => Expr a -> Aggregate a Source #
Corresponds to sum
. Note that in SQL, sum
is type changing - for
example the sum
of integer
returns a bigint
. Rel8 doesn't support
this, and will add explicit cast back to the original input type. This can
lead to overflows, and if you anticipate very large sums, you should upcast
your input.
sumWhere :: (Sql DBNum a, Sql DBSum a) => Expr Bool -> Expr a -> Aggregate a Source #
Take the sum of all expressions that satisfy a predicate.
class DBType a => DBString a Source #
The class of data types that support the string_agg()
aggregation
function.
Instances
DBString ByteString Source # | |
Defined in Rel8.Type.String | |
DBString Text Source # | |
Defined in Rel8.Type.String | |
DBString ByteString Source # | |
Defined in Rel8.Type.String | |
DBString Text Source # | |
Defined in Rel8.Type.String | |
DBString (CI Text) Source # | |
Defined in Rel8.Type.String | |
DBString (CI Text) Source # | |
Defined in Rel8.Type.String |
stringAgg :: Sql DBString a => Expr db -> Expr a -> Aggregate a Source #
Corresponds to string_agg()
.
count :: Expr a -> Aggregate Int64 Source #
Count the occurances of a single column. Corresponds to COUNT(a)
countDistinct :: Sql DBEq a => Expr a -> Aggregate Int64 Source #
Count the number of distinct occurances of a single column. Corresponds to
COUNT(DISTINCT a)
countWhere :: Expr Bool -> Aggregate Int64 Source #
A count of the number of times a given expression is true
.
Ordering
An ordering expression for a
. Primitive orderings are defined with
asc
and desc
, and you can combine Order
via its various
instances.
A common pattern is to use <>
to combine multiple orderings in sequence,
and >$<
(from Contravariant
) to select individual columns.
nullsFirst :: Order (Expr a) -> Order (Expr (Maybe a)) Source #
Transform an ordering so that null
values appear first. This corresponds
to NULLS FIRST
in SQL.
nullsLast :: Order (Expr a) -> Order (Expr (Maybe a)) Source #
Transform an ordering so that null
values appear first. This corresponds
to NULLS LAST
in SQL.
IO
class (ToExprs exprs a, a ~ FromExprs exprs) => Serializable exprs a | exprs -> a Source #
Serializable
witnesses the one-to-one correspondence between the type
sql
, which contains SQL expressions, and the type haskell
, which
contains the Haskell decoding of rows containing sql
SQL expressions.
Instances
(ToExprs exprs a, a ~ FromExprs exprs) => Serializable exprs a Source # | |
Defined in Rel8.Table.Serialize | |
Sql DBType a => Serializable (Expr a) a Source # | |
Defined in Rel8.Table.Serialize |
Running statements
SELECT
select :: forall exprs a. Serializable exprs a => Connection -> Query exprs -> IO [a] Source #
Run a SELECT
query, returning all rows.
INSERT
The constituent parts of a SQL INSERT
statement.
Insert | |
|
data OnConflict Source #
OnConflict
allows you to add an ON CONFLICT
clause to an INSERT
statement.
toInsert :: Inserts exprs inserts => exprs -> inserts Source #
toInsert
converts a Table
of Expr
s into a Table
that can be used
with insert
. This will override any columns that have default values
to use exactly what is given. If you want to use default values, you can
either override the result of toInsert
, or use toInsertDefaults
.
toInsertDefaults :: Inserts exprs inserts => exprs -> inserts Source #
toInsertDefaults
converts a Table
of Expr
s into a Table
that can
be used with insert
. Any columns that have a default value will
override whatever is in the input expression.
One example where this is useful is for any table that has a special id
column, which has a default value to draw a new value from a sequence. If we
use toInsertDefaults
, we can provide a dummy value that will be replaced
with a call to DEFAULT
.
DELETE
The constituent parts of a DELETE
statement.
Delete | |
|
UPDATE
The constituent parts of an UPDATE
statement.
Update | |
|
.. RETURNING
data Returning names a where Source #
INSERT
, UPDATE
and DELETE
all support returning either the number of
rows affected, or the actual rows modified. Projection
allows you to
project out of these returned rows, which can be useful if you want to log
exactly which rows were deleted, or to view a generated id (for example, if
using a column with an autoincrementing counter as a default value).
NumberOfRowsAffected :: Returning names Int64 | |
Projection :: (Selects names exprs, Serializable projection a) => (exprs -> projection) -> Returning names [a] |
CREATE VIEW
createView :: Selects names exprs => TableSchema names -> Query exprs -> Connection -> IO () Source #
Given a TableSchema
and Query
, createView
runs a CREATE VIEW
statement that will save the given query as a view. This can be useful if
you want to share Rel8 queries with other applications.
TODO
class (Table from a, Table to b, Congruent a b, Recontextualize from from a a, Recontextualize to to b b, Recontextualize to from b a) => Recontextualize from to a b | a -> from, b -> to, a to -> b, b from -> a Source #
Instances
(Labelable from, Nullifiable from, ConstrainTag from MaybeTag, Labelable to, Nullifiable to, ConstrainTag to MaybeTag, Recontextualize from to a b) => Recontextualize from to (MaybeTable a) (MaybeTable b) Source # | |
Defined in Rel8.Table.Maybe | |
(Unreifies from a, Unreifies to b, Recontextualize from to a b) => Recontextualize from to (NonEmptyTable a) (NonEmptyTable b) Source # | |
Defined in Rel8.Table.NonEmpty | |
(Unreifies from a, Unreifies to b, Recontextualize from to a b) => Recontextualize from to (ListTable a) (ListTable b) Source # | |
Defined in Rel8.Table.List | |
(Rel8able t, Labelable from, Reifiable from, Labelable to, Reifiable to, Congruent (t from) (t to)) => Recontextualize from to (t from) (t to) Source # | |
Defined in Rel8.Table.Rel8able | |
Sql DBType a => Recontextualize Result Result (Identity a) (Identity a) Source # | |
Defined in Rel8.Table.Recontextualize | |
(Recontextualize from to a1 b1, Recontextualize from to a2 b2, Labelable from, Labelable to) => Recontextualize from to (a1, a2) (b1, b2) Source # | |
Defined in Rel8.Table.Recontextualize | |
(Labelable from, Nullifiable from, ConstrainTag from MaybeTag, Labelable to, Nullifiable to, ConstrainTag to MaybeTag, Recontextualize from to a1 b1, Recontextualize from to a2 b2) => Recontextualize from to (TheseTable a1 a2) (TheseTable b1 b2) Source # | |
Defined in Rel8.Table.These | |
(Nullifiable from, Labelable from, ConstrainTag from EitherTag, Nullifiable to, Labelable to, ConstrainTag to EitherTag, Recontextualize from to a1 b1, Recontextualize from to a2 b2) => Recontextualize from to (EitherTable a1 a2) (EitherTable b1 b2) Source # | |
Defined in Rel8.Table.Either | |
(Recontextualize from to a1 b1, Recontextualize from to a2 b2, Recontextualize from to a3 b3, Labelable from, Labelable to) => Recontextualize from to (a1, a2, a3) (b1, b2, b3) Source # | |
Defined in Rel8.Table.Recontextualize | |
(Recontextualize from to a1 b1, Recontextualize from to a2 b2, Recontextualize from to a3 b3, Recontextualize from to a4 b4, Labelable from, Labelable to) => Recontextualize from to (a1, a2, a3, a4) (b1, b2, b3, b4) Source # | |
Defined in Rel8.Table.Recontextualize | |
(Recontextualize from to a1 b1, Recontextualize from to a2 b2, Recontextualize from to a3 b3, Recontextualize from to a4 b4, Recontextualize from to a5 b5, Labelable from, Labelable to) => Recontextualize from to (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5) Source # | |
Defined in Rel8.Table.Recontextualize |
class Nullable' (IsMaybe a) a => Nullable a Source #
Nullable a
means that rel8
is able to check if the type a
is a
type that can take null
values or not.
Instances
Nullable' (IsMaybe a) a => Nullable a Source # | |
Defined in Rel8.Schema.Null |
class (Nullable a, IsMaybe a ~ 'False) => NotNull a Source #
nullify a
means a
cannot take null
as a value.
Instances
(Nullable a, IsMaybe a ~ 'False) => NotNull a Source # | |
Defined in Rel8.Schema.Null |
A HTable
is a functor-indexed/higher-kinded data type that is
representable (htabulate
/hfield
), constrainable (hdicts
), and
specified (hspecs
).
This is an internal concept for Rel8, and you should not need to define instances yourself or specify this constraint.
class Interpretation context => Labelable context Source #
labeler, unlabeler
Instances
Labelable Result Source # | |
Defined in Rel8.Schema.Context.Label labeler :: forall (labels :: Labels) (necessity :: Necessity) a (label :: Symbol). Col Result ('Spec labels necessity a) -> Col Result ('Spec (label ': labels) necessity a) unlabeler :: forall (label :: Symbol) (labels :: [Symbol]) (necessity :: Necessity) a. Col Result ('Spec (label ': labels) necessity a) -> Col Result ('Spec labels necessity a) |
class Table Expr exprs => ToExprs exprs a where Source #
Nothing
fromResult :: Columns exprs (Col Result) -> a Source #
default fromResult :: (Generic (Record a), KnownAlgebra (GAlgebra (Rep (Record exprs))), Eval (GGToExprs (GAlgebra (Rep (Record exprs))) TToExprs TColumns (Rep (Record exprs)) (Rep (Record a))), Columns exprs ~ Eval (GGColumns (GAlgebra (Rep (Record exprs))) TColumns (Rep (Record exprs)))) => Columns exprs (Col Result) -> a Source #
toResult :: a -> Columns exprs (Col Result) Source #
default toResult :: (Generic (Record a), KnownAlgebra (GAlgebra (Rep (Record exprs))), Eval (GGToExprs (GAlgebra (Rep (Record exprs))) TToExprs TColumns (Rep (Record exprs)) (Rep (Record a))), Columns exprs ~ Eval (GGColumns (GAlgebra (Rep (Record exprs))) TColumns (Rep (Record exprs)))) => a -> Columns exprs (Col Result) Source #
Instances
(Sql DBType a, x ~ Expr a) => ToExprs x a Source # | |
(HTable t, result ~ Col Result, x ~ t (Col (Expr :: X -> Type))) => ToExprs x (t result) Source # | |
(Table (Expr :: X -> Type) (HKD a (Expr :: X -> Type)), Columns (HKD a (Expr :: X -> Type)) ~ GColumns (HKD a), HKDable a, x ~ HKD a (Expr :: X -> Type)) => ToExprs x (HKDT a) Source # | |
(x ~ t' (Expr :: X -> Type), result ~ Result, ToExprs' (Algebra t) t' t) => ToExprs x (t result) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, x ~ (exprs1, exprs2)) => ToExprs x (a, b) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, x ~ TheseTable exprs1 exprs2) => ToExprs x (These a b) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, x ~ EitherTable exprs1 exprs2) => ToExprs x (Either a b) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, ToExprs exprs3 c, x ~ (exprs1, exprs2, exprs3)) => ToExprs x (a, b, c) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, ToExprs exprs3 c, ToExprs exprs4 d, x ~ (exprs1, exprs2, exprs3, exprs4)) => ToExprs x (a, b, c, d) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, ToExprs exprs3 c, ToExprs exprs4 d, ToExprs exprs5 e, x ~ (exprs1, exprs2, exprs3, exprs4, exprs5)) => ToExprs x (a, b, c, d, e) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, ToExprs exprs3 c, ToExprs exprs4 d, ToExprs exprs5 e, ToExprs exprs6 f, x ~ (exprs1, exprs2, exprs3, exprs4, exprs5, exprs6)) => ToExprs x (a, b, c, d, e, f) Source # | |
(ToExprs exprs1 a, ToExprs exprs2 b, ToExprs exprs3 c, ToExprs exprs4 d, ToExprs exprs5 e, ToExprs exprs6 f, ToExprs exprs7 g, x ~ (exprs1, exprs2, exprs3, exprs4, exprs5, exprs6, exprs7)) => ToExprs x (a, b, c, d, e, f, g) Source # | |
ToExprs exprs a => ToExprs (MaybeTable exprs) (Maybe a) Source # | |
Defined in Rel8.Table.Maybe fromResult :: Columns (MaybeTable exprs) (Col Result) -> Maybe a Source # toResult :: Maybe a -> Columns (MaybeTable exprs) (Col Result) Source # | |
ToExprs exprs a => ToExprs (NonEmptyTable exprs) (NonEmpty a) Source # | |
Defined in Rel8.Table.NonEmpty fromResult :: Columns (NonEmptyTable exprs) (Col Result) -> NonEmpty a Source # toResult :: NonEmpty a -> Columns (NonEmptyTable exprs) (Col Result) Source # | |
ToExprs exprs a => ToExprs (ListTable exprs) [a] Source # | |
(Sql DBType a, NotNull a, x ~ NonEmpty a) => ToExprs (Expr x) (NonEmpty a) Source # | |
(Sql DBType a, NotNull a, x ~ Maybe a) => ToExprs (Expr x) (Maybe a) Source # | |
(Sql DBType a, x ~ [a]) => ToExprs (Expr x) [a] Source # | |
type family FromExprs a Source #
Instances
type FromExprs (MaybeTable a) Source # | |
Defined in Rel8.Table.Maybe | |
type FromExprs (NonEmptyTable a) Source # | |
Defined in Rel8.Table.NonEmpty | |
type FromExprs (ListTable a) Source # | |
Defined in Rel8.Table.List | |
type FromExprs (a, b) Source # | |
Defined in Rel8.Table.Serialize | |
type FromExprs (Expr a) Source # | |
Defined in Rel8.Table.Serialize | |
type FromExprs (TheseTable a b) Source # | |
Defined in Rel8.Table.These | |
type FromExprs (EitherTable a b) Source # | |
Defined in Rel8.Table.Either | |
type FromExprs (a, b, c) Source # | |
Defined in Rel8.Table.Serialize | |
type FromExprs (a, b, c, d) Source # | |
type FromExprs (a, b, c, d, e) Source # | |
type FromExprs (a, b, c, d, e, f) Source # | |
type FromExprs (a, b, c, d, e, f, g) Source # | |
Instances
Labelable Result Source # | |
Defined in Rel8.Schema.Context.Label labeler :: forall (labels :: Labels) (necessity :: Necessity) a (label :: Symbol). Col Result ('Spec labels necessity a) -> Col Result ('Spec (label ': labels) necessity a) unlabeler :: forall (label :: Symbol) (labels :: [Symbol]) (necessity :: Necessity) a. Col Result ('Spec (label ': labels) necessity a) -> Col Result ('Spec labels necessity a) | |
Sql DBType a => Recontextualize Result Result (Identity a) (Identity a) Source # | |
Defined in Rel8.Table.Recontextualize | |
Table Result a => Table Result [a] Source # | |
Defined in Rel8.Table | |
Table Result a => Table Result (Maybe a) Source # | |
Defined in Rel8.Table toColumns :: Maybe a -> Columns (Maybe a) (Col Result) Source # fromColumns :: Columns (Maybe a) (Col Result) -> Maybe a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (Maybe a) -> Maybe a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Maybe a -> Unreify (Maybe a) Source # | |
Table Result a => Table Result (NonEmpty a) Source # | |
Defined in Rel8.Table toColumns :: NonEmpty a -> Columns (NonEmpty a) (Col Result) Source # fromColumns :: Columns (NonEmpty a) (Col Result) -> NonEmpty a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (NonEmpty a) -> NonEmpty a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> NonEmpty a -> Unreify (NonEmpty a) Source # | |
Sql DBType a => Table Result (Identity a) Source # | |
Defined in Rel8.Table toColumns :: Identity a -> Columns (Identity a) (Col Result) Source # fromColumns :: Columns (Identity a) (Col Result) -> Identity a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (Identity a) -> Identity a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Identity a -> Unreify (Identity a) Source # | |
HKDable a => Table Result (HKDT a) Source # | |
Defined in Rel8.Table.HKD toColumns :: HKDT a -> Columns (HKDT a) (Col Result) Source # fromColumns :: Columns (HKDT a) (Col Result) -> HKDT a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (HKDT a) -> HKDT a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> HKDT a -> Unreify (HKDT a) Source # | |
(Table Result a, Table Result b) => Table Result (Either a b) Source # | |
Defined in Rel8.Table toColumns :: Either a b -> Columns (Either a b) (Col Result) Source # fromColumns :: Columns (Either a b) (Col Result) -> Either a b Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (Either a b) -> Either a b Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Either a b -> Unreify (Either a b) Source # | |
(Table Result a, Table Result b) => Table Result (These a b) Source # | |
Defined in Rel8.Table toColumns :: These a b -> Columns (These a b) (Col Result) Source # fromColumns :: Columns (These a b) (Col Result) -> These a b Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (These a b) -> These a b Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> These a b -> Unreify (These a b) Source # |
Instances
HKDable a => Table Result (HKDT a) Source # | |
Defined in Rel8.Table.HKD toColumns :: HKDT a -> Columns (HKDT a) (Col Result) Source # fromColumns :: Columns (HKDT a) (Col Result) -> HKDT a Source # reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify (HKDT a) -> HKDT a Source # unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> HKDT a -> Unreify (HKDT a) Source # | |
(Table (Expr :: X -> Type) (HKD a (Expr :: X -> Type)), Columns (HKD a (Expr :: X -> Type)) ~ GColumns (HKD a), HKDable a, x ~ HKD a (Expr :: X -> Type)) => ToExprs x (HKDT a) Source # | |
type Columns (HKDT a) Source # | |
Defined in Rel8.Table.HKD | |
type Context (HKDT a) Source # | |
Defined in Rel8.Table.HKD | |
type Unreify (HKDT a) Source # | |
Defined in Rel8.Table.HKD |