rel8-0.1.0.0: Hey! Hey! Can u rel8?
Safe HaskellNone
LanguageHaskell2010

Rel8

Synopsis

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

Instances details
DBType Bool Source #

Corresponds to bool

Instance details

Defined in Rel8.Type

DBType Char Source #

Corresponds to char

Instance details

Defined in Rel8.Type

DBType Double Source #

Corresponds to float8

Instance details

Defined in Rel8.Type

DBType Float Source #

Corresponds to float4

Instance details

Defined in Rel8.Type

DBType Int16 Source #

Corresponds to int2

Instance details

Defined in Rel8.Type

DBType Int32 Source #

Corresponds to int4

Instance details

Defined in Rel8.Type

DBType Int64 Source #

Corresponds to int8

Instance details

Defined in Rel8.Type

DBType ByteString Source #

Corresponds to bytea

Instance details

Defined in Rel8.Type

DBType Scientific Source #

Corresponds to numeric

Instance details

Defined in Rel8.Type

DBType Text Source #

Corresponds to text

Instance details

Defined in Rel8.Type

DBType ByteString Source #

Corresponds to bytea

Instance details

Defined in Rel8.Type

DBType Text Source #

Corresponds to text

Instance details

Defined in Rel8.Type

DBType CalendarDiffTime Source #

Corresponds to interval

Instance details

Defined in Rel8.Type

Methods

typeInformation :: TypeInformation CalendarDiffTime Source #

DBType UTCTime Source #

Corresponds to timestamptz

Instance details

Defined in Rel8.Type

DBType Day Source #

Corresponds to date

Instance details

Defined in Rel8.Type

DBType LocalTime Source #

Corresponds to timestamp

Instance details

Defined in Rel8.Type

DBType TimeOfDay Source #

Corresponds to time

Instance details

Defined in Rel8.Type

DBType Value Source #

Corresponds to jsonb

Instance details

Defined in Rel8.Type

DBType UUID Source #

Corresponds to uuid

Instance details

Defined in Rel8.Type

Sql DBType a => DBType [a] Source # 
Instance details

Defined in Rel8.Type

Sql DBType a => DBType (NonEmpty a) Source # 
Instance details

Defined in Rel8.Type

Methods

typeInformation :: TypeInformation (NonEmpty a) Source #

DBType (CI Text) Source #

Corresponds to citext

Instance details

Defined in Rel8.Type

DBType (CI Text) Source #

Corresponds to citext

Instance details

Defined in Rel8.Type

(FromJSON a, ToJSON a) => DBType (JSONBEncoded a) Source # 
Instance details

Defined in Rel8.Type.JSONBEncoded

(FromJSON a, ToJSON a) => DBType (JSONEncoded a) Source # 
Instance details

Defined in Rel8.Type.JSONEncoded

DBEnum a => DBType (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

(Read a, Show a, Typeable a) => DBType (ReadShow a) Source # 
Instance details

Defined in Rel8.Type.ReadShow

DBComposite a => DBType (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

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.

Constructors

JSONEncoded 

Fields

Instances

Instances details
(FromJSON a, ToJSON a) => DBType (JSONEncoded a) Source # 
Instance details

Defined in Rel8.Type.JSONEncoded

newtype JSONBEncoded a Source #

Like JSONEncoded, but works for jsonb columns.

Constructors

JSONBEncoded 

Fields

Instances

Instances details
(FromJSON a, ToJSON a) => DBType (JSONBEncoded a) Source # 
Instance details

Defined in Rel8.Type.JSONBEncoded

ReadShow

newtype ReadShow a Source #

A deriving-via helper type for column types that store a Haskell value using a Haskell's Read and Show type classes.

Constructors

ReadShow 

Fields

Instances

Instances details
(Read a, Show a, Typeable a) => DBType (ReadShow a) Source # 
Instance details

Defined in Rel8.Type.ReadShow

Generic

newtype Composite a Source #

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).

Constructors

Composite a 

Instances

Instances details
DBComposite a => DBType (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

(DBComposite a, EqTable (HKD a (Expr :: X -> Type))) => DBEq (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBMin (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBMax (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBOrd (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

class (DBType a, HKDable a) => DBComposite a where Source #

decompose :: forall a. DBComposite a => Expr a -> HKD a Expr Source #

newtype Enum a 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).

Constructors

Enum a 

Instances

Instances details
DBEnum a => DBType (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

DBEnum a => DBEq (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

DBEnum a => DBMin (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

DBEnum a => DBMax (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

DBEnum a => DBOrd (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

class (DBType a, Enumable a) => DBEnum a where Source #

Minimal complete definition

enumTypeName

Methods

enumValue :: a -> String Source #

enumTypeName :: String Source #

class (Generic a, GEnumable (Rep a)) => Enumable a Source #

Instances

Instances details
(Generic a, GEnumable (Rep a)) => Enumable a Source # 
Instance details

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.

Constructors

TypeInformation 

Fields

  • encode :: a -> PrimExpr

    How to encode a single Haskell value as a SQL expression.

  • decode :: Value a

    How to deserialize a single result back to Haskell.

  • typeName :: String

    The name of the SQL type.

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 DBTypes that form a semigroup. This class is purely a Rel8 concept, and exists to mirror the Semigroup class.

Methods

(<>.) :: Expr a -> Expr a -> Expr a infixr 6 Source #

An associative operation.

Instances

Instances details
DBSemigroup ByteString Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr ByteString -> Expr ByteString -> Expr ByteString Source #

DBSemigroup Text Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr Text -> Expr Text -> Expr Text Source #

DBSemigroup ByteString Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr ByteString -> Expr ByteString -> Expr ByteString Source #

DBSemigroup Text Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr Text -> Expr Text -> Expr Text Source #

DBSemigroup CalendarDiffTime Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr CalendarDiffTime -> Expr CalendarDiffTime -> Expr CalendarDiffTime Source #

Sql DBType a => DBSemigroup [a] Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr [a] -> Expr [a] -> Expr [a] Source #

Sql DBType a => DBSemigroup (NonEmpty a) Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr (NonEmpty a) -> Expr (NonEmpty a) -> Expr (NonEmpty a) Source #

DBSemigroup (CI Text) Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr (CI Text) -> Expr (CI Text) -> Expr (CI Text) Source #

DBSemigroup (CI Text) Source # 
Instance details

Defined in Rel8.Type.Semigroup

Methods

(<>.) :: Expr (CI Text) -> Expr (CI Text) -> Expr (CI Text) Source #

class DBSemigroup a => DBMonoid a where Source #

The class of DBTypes that form a semigroup. This class is purely a Rel8 concept, and exists to mirror the Monoid class.

Methods

memptyExpr :: Expr a Source #

Instances

Instances details
DBMonoid ByteString Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

memptyExpr :: Expr ByteString Source #

DBMonoid Text Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

memptyExpr :: Expr Text Source #

DBMonoid ByteString Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

memptyExpr :: Expr ByteString Source #

DBMonoid Text Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

memptyExpr :: Expr Text Source #

DBMonoid CalendarDiffTime Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

memptyExpr :: Expr CalendarDiffTime Source #

Sql DBType a => DBMonoid [a] Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

memptyExpr :: Expr [a] Source #

DBMonoid (CI Text) Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

memptyExpr :: Expr (CI Text) Source #

DBMonoid (CI Text) Source # 
Instance details

Defined in Rel8.Type.Monoid

Methods

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

Instances details
DBNum Double Source # 
Instance details

Defined in Rel8.Type.Num

DBNum Float Source # 
Instance details

Defined in Rel8.Type.Num

DBNum Int16 Source # 
Instance details

Defined in Rel8.Type.Num

DBNum Int32 Source # 
Instance details

Defined in Rel8.Type.Num

DBNum Int64 Source # 
Instance details

Defined in Rel8.Type.Num

DBNum Scientific Source # 
Instance details

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

Instances details
DBIntegral Int16 Source # 
Instance details

Defined in Rel8.Type.Num

DBIntegral Int32 Source # 
Instance details

Defined in Rel8.Type.Num

DBIntegral Int64 Source # 
Instance details

Defined in Rel8.Type.Num

class DBNum a => DBFractional a Source #

The class of database types that support the / operator.

Instances

Instances details
DBFractional Double Source # 
Instance details

Defined in Rel8.Type.Num

DBFractional Float Source # 
Instance details

Defined in Rel8.Type.Num

DBFractional Scientific Source # 
Instance details

Defined in Rel8.Type.Num

class DBFractional a => DBFloating a Source #

The class of database types that support the / operator.

Instances

Instances details
DBFloating Double Source # 
Instance details

Defined in Rel8.Type.Num

DBFloating Float Source # 
Instance details

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 Tables 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

Instances details
HKDable a => Rel8able (HKD a) Source # 
Instance details

Defined in Rel8.Table.HKD

Associated Types

type GColumns (HKD a) :: HTable

Methods

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 # 
Instance details

Defined in Rel8.Table.ADT

Associated Types

type GColumns (ADT t) :: HTable

Methods

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 KRel8able = Rel8able Source #

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 Field context necessity a where ... Source #

Equations

Field (Reify context) necessity a = AField context necessity a 
Field Aggregate _necessity a = Aggregate a 
Field Expr _necessity a = Expr a 
Field Insert 'Required a = Expr a 
Field Insert 'Optional a = Maybe (Expr a) 
Field Name _necessity a = Name a 
Field Result _necessity a = a 

data Necessity Source #

Constructors

Optional 
Required 

type Default context a = Field context 'Optional a Source #

type family HADT context t where ... Source #

Equations

HADT (Reify context) t = AHADT context t 
HADT Result t = t Result 
HADT context t = ADT t context 

type family HEither context where ... Source #

Equations

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 #

Equations

HMaybe (Reify context) = AHMaybe context 
HMaybe Aggregate = MaybeTable 
HMaybe Expr = MaybeTable 
HMaybe Insert = MaybeTable 
HMaybe Name = MaybeTable 
HMaybe Result = Maybe 

type family HList context where ... Source #

Equations

HList (Reify context) = AHList context 
HList Aggregate = ListTable 
HList Expr = ListTable 
HList Insert = ListTable 
HList Name = ListTable 
HList Result = [] 

type family HNonEmpty context where ... Source #

type family HThese context where ... Source #

Equations

HThese (Reify context) = AHThese context 
HThese Aggregate = TheseTable 
HThese Expr = TheseTable 
HThese Insert = TheseTable 
HThese Name = TheseTable 
HThese Result = These 

type family Lift context a where ... Source #

Equations

Lift (Reify context) a = ALift context a 
Lift Result a = a 
Lift context a = HKD a context 

class (HTable (Columns a), context ~ Context a) => Table context a | a -> context where Source #

Tables 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.

Minimal complete definition

Nothing

Associated Types

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

Methods

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 #

default unreify :: (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) -> a -> Unreify a Source #

Instances

Instances details
(Table context a, Labelable context, Nullifiable context, ConstrainTag context MaybeTag) => Table context (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Associated Types

type Columns (MaybeTable a) :: HTable Source #

type Context (MaybeTable a) :: Context Source #

type Unreify (MaybeTable a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.NonEmpty

Associated Types

type Columns (NonEmptyTable a) :: HTable Source #

type Context (NonEmptyTable a) :: Context Source #

type Unreify (NonEmptyTable a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.List

Associated Types

type Columns (ListTable a) :: HTable Source #

type Context (ListTable a) :: Context Source #

type Unreify (ListTable a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.Rel8able

Associated Types

type Columns (t context) :: HTable Source #

type Context (t context) :: Context Source #

type Unreify (t context) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns [a] :: HTable Source #

type Context [a] :: Context Source #

type Unreify [a] Source #

Methods

toColumns :: [a] -> Columns [a] (Col Result) Source #

fromColumns :: Columns [a] (Col Result) -> [a] Source #

reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify [a] -> [a] Source #

unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> [a] -> Unreify [a] Source #

Table Result a => Table Result (Maybe a) Source # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (Maybe a) :: HTable Source #

type Context (Maybe a) :: Context Source #

type Unreify (Maybe a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (NonEmpty a) :: HTable Source #

type Context (NonEmpty a) :: Context Source #

type Unreify (NonEmpty a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (Identity a) :: HTable Source #

type Context (Identity a) :: Context Source #

type Unreify (Identity a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.HKD

Associated Types

type Columns (HKDT a) :: HTable Source #

type Context (HKDT a) :: Context Source #

type Unreify (HKDT a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (a, b) :: HTable Source #

type Context (a, b) :: Context Source #

type Unreify (a, b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.These

Associated Types

type Columns (TheseTable a b) :: HTable Source #

type Context (TheseTable a b) :: Context Source #

type Unreify (TheseTable a b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.Either

Associated Types

type Columns (EitherTable a b) :: HTable Source #

type Context (EitherTable a b) :: Context Source #

type Unreify (EitherTable a b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (Either a b) :: HTable Source #

type Context (Either a b) :: Context Source #

type Unreify (Either a b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (These a b) :: HTable Source #

type Context (These a b) :: Context Source #

type Unreify (These a b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (a, b, c) :: HTable Source #

type Context (a, b, c) :: Context Source #

type Unreify (a, b, c) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (a, b, c, d) :: HTable Source #

type Context (a, b, c, d) :: Context Source #

type Unreify (a, b, c, d) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (a, b, c, d, e) :: HTable Source #

type Context (a, b, c, d, e) :: Context Source #

type Unreify (a, b, c, d, e) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (a, b, c, d, e, f) :: HTable Source #

type Context (a, b, c, d, e, f) :: Context Source #

type Unreify (a, b, c, d, e, f) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (a, b, c, d, e, f, g) :: HTable Source #

type Context (a, b, c, d, e, f, g) :: Context Source #

type Unreify (a, b, c, d, e, f, g) Source #

Methods

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.

Methods

(<|>:) :: Table Expr a => f a -> f a -> f a infixl 3 Source #

An associative binary operation on Tables.

Instances

Instances details
AltTable Query Source #

<|>: = unionAll.

Instance details

Defined in Rel8.Query

Methods

(<|>:) :: Table Expr a => Query a -> Query a -> Query a Source #

AltTable MaybeTable Source # 
Instance details

Defined in Rel8.Table.Maybe

AltTable NonEmptyTable Source # 
Instance details

Defined in Rel8.Table.NonEmpty

AltTable ListTable Source # 
Instance details

Defined in Rel8.Table.List

Methods

(<|>:) :: Table Expr a => ListTable a -> ListTable a -> ListTable a Source #

EqTable k => AltTable (Tabulation k) Source # 
Instance details

Defined in Rel8.Tabulate

Methods

(<|>:) :: 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 Tables form a monoid on applicative functors.

Methods

emptyTable :: Table Expr a => f a Source #

The identity of <|>:.

Instances

Instances details
AlternativeTable Query Source #

emptyTable = values [].

Instance details

Defined in Rel8.Query

Methods

emptyTable :: Table Expr a => Query a Source #

AlternativeTable MaybeTable Source # 
Instance details

Defined in Rel8.Table.Maybe

AlternativeTable ListTable Source # 
Instance details

Defined in Rel8.Table.List

EqTable k => AlternativeTable (Tabulation k) Source # 
Instance details

Defined in Rel8.Tabulate

Methods

emptyTable :: Table Expr a => Tabulation k a Source #

class Table Expr a => EqTable a Source #

The class of Tables 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

Instances details
(HTable t, f ~ Col (Expr :: X -> Type), HConstrainTable t (ConstrainDBType DBEq)) => EqTable (t f) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (t f) (Dict (ConstrainDBType DBEq))

(context ~ (Expr :: X -> Type), Rel8able t, HConstrainTable (Columns (t context)) (ConstrainDBType DBEq)) => EqTable (t context) Source # 
Instance details

Defined in Rel8.Table.Rel8able

Methods

eqTable :: Columns (t context) (Dict (ConstrainDBType DBEq))

EqTable a => EqTable (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

eqTable :: Columns (MaybeTable a) (Dict (ConstrainDBType DBEq))

EqTable a => EqTable (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

Methods

eqTable :: Columns (NonEmptyTable a) (Dict (ConstrainDBType DBEq))

EqTable a => EqTable (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

Methods

eqTable :: Columns (ListTable a) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b) => EqTable (a, b) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (a, b) (Dict (ConstrainDBType DBEq))

Sql DBEq a => EqTable (Expr a) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (Expr a) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b) => EqTable (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

Methods

eqTable :: Columns (TheseTable a b) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b) => EqTable (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

Methods

eqTable :: Columns (EitherTable a b) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b, EqTable c) => EqTable (a, b, c) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (a, b, c) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b, EqTable c, EqTable d) => EqTable (a, b, c, d) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (a, b, c, d) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b, EqTable c, EqTable d, EqTable e) => EqTable (a, b, c, d, e) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (a, b, c, d, e) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b, EqTable c, EqTable d, EqTable e, EqTable f) => EqTable (a, b, c, d, e, f) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (a, b, c, d, e, f) (Dict (ConstrainDBType DBEq))

(EqTable a, EqTable b, EqTable c, EqTable d, EqTable e, EqTable f, EqTable g) => EqTable (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (a, b, c, d, e, f, g) (Dict (ConstrainDBType DBEq))

(==:) :: forall a. EqTable a => a -> a -> Expr Bool infix 4 Source #

Compare two Tables 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 Tables 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 Tables 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

Instances details
(HTable t, f ~ Col (Expr :: X -> Type), HConstrainTable t (ConstrainDBType DBEq), HConstrainTable t (ConstrainDBType DBOrd)) => OrdTable (t f) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (t f) (Dict (ConstrainDBType DBOrd))

(context ~ (Expr :: X -> Type), Rel8able t, HConstrainTable (Columns (t context)) (ConstrainDBType DBEq), HConstrainTable (Columns (t context)) (ConstrainDBType DBOrd)) => OrdTable (t context) Source # 
Instance details

Defined in Rel8.Table.Rel8able

Methods

ordTable :: Columns (t context) (Dict (ConstrainDBType DBOrd))

OrdTable a => OrdTable (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

ordTable :: Columns (MaybeTable a) (Dict (ConstrainDBType DBOrd))

OrdTable a => OrdTable (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

Methods

ordTable :: Columns (NonEmptyTable a) (Dict (ConstrainDBType DBOrd))

OrdTable a => OrdTable (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

Methods

ordTable :: Columns (ListTable a) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b) => OrdTable (a, b) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (a, b) (Dict (ConstrainDBType DBOrd))

Sql DBOrd a => OrdTable (Expr a) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (Expr a) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b) => OrdTable (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

Methods

ordTable :: Columns (TheseTable a b) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b) => OrdTable (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

Methods

ordTable :: Columns (EitherTable a b) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b, OrdTable c) => OrdTable (a, b, c) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (a, b, c) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b, OrdTable c, OrdTable d) => OrdTable (a, b, c, d) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (a, b, c, d) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b, OrdTable c, OrdTable d, OrdTable e) => OrdTable (a, b, c, d, e) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (a, b, c, d, e) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b, OrdTable c, OrdTable d, OrdTable e, OrdTable f) => OrdTable (a, b, c, d, e, f) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (a, b, c, d, e, f) (Dict (ConstrainDBType DBOrd))

(OrdTable a, OrdTable b, OrdTable c, OrdTable d, OrdTable e, OrdTable f, OrdTable g) => OrdTable (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (a, b, c, d, e, f, g) (Dict (ConstrainDBType DBOrd))

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 Exprs 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

Instances details
Monad MaybeTable Source #

Has the same behavior as the Monad instance for Maybe. See also: bindMaybeTable.

Instance details

Defined in Rel8.Table.Maybe

Methods

(>>=) :: MaybeTable a -> (a -> MaybeTable b) -> MaybeTable b

(>>) :: MaybeTable a -> MaybeTable b -> MaybeTable b

return :: a -> MaybeTable a

Functor MaybeTable Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

fmap :: (a -> b) -> MaybeTable a -> MaybeTable b

(<$) :: a -> MaybeTable b -> MaybeTable a

Applicative MaybeTable Source #

Has the same behavior as the Applicative instance for Maybe. See also: traverseMaybeTable.

Instance details

Defined in Rel8.Table.Maybe

Methods

pure :: a -> MaybeTable a

(<*>) :: MaybeTable (a -> b) -> MaybeTable a -> MaybeTable b

liftA2 :: (a -> b -> c) -> MaybeTable a -> MaybeTable b -> MaybeTable c

(*>) :: MaybeTable a -> MaybeTable b -> MaybeTable b

(<*) :: MaybeTable a -> MaybeTable b -> MaybeTable a

Apply MaybeTable Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

(<.>) :: MaybeTable (a -> b) -> MaybeTable a -> MaybeTable b

(.>) :: MaybeTable a -> MaybeTable b -> MaybeTable b

(<.) :: MaybeTable a -> MaybeTable b -> MaybeTable a

liftF2 :: (a -> b -> c) -> MaybeTable a -> MaybeTable b -> MaybeTable c

Bind MaybeTable Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

(>>-) :: MaybeTable a -> (a -> MaybeTable b) -> MaybeTable b

join :: MaybeTable (MaybeTable a) -> MaybeTable a

AlternativeTable MaybeTable Source # 
Instance details

Defined in Rel8.Table.Maybe

AltTable MaybeTable Source # 
Instance details

Defined in Rel8.Table.Maybe

(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 # 
Instance details

Defined in Rel8.Table.Maybe

(Table context a, Labelable context, Nullifiable context, ConstrainTag context MaybeTag) => Table context (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Associated Types

type Columns (MaybeTable a) :: HTable Source #

type Context (MaybeTable a) :: Context Source #

type Unreify (MaybeTable a) Source #

Methods

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 (Expr :: X -> Type) a, Semigroup a) => Semigroup (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

(<>) :: MaybeTable a -> MaybeTable a -> MaybeTable a

sconcat :: NonEmpty (MaybeTable a) -> MaybeTable a

stimes :: Integral b => b -> MaybeTable a -> MaybeTable a

(Table (Expr :: X -> Type) a, Semigroup a) => Monoid (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

EqTable a => EqTable (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

eqTable :: Columns (MaybeTable a) (Dict (ConstrainDBType DBEq))

OrdTable a => OrdTable (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

ordTable :: Columns (MaybeTable a) (Dict (ConstrainDBType DBOrd))

ToExprs exprs a => ToExprs (MaybeTable exprs) (Maybe a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

fromResult :: Columns (MaybeTable exprs) (Col Result) -> Maybe a Source #

toResult :: Maybe a -> Columns (MaybeTable exprs) (Col Result) Source #

type Columns (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

type Context (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

type Unreify (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

type FromExprs (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

type FromExprs (MaybeTable a) = Maybe (FromExprs a)

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 JOINs.

catMaybeTable :: MaybeTable a -> Query a Source #

Filter out MaybeTables, 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 MaybeTables.

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.

nameMaybeTable :: Name (Maybe MaybeTag) -> a -> MaybeTable a Source #

EitherTable

data EitherTable a b Source #

Instances

Instances details
Bifunctor EitherTable Source # 
Instance details

Defined in Rel8.Table.Either

Methods

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 # 
Instance details

Defined in Rel8.Table.Either

(Table context a, Table context b, Labelable context, Nullifiable context, ConstrainTag context EitherTag) => Table context (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

Associated Types

type Columns (EitherTable a b) :: HTable Source #

type Context (EitherTable a b) :: Context Source #

type Unreify (EitherTable a b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.Either

Methods

(>>=) :: 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 # 
Instance details

Defined in Rel8.Table.Either

Methods

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 # 
Instance details

Defined in Rel8.Table.Either

Methods

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 # 
Instance details

Defined in Rel8.Table.Either

Methods

(<.>) :: 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 # 
Instance details

Defined in Rel8.Table.Either

Methods

(>>-) :: 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 # 
Instance details

Defined in Rel8.Table.Either

Methods

(<>) :: 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 # 
Instance details

Defined in Rel8.Table.Either

Methods

eqTable :: Columns (EitherTable a b) (Dict (ConstrainDBType DBEq))

(OrdTable a, OrdTable b) => OrdTable (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

Methods

ordTable :: Columns (EitherTable a b) (Dict (ConstrainDBType DBOrd))

type Columns (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

type Columns (EitherTable a b)
type Context (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

type Context (EitherTable a b) = Context a
type Unreify (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

type Unreify (EitherTable a b)
type FromExprs (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

type FromExprs (EitherTable a b) = Either (FromExprs a) (FromExprs b)

eitherTable :: Table Expr c => (a -> c) -> (b -> c) -> EitherTable a b -> c 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

Instances details
Bifunctor TheseTable Source # 
Instance details

Defined in Rel8.Table.These

Methods

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 # 
Instance details

Defined in Rel8.Table.These

(Table context a, Table context b, Labelable context, Nullifiable context, ConstrainTag context MaybeTag) => Table context (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

Associated Types

type Columns (TheseTable a b) :: HTable Source #

type Context (TheseTable a b) :: Context Source #

type Unreify (TheseTable a b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.These

Methods

(>>=) :: 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 # 
Instance details

Defined in Rel8.Table.These

Methods

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 # 
Instance details

Defined in Rel8.Table.These

Methods

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 # 
Instance details

Defined in Rel8.Table.These

Methods

(<.>) :: 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 # 
Instance details

Defined in Rel8.Table.These

Methods

(>>-) :: 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 # 
Instance details

Defined in Rel8.Table.These

Methods

(<>) :: 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 # 
Instance details

Defined in Rel8.Table.These

Methods

eqTable :: Columns (TheseTable a b) (Dict (ConstrainDBType DBEq))

(OrdTable a, OrdTable b) => OrdTable (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

Methods

ordTable :: Columns (TheseTable a b) (Dict (ConstrainDBType DBOrd))

type Columns (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

type Columns (TheseTable a b)
type Context (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

type Context (TheseTable a b) = Context a
type Unreify (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

type Unreify (TheseTable a b)
type FromExprs (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

type FromExprs (TheseTable a b) = These (FromExprs a) (FromExprs b)

theseTable :: Table Expr c => (a -> c) -> (b -> c) -> (a -> b -> c) -> TheseTable a b -> c Source #

thoseTable :: a -> b -> TheseTable a 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.

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

data ListTable a Source #

A ListTable value contains zero or more instances of a. You construct ListTables with many or listAgg.

Instances

Instances details
AlternativeTable ListTable Source # 
Instance details

Defined in Rel8.Table.List

AltTable ListTable Source # 
Instance details

Defined in Rel8.Table.List

Methods

(<|>:) :: Table Expr a => ListTable a -> ListTable a -> ListTable a Source #

(Unreifies from a, Unreifies to b, Recontextualize from to a b) => Recontextualize from to (ListTable a) (ListTable b) Source # 
Instance details

Defined in Rel8.Table.List

(Table context a, Unreifies context a) => Table context (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

Associated Types

type Columns (ListTable a) :: HTable Source #

type Context (ListTable a) :: Context Source #

type Unreify (ListTable a) Source #

Methods

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 #

Table (Expr :: X -> Type) a => Semigroup (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

Methods

(<>) :: ListTable a -> ListTable a -> ListTable a

sconcat :: NonEmpty (ListTable a) -> ListTable a

stimes :: Integral b => b -> ListTable a -> ListTable a

Table (Expr :: X -> Type) a => Monoid (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

EqTable a => EqTable (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

Methods

eqTable :: Columns (ListTable a) (Dict (ConstrainDBType DBEq))

OrdTable a => OrdTable (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

Methods

ordTable :: Columns (ListTable a) (Dict (ConstrainDBType DBOrd))

ToExprs exprs a => ToExprs (ListTable exprs) [a] Source # 
Instance details

Defined in Rel8.Table.List

Methods

fromResult :: Columns (ListTable exprs) (Col Result) -> [a] Source #

toResult :: [a] -> Columns (ListTable exprs) (Col Result) Source #

type Columns (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

type Context (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

type Unreify (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

type FromExprs (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

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.

catList :: Sql DBType a => Expr [a] -> Query (Expr a) Source #

NonEmptyTable

data NonEmptyTable a Source #

A NonEmptyTable value contains one or more instances of a. You construct NonEmptyTables with some or nonEmptyAgg.

Instances

Instances details
AltTable NonEmptyTable Source # 
Instance details

Defined in Rel8.Table.NonEmpty

(Unreifies from a, Unreifies to b, Recontextualize from to a b) => Recontextualize from to (NonEmptyTable a) (NonEmptyTable b) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

(Table context a, Unreifies context a) => Table context (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

Associated Types

type Columns (NonEmptyTable a) :: HTable Source #

type Context (NonEmptyTable a) :: Context Source #

type Unreify (NonEmptyTable a) Source #

Methods

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 (Expr :: X -> Type) a => Semigroup (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

Methods

(<>) :: NonEmptyTable a -> NonEmptyTable a -> NonEmptyTable a

sconcat :: NonEmpty (NonEmptyTable a) -> NonEmptyTable a

stimes :: Integral b => b -> NonEmptyTable a -> NonEmptyTable a

EqTable a => EqTable (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

Methods

eqTable :: Columns (NonEmptyTable a) (Dict (ConstrainDBType DBEq))

OrdTable a => OrdTable (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

Methods

ordTable :: Columns (NonEmptyTable a) (Dict (ConstrainDBType DBOrd))

ToExprs exprs a => ToExprs (NonEmptyTable exprs) (NonEmpty a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

Methods

fromResult :: Columns (NonEmptyTable exprs) (Col Result) -> NonEmpty a Source #

toResult :: NonEmpty a -> Columns (NonEmptyTable exprs) (Col Result) Source #

type Columns (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

type Context (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

type Unreify (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

type FromExprs (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

type FromExprs (NonEmptyTable a) = NonEmpty (FromExprs a)

nonEmptyTable :: Table Expr a => NonEmpty a -> NonEmptyTable a Source #

insertNonEmptyTable :: Inserts exprs inserts => NonEmpty exprs -> NonEmptyTable inserts 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 NonEmptyTables. 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.

catNonEmpty :: Sql DBType a => Expr (NonEmpty a) -> Query (Expr a) Source #

ADT

data ADT t context Source #

Instances

Instances details
ADTable t => Rel8able (ADT t) Source # 
Instance details

Defined in Rel8.Table.ADT

Associated Types

type GColumns (ADT t) :: HTable

Methods

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 # 
Instance details

Defined in Rel8.Table.ADT

Associated Types

type Rep (ADT t context) :: Type -> Type

Methods

from :: ADT t context -> Rep (ADT t context) x

to :: Rep (ADT t context) x -> ADT t context

type Rep (ADT t context) Source # 
Instance details

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

Instances details
(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 # 
Instance details

Defined in Rel8.Table.ADT

type BuildADT t name = GGBuild 'Sum name (ADTRep t) (ADT t Expr) Source #

buildADT :: forall t name. BuildableADT t name => BuildADT t name Source #

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 InsertADT t name = GGInsert 'Sum name (ADTRep t) (ADT t Insert) Source #

insertADT :: forall t name. BuildableADT t name => InsertADT t name Source #

type NameADT t = GGName 'Sum (ADTRep t) (ADT t Name) Source #

nameADT :: forall t. ConstructableADT t => NameADT t 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

data HKD a f Source #

Instances

Instances details
HKDable a => Rel8able (HKD a) Source # 
Instance details

Defined in Rel8.Table.HKD

Associated Types

type GColumns (HKD a) :: HTable

Methods

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 # 
Instance details

Defined in Rel8.Table.HKD

Associated Types

type Rep (HKD a f) :: Type -> Type

Methods

from :: HKD a f -> Rep (HKD a f) x

to :: Rep (HKD a f) x -> HKD a f

type Rep (HKD a f) Source # 
Instance details

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

Instances details
(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 # 
Instance details

Defined in Rel8.Table.HKD

fromHKD :: HKDable a => HKD a Result -> a Source #

toHKD :: HKDable a => a -> HKD a Result Source #

type BuildHKD a name = GGBuild (GAlgebra (Rep a)) name (HKDRep a) (HKD a Expr) Source #

buildHKD :: forall a name. BuildableHKD a name => BuildHKD a name Source #

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 InsertHKD a name = GGInsert (GAlgebra (Rep a)) name (HKDRep a) (HKD a Insert) Source #

insertHKD :: forall a name. BuildableHKD a name => InsertHKD a name Source #

type NameHKD a = GGName (GAlgebra (Rep a)) (HKDRep a) (HKD a Name) Source #

nameHKD :: forall a. ConstructableHKD a => NameHKD a 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.

Constructors

TableSchema 

Fields

  • name :: String

    The name of the table.

  • schema :: Maybe String

    The schema that this table belongs to. If Nothing, whatever is on the connection's search_path will be used.

  • columns :: names

    The columns of the table. Typically you would use a a higher-kinded data type here, parameterized by the ColumnSchema functor.

Instances

Instances details
Functor TableSchema Source # 
Instance details

Defined in Rel8.Schema.Table

Methods

fmap :: (a -> b) -> TableSchema a -> TableSchema b

(<$) :: a -> TableSchema b -> TableSchema a

data Name a Source #

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

Instances details
Show (Name a) Source # 
Instance details

Defined in Rel8.Schema.Name

Methods

showsPrec :: Int -> Name a -> ShowS

show :: Name a -> String

showList :: [Name a] -> ShowS

k ~ Type => IsString (Name a) Source # 
Instance details

Defined in Rel8.Schema.Name

Methods

fromString :: String -> Name a

type Columns (Name a) Source # 
Instance details

Defined in Rel8.Schema.Name

type Columns (Name a)
type Context (Name a) Source # 
Instance details

Defined in Rel8.Schema.Name

type Context (Name a)
type Unreify (Name a) Source # 
Instance details

Defined in Rel8.Schema.Name

type Unreify (Name a)

namesFromLabelsWith :: Table Name a => (NonEmpty String -> String) -> a Source #

Expressions

data Expr a Source #

Typed SQL expressions.

Instances

Instances details
(arg ~ Expr a, Sql DBType b) => Function arg (Expr b) Source # 
Instance details

Defined in Rel8.Expr.Function

Methods

applyArgument :: ([PrimExpr] -> PrimExpr) -> arg -> Expr b

Sql DBFloating a => Floating (Expr a) Source # 
Instance details

Defined in Rel8.Expr

Methods

pi :: Expr a

exp :: Expr a -> Expr a

log :: Expr a -> Expr a

sqrt :: Expr a -> Expr a

(**) :: Expr a -> Expr a -> Expr a

logBase :: Expr a -> Expr a -> Expr a

sin :: Expr a -> Expr a

cos :: Expr a -> Expr a

tan :: Expr a -> Expr a

asin :: Expr a -> Expr a

acos :: Expr a -> Expr a

atan :: Expr a -> Expr a

sinh :: Expr a -> Expr a

cosh :: Expr a -> Expr a

tanh :: Expr a -> Expr a

asinh :: Expr a -> Expr a

acosh :: Expr a -> Expr a

atanh :: Expr a -> Expr a

log1p :: Expr a -> Expr a

expm1 :: Expr a -> Expr a

log1pexp :: Expr a -> Expr a

log1mexp :: Expr a -> Expr a

Sql DBFractional a => Fractional (Expr a) Source # 
Instance details

Defined in Rel8.Expr

Methods

(/) :: Expr a -> Expr a -> Expr a

recip :: Expr a -> Expr a

fromRational :: Rational -> Expr a

Sql DBNum a => Num (Expr a) Source # 
Instance details

Defined in Rel8.Expr

Methods

(+) :: Expr a -> Expr a -> Expr a

(-) :: Expr a -> Expr a -> Expr a

(*) :: Expr a -> Expr a -> Expr a

negate :: Expr a -> Expr a

abs :: Expr a -> Expr a

signum :: Expr a -> Expr a

fromInteger :: Integer -> Expr a

Show (Expr a) Source # 
Instance details

Defined in Rel8.Expr

Methods

showsPrec :: Int -> Expr a -> ShowS

show :: Expr a -> String

showList :: [Expr a] -> ShowS

(Sql IsString a, Sql DBType a) => IsString (Expr a) Source # 
Instance details

Defined in Rel8.Expr

Methods

fromString :: String -> Expr a

Sql DBSemigroup a => Semigroup (Expr a) Source # 
Instance details

Defined in Rel8.Expr

Methods

(<>) :: Expr a -> Expr a -> Expr a

sconcat :: NonEmpty (Expr a) -> Expr a

stimes :: Integral b => b -> Expr a -> Expr a

Sql DBMonoid a => Monoid (Expr a) Source # 
Instance details

Defined in Rel8.Expr

Methods

mempty :: Expr a

mappend :: Expr a -> Expr a -> Expr a

mconcat :: [Expr a] -> Expr a

Sql DBEq a => EqTable (Expr a) Source # 
Instance details

Defined in Rel8.Table.Eq

Methods

eqTable :: Columns (Expr a) (Dict (ConstrainDBType DBEq))

Sql DBOrd a => OrdTable (Expr a) Source # 
Instance details

Defined in Rel8.Table.Ord

Methods

ordTable :: Columns (Expr a) (Dict (ConstrainDBType DBOrd))

Sql DBType a => Serializable (Expr a) a Source # 
Instance details

Defined in Rel8.Table.Serialize

(Sql DBType a, NotNull a, x ~ NonEmpty a) => ToExprs (Expr x) (NonEmpty a) Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns (Expr x) (Col Result) -> NonEmpty a Source #

toResult :: NonEmpty a -> Columns (Expr x) (Col Result) Source #

(Sql DBType a, NotNull a, x ~ Maybe a) => ToExprs (Expr x) (Maybe a) Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns (Expr x) (Col Result) -> Maybe a Source #

toResult :: Maybe a -> Columns (Expr x) (Col Result) Source #

(Sql DBType a, x ~ [a]) => ToExprs (Expr x) [a] Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns (Expr x) (Col Result) -> [a] Source #

toResult :: [a] -> Columns (Expr x) (Col Result) Source #

type Columns (Expr a) Source # 
Instance details

Defined in Rel8.Expr

type Columns (Expr a)
type Context (Expr a) Source # 
Instance details

Defined in Rel8.Expr

type Context (Expr a)
type Unreify (Expr a) Source # 
Instance details

Defined in Rel8.Expr

type Unreify (Expr a)
type FromExprs (Expr a) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (Expr a) = a

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

Instances details
(constraint (Unnullify a), Nullable a) => Sql constraint a Source # 
Instance details

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

null :: DBType a => Expr (Maybe a) Source #

Corresponds to SQL 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.

isNull :: Expr (Maybe a) -> Expr Bool Source #

Like isNothing, but for null.

isNonNull :: Expr (Maybe a) -> Expr Bool Source #

Like isJust, but for 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.

catNull :: Expr (Maybe a) -> Query (Expr a) Source #

Filter a Query that might return null to a Query without any nulls.

Corresponds to catMaybes.

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

Instances details
DBEq Bool Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Char Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Double Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Float Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Int16 Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Int32 Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Int64 Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq ByteString Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Scientific Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Text Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq ByteString Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Text Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq CalendarDiffTime Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq UTCTime Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Day Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq LocalTime Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq TimeOfDay Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq Value Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq UUID Source # 
Instance details

Defined in Rel8.Type.Eq

Sql DBEq a => DBEq [a] Source # 
Instance details

Defined in Rel8.Type.Eq

Sql DBEq a => DBEq (NonEmpty a) Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq (CI Text) Source # 
Instance details

Defined in Rel8.Type.Eq

DBEq (CI Text) Source # 
Instance details

Defined in Rel8.Type.Eq

DBEnum a => DBEq (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

(DBComposite a, EqTable (HKD a (Expr :: X -> Type))) => DBEq (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

true :: Expr Bool Source #

The SQL true literal.

false :: Expr Bool Source #

The SQL false literal.

not_ :: Expr Bool -> Expr Bool Source #

The SQL NOT operator.

(&&.) :: Expr Bool -> Expr Bool -> Expr Bool infixr 3 Source #

The SQL AND operator.

and_ :: Foldable f => f (Expr Bool) -> Expr Bool Source #

Fold AND over a collection of expressions.

(||.) :: Expr Bool -> Expr Bool -> Expr Bool infixr 2 Source #

The SQL OR operator.

or_ :: Foldable f => f (Expr Bool) -> Expr Bool Source #

Fold OR over a collection of expressions.

(==.) :: 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.

in_ :: forall a f. (Sql DBEq a, Foldable f) => Expr a -> f (Expr a) -> Expr Bool Source #

Like the SQL IN operator, but implemented by folding over a list with ==. and ||..

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

Instances details
DBOrd Bool Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Char Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Double Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Float Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Int16 Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Int32 Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Int64 Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd ByteString Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Scientific Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Text Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd ByteString Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Text Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd CalendarDiffTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd UTCTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd Day Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd LocalTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd TimeOfDay Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd UUID Source # 
Instance details

Defined in Rel8.Type.Ord

Sql DBOrd a => DBOrd [a] Source # 
Instance details

Defined in Rel8.Type.Ord

Sql DBOrd a => DBOrd (NonEmpty a) Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd (CI Text) Source # 
Instance details

Defined in Rel8.Type.Ord

DBOrd (CI Text) Source # 
Instance details

Defined in Rel8.Type.Ord

DBEnum a => DBOrd (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBOrd (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

(<.) :: 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.

Minimal complete definition

applyArgument

Instances

Instances details
(arg ~ Expr a, Function args res) => Function arg (args -> res) Source # 
Instance details

Defined in Rel8.Expr.Function

Methods

applyArgument :: ([PrimExpr] -> PrimExpr) -> arg -> args -> res

(arg ~ Expr a, Sql DBType b) => Function arg (Expr b) Source # 
Instance details

Defined in Rel8.Expr.Function

Methods

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

data Query a Source #

The Query monad allows you to compose a SELECT query. This monad has semantics similar to the list ([]) monad.

Instances

Instances details
Monad Query Source # 
Instance details

Defined in Rel8.Query

Methods

(>>=) :: Query a -> (a -> Query b) -> Query b

(>>) :: Query a -> Query b -> Query b

return :: a -> Query a

Functor Query Source # 
Instance details

Defined in Rel8.Query

Methods

fmap :: (a -> b) -> Query a -> Query b

(<$) :: a -> Query b -> Query a

Applicative Query Source # 
Instance details

Defined in Rel8.Query

Methods

pure :: a -> Query a

(<*>) :: Query (a -> b) -> Query a -> Query b

liftA2 :: (a -> b -> c) -> Query a -> Query b -> Query c

(*>) :: Query a -> Query b -> Query b

(<*) :: Query a -> Query b -> Query a

Apply Query Source # 
Instance details

Defined in Rel8.Query

Methods

(<.>) :: Query (a -> b) -> Query a -> Query b

(.>) :: Query a -> Query b -> Query b

(<.) :: Query a -> Query b -> Query a

liftF2 :: (a -> b -> c) -> Query a -> Query b -> Query c

Bind Query Source # 
Instance details

Defined in Rel8.Query

Methods

(>>-) :: Query a -> (a -> Query b) -> Query b

join :: Query (Query a) -> Query a

AlternativeTable Query Source #

emptyTable = values [].

Instance details

Defined in Rel8.Query

Methods

emptyTable :: Table Expr a => Query a Source #

AltTable Query Source #

<|>: = unionAll.

Instance details

Defined in Rel8.Query

Methods

(<|>:) :: Table Expr a => Query a -> Query a -> Query a Source #

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 #

Selects a b means that a is a schema (i.e., a Table of Names) for the Expr columns in b.

Instances

Instances details
Recontextualize (Name :: X -> Type) (Expr :: X -> Type) names exprs => Selects names exprs Source # 
Instance details

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

filter :: (a -> Expr Bool) -> a -> Query a Source #

filter f x will be a zero-row query when f x is False, and will return x unchanged when f x is True. This is similar to guard, but as the predicate is separate from the argument, it is easy to use in a pipeline of Query transformations.

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

exists :: Query a -> Query (Expr Bool) Source #

Checks if a query returns at least one row.

with :: (a -> Query b) -> a -> Query a Source #

with is similar to filter, but allows the predicate to be a full query.

with f a = a <$ whereExists (f a), but this form matches filter.

withBy :: (a -> b -> Expr Bool) -> Query b -> a -> Query a Source #

Like with, but with a custom membership test.

without :: (a -> Query b) -> a -> Query a Source #

Filter rows where a -> Query b yields no rows.

withoutBy :: (a -> b -> Expr Bool) -> Query b -> a -> Query a Source #

Like without, but with a custom membership test.

Aggregation

data Aggregate a Source #

An Aggregate a describes how to aggregate Tables 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 Aggregates using the . combinator.

Instances

Instances details
type Columns (Aggregate a) Source # 
Instance details

Defined in Rel8.Aggregate

type Context (Aggregate a) Source # 
Instance details

Defined in Rel8.Aggregate

type Unreify (Aggregate a) Source # 
Instance details

Defined in Rel8.Aggregate

class Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs Source #

Aggregates a b means that the columns in a are all Aggregate Exprs for the columns in b.

Instances

Instances details
Recontextualize (Aggregate :: X -> Type) (Expr :: X -> Type) aggregates exprs => Aggregates aggregates exprs Source # 
Instance details

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

Instances details
DBMax Bool Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Char Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Double Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Float Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Int16 Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Int32 Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Int64 Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax ByteString Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Scientific Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Text Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax ByteString Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Text Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax CalendarDiffTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax UTCTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax Day Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax LocalTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax TimeOfDay Source # 
Instance details

Defined in Rel8.Type.Ord

Sql DBMax a => DBMax [a] Source # 
Instance details

Defined in Rel8.Type.Ord

Sql DBMax a => DBMax (NonEmpty a) Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax (CI Text) Source # 
Instance details

Defined in Rel8.Type.Ord

DBMax (CI Text) Source # 
Instance details

Defined in Rel8.Type.Ord

DBEnum a => DBMax (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBMax (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

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

Instances details
DBMin Bool Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Char Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Double Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Float Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Int16 Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Int32 Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Int64 Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin ByteString Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Scientific Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Text Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin ByteString Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Text Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin CalendarDiffTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin UTCTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin Day Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin LocalTime Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin TimeOfDay Source # 
Instance details

Defined in Rel8.Type.Ord

Sql DBMin a => DBMin [a] Source # 
Instance details

Defined in Rel8.Type.Ord

Sql DBMin a => DBMin (NonEmpty a) Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin (CI Text) Source # 
Instance details

Defined in Rel8.Type.Ord

DBMin (CI Text) Source # 
Instance details

Defined in Rel8.Type.Ord

DBEnum a => DBMin (Enum a) Source # 
Instance details

Defined in Rel8.Type.Enum

(DBComposite a, OrdTable (HKD a (Expr :: X -> Type))) => DBMin (Composite a) Source # 
Instance details

Defined in Rel8.Type.Composite

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

Instances details
DBSum Double Source # 
Instance details

Defined in Rel8.Type.Sum

DBSum Float Source # 
Instance details

Defined in Rel8.Type.Sum

DBSum Int16 Source # 
Instance details

Defined in Rel8.Type.Sum

DBSum Int32 Source # 
Instance details

Defined in Rel8.Type.Sum

DBSum Int64 Source # 
Instance details

Defined in Rel8.Type.Sum

DBSum Scientific Source # 
Instance details

Defined in Rel8.Type.Sum

DBSum CalendarDiffTime Source # 
Instance details

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

Instances details
DBString ByteString Source # 
Instance details

Defined in Rel8.Type.String

DBString Text Source # 
Instance details

Defined in Rel8.Type.String

DBString ByteString Source # 
Instance details

Defined in Rel8.Type.String

DBString Text Source # 
Instance details

Defined in Rel8.Type.String

DBString (CI Text) Source # 
Instance details

Defined in Rel8.Type.String

DBString (CI Text) Source # 
Instance details

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)

countStar :: Aggregate Int64 Source #

Corresponds to COUNT(*).

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.

and :: Expr Bool -> Aggregate Bool Source #

Corresponds to bool_and.

or :: Expr Bool -> Aggregate Bool Source #

Corresponds to bool_or.

Ordering

orderBy :: Order a -> Query a -> Query a Source #

Order the rows returned by a query.

data Order a Source #

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.

Instances

Instances details
Contravariant Order Source # 
Instance details

Defined in Rel8.Order

Methods

contramap :: (a -> b) -> Order b -> Order a

(>$) :: b -> Order b -> Order a

Decidable Order Source # 
Instance details

Defined in Rel8.Order

Methods

lose :: (a -> Void) -> Order a

choose :: (a -> Either b c) -> Order b -> Order c -> Order a

Divisible Order Source # 
Instance details

Defined in Rel8.Order

Methods

divide :: (a -> (b, c)) -> Order b -> Order c -> Order a

conquer :: Order a

Semigroup (Order a) Source # 
Instance details

Defined in Rel8.Order

Methods

(<>) :: Order a -> Order a -> Order a

sconcat :: NonEmpty (Order a) -> Order a

stimes :: Integral b => b -> Order a -> Order a

Monoid (Order a) Source # 
Instance details

Defined in Rel8.Order

Methods

mempty :: Order a

mappend :: Order a -> Order a -> Order a

mconcat :: [Order a] -> Order a

asc :: DBOrd a => Order (Expr a) Source #

Sort a column in ascending order.

desc :: DBOrd a => Order (Expr a) Source #

Sort a column in descending order.

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

Instances details
(ToExprs exprs a, a ~ FromExprs exprs) => Serializable exprs a Source # 
Instance details

Defined in Rel8.Table.Serialize

Sql DBType a => Serializable (Expr a) a Source # 
Instance details

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

data Insert a where Source #

The constituent parts of a SQL INSERT statement.

Constructors

Insert 

Fields

  • :: (Selects names exprs, Inserts exprs inserts)
     
  • => { into :: TableSchema names

    Which table to insert into.

  •    , rows :: [inserts]

    The rows to insert.

  •    , onConflict :: OnConflict

    What to do if the inserted rows conflict with data already in the table.

  •    , returning :: Returning names a

    What information to return on completion.

  •    } -> Insert a
     

data OnConflict Source #

OnConflict allows you to add an ON CONFLICT clause to an INSERT statement.

Constructors

Abort
ON CONFLICT ABORT
DoNothing
ON CONFLICT DO NOTHING

insert :: Connection -> Insert a -> IO a Source #

Run an INSERT statement

toInsert :: Inserts exprs inserts => exprs -> inserts Source #

toInsert converts a Table of Exprs 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 Exprs 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

data Delete a where Source #

The constituent parts of a DELETE statement.

Constructors

Delete 

Fields

delete :: Connection -> Delete a -> IO a Source #

Run a DELETE statement.

UPDATE

update :: Connection -> Update a -> IO a Source #

Run an UPDATE statement.

data Update a where Source #

The constituent parts of an UPDATE statement.

Constructors

Update 

Fields

.. 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).

Constructors

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

Instances details
(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 # 
Instance details

Defined in Rel8.Table.Maybe

(Unreifies from a, Unreifies to b, Recontextualize from to a b) => Recontextualize from to (NonEmptyTable a) (NonEmptyTable b) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

(Unreifies from a, Unreifies to b, Recontextualize from to a b) => Recontextualize from to (ListTable a) (ListTable b) Source # 
Instance details

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 # 
Instance details

Defined in Rel8.Table.Rel8able

Sql DBType a => Recontextualize Result Result (Identity a) (Identity a) Source # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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

Instances details
Nullable' (IsMaybe a) a => Nullable a Source # 
Instance details

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

Instances details
(Nullable a, IsMaybe a ~ 'False) => NotNull a Source # 
Instance details

Defined in Rel8.Schema.Null

class HTable t Source #

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 #

Minimal complete definition

labeler, unlabeler

Instances

Instances details
Labelable Result Source # 
Instance details

Defined in Rel8.Schema.Context.Label

Methods

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 #

Minimal complete definition

Nothing

Methods

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

Instances details
(Sql DBType a, x ~ Expr a) => ToExprs x a Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> a Source #

toResult :: a -> Columns x (Col Result) Source #

(HTable t, result ~ Col Result, x ~ t (Col (Expr :: X -> Type))) => ToExprs x (t result) Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> t result Source #

toResult :: t result -> Columns x (Col 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 # 
Instance details

Defined in Rel8.Table.HKD

Methods

fromResult :: Columns x (Col Result) -> HKDT a Source #

toResult :: HKDT a -> Columns x (Col Result) Source #

(x ~ t' (Expr :: X -> Type), result ~ Result, ToExprs' (Algebra t) t' t) => ToExprs x (t result) Source # 
Instance details

Defined in Rel8.Table.Rel8able

Methods

fromResult :: Columns x (Col Result) -> t result Source #

toResult :: t result -> Columns x (Col Result) Source #

(ToExprs exprs1 a, ToExprs exprs2 b, x ~ (exprs1, exprs2)) => ToExprs x (a, b) Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> (a, b) Source #

toResult :: (a, b) -> Columns x (Col Result) Source #

(ToExprs exprs1 a, ToExprs exprs2 b, x ~ TheseTable exprs1 exprs2) => ToExprs x (These a b) Source # 
Instance details

Defined in Rel8.Table.These

Methods

fromResult :: Columns x (Col Result) -> These a b Source #

toResult :: These a b -> Columns x (Col Result) Source #

(ToExprs exprs1 a, ToExprs exprs2 b, x ~ EitherTable exprs1 exprs2) => ToExprs x (Either a b) Source # 
Instance details

Defined in Rel8.Table.Either

Methods

fromResult :: Columns x (Col Result) -> Either a b Source #

toResult :: Either a b -> Columns x (Col Result) Source #

(ToExprs exprs1 a, ToExprs exprs2 b, ToExprs exprs3 c, x ~ (exprs1, exprs2, exprs3)) => ToExprs x (a, b, c) Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> (a, b, c) Source #

toResult :: (a, b, c) -> Columns x (Col Result) 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 # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> (a, b, c, d) Source #

toResult :: (a, b, c, d) -> Columns x (Col Result) 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 # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> (a, b, c, d, e) Source #

toResult :: (a, b, c, d, e) -> Columns x (Col Result) 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 # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> (a, b, c, d, e, f) Source #

toResult :: (a, b, c, d, e, f) -> Columns x (Col Result) 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 # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns x (Col Result) -> (a, b, c, d, e, f, g) Source #

toResult :: (a, b, c, d, e, f, g) -> Columns x (Col Result) Source #

ToExprs exprs a => ToExprs (MaybeTable exprs) (Maybe a) Source # 
Instance details

Defined in Rel8.Table.Maybe

Methods

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 # 
Instance details

Defined in Rel8.Table.NonEmpty

Methods

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 # 
Instance details

Defined in Rel8.Table.List

Methods

fromResult :: Columns (ListTable exprs) (Col Result) -> [a] Source #

toResult :: [a] -> Columns (ListTable exprs) (Col Result) Source #

(Sql DBType a, NotNull a, x ~ NonEmpty a) => ToExprs (Expr x) (NonEmpty a) Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns (Expr x) (Col Result) -> NonEmpty a Source #

toResult :: NonEmpty a -> Columns (Expr x) (Col Result) Source #

(Sql DBType a, NotNull a, x ~ Maybe a) => ToExprs (Expr x) (Maybe a) Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns (Expr x) (Col Result) -> Maybe a Source #

toResult :: Maybe a -> Columns (Expr x) (Col Result) Source #

(Sql DBType a, x ~ [a]) => ToExprs (Expr x) [a] Source # 
Instance details

Defined in Rel8.Table.Serialize

Methods

fromResult :: Columns (Expr x) (Col Result) -> [a] Source #

toResult :: [a] -> Columns (Expr x) (Col Result) Source #

type family FromExprs a Source #

Instances

Instances details
type FromExprs (MaybeTable a) Source # 
Instance details

Defined in Rel8.Table.Maybe

type FromExprs (MaybeTable a) = Maybe (FromExprs a)
type FromExprs (NonEmptyTable a) Source # 
Instance details

Defined in Rel8.Table.NonEmpty

type FromExprs (NonEmptyTable a) = NonEmpty (FromExprs a)
type FromExprs (ListTable a) Source # 
Instance details

Defined in Rel8.Table.List

type FromExprs (a, b) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (a, b) = (FromExprs a, FromExprs b)
type FromExprs (Expr a) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (Expr a) = a
type FromExprs (TheseTable a b) Source # 
Instance details

Defined in Rel8.Table.These

type FromExprs (TheseTable a b) = These (FromExprs a) (FromExprs b)
type FromExprs (EitherTable a b) Source # 
Instance details

Defined in Rel8.Table.Either

type FromExprs (EitherTable a b) = Either (FromExprs a) (FromExprs b)
type FromExprs (a, b, c) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (a, b, c) = (FromExprs a, FromExprs b, FromExprs c)
type FromExprs (a, b, c, d) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (a, b, c, d) = (FromExprs a, FromExprs b, FromExprs c, FromExprs d)
type FromExprs (a, b, c, d, e) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (a, b, c, d, e) = (FromExprs a, FromExprs b, FromExprs c, FromExprs d, FromExprs e)
type FromExprs (a, b, c, d, e, f) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (a, b, c, d, e, f) = (FromExprs a, FromExprs b, FromExprs c, FromExprs d, FromExprs e, FromExprs f)
type FromExprs (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Rel8.Table.Serialize

type FromExprs (a, b, c, d, e, f, g) = (FromExprs a, FromExprs b, FromExprs c, FromExprs d, FromExprs e, FromExprs f, FromExprs g)

data Result a Source #

Instances

Instances details
Labelable Result Source # 
Instance details

Defined in Rel8.Schema.Context.Label

Methods

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 # 
Instance details

Defined in Rel8.Table.Recontextualize

Table Result a => Table Result [a] Source # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns [a] :: HTable Source #

type Context [a] :: Context Source #

type Unreify [a] Source #

Methods

toColumns :: [a] -> Columns [a] (Col Result) Source #

fromColumns :: Columns [a] (Col Result) -> [a] Source #

reify :: forall (ctx :: Context). (Result :~: Reify ctx) -> Unreify [a] -> [a] Source #

unreify :: forall (ctx :: Context). (Result :~: Reify ctx) -> [a] -> Unreify [a] Source #

Table Result a => Table Result (Maybe a) Source # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (Maybe a) :: HTable Source #

type Context (Maybe a) :: Context Source #

type Unreify (Maybe a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (NonEmpty a) :: HTable Source #

type Context (NonEmpty a) :: Context Source #

type Unreify (NonEmpty a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (Identity a) :: HTable Source #

type Context (Identity a) :: Context Source #

type Unreify (Identity a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.HKD

Associated Types

type Columns (HKDT a) :: HTable Source #

type Context (HKDT a) :: Context Source #

type Unreify (HKDT a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (Either a b) :: HTable Source #

type Context (Either a b) :: Context Source #

type Unreify (Either a b) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table

Associated Types

type Columns (These a b) :: HTable Source #

type Context (These a b) :: Context Source #

type Unreify (These a b) Source #

Methods

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 #

newtype HKDT a Source #

Constructors

HKDT 

Fields

Instances

Instances details
HKDable a => Table Result (HKDT a) Source # 
Instance details

Defined in Rel8.Table.HKD

Associated Types

type Columns (HKDT a) :: HTable Source #

type Context (HKDT a) :: Context Source #

type Unreify (HKDT a) Source #

Methods

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 # 
Instance details

Defined in Rel8.Table.HKD

Methods

fromResult :: Columns x (Col Result) -> HKDT a Source #

toResult :: HKDT a -> Columns x (Col Result) Source #

type Columns (HKDT a) Source # 
Instance details

Defined in Rel8.Table.HKD

type Columns (HKDT a)
type Context (HKDT a) Source # 
Instance details

Defined in Rel8.Table.HKD

type Context (HKDT a) = Result
type Unreify (HKDT a) Source # 
Instance details

Defined in Rel8.Table.HKD

type Unreify (HKDT a) = Void