Some monad with Selda SQL capabilitites.
Instances1MonadSelda
(MonadIO m, MonadMask m) => MonadSelda (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.Internal
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Moduleselda-0.5.2.1Haskell2010
Selda is not LINQ, but they're definitely related.
Selda is a high-level EDSL for interacting with relational databases.
All database computations are performed within some monad implementing
the MonadSelda type class. The SeldaT monad over any MonadIO is the
only pre-defined instance of MonadSelda.
SeldaM is provided as a convenient short-hand for SeldaT IO.
To actually execute a database computation, you need one of the database
backends: selda-sqlite or selda-postgresql.
All Selda functions may throw SeldaError when something goes wrong. This includes database connection errors, uniqueness constraint errors, etc.
See https://selda.link/tutorial for a tutorial covering the language basics.
Some monad with Selda SQL capabilitites.
(MonadIO m, MonadMask m) => MonadSelda (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalType of database backend used by m.
Thrown by any function in SeldaT if an error occurs.
Eq SeldaErrorDefined in selda-0.5.2.1 · Database.Selda.Backend.InternalShow SeldaErrorDefined in selda-0.5.2.1 · Database.Selda.Backend.InternalException SeldaErrorDefined in selda-0.5.2.1 · Database.Selda.Backend.InternalAn error occurred when validating a database table. If this error is thrown, there is a bug in your database schema, and the particular table that triggered the error is unusable. Since validation is deterministic, this error will be thrown on every consecutive operation over the offending table.
Therefore, it is not meaningful to handle this exception in any way, just fix your bug instead.
Eq ValidationErrorDefined in selda-0.5.2.1 · Database.Selda.Table.ValidationShow ValidationErrorDefined in selda-0.5.2.1 · Database.Selda.Table.ValidationException ValidationErrorDefined in selda-0.5.2.1 · Database.Selda.Table.ValidationMonad transformer adding Selda SQL capabilities.
MonadTrans (SeldaT b)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonad m => Monad (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalFunctor m => Functor (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonadFail m => MonadFail (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalApplicative m => Applicative (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonadIO m => MonadIO (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonadCatch m => MonadCatch (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonadMask m => MonadMask (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonadThrow m => MonadThrow (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.Internal(MonadIO m, MonadMask m) => MonadSelda (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.Internaltype Backend (SeldaT b m) = bDefined in selda-0.5.2.1 · Database.Selda.Backend.InternalAny type which has a corresponding relation.
To make a Relational instance for some type, simply derive Generic.
Note that only types which have a single data constructor, and where all
fields are instances of SqlValue can be used with this module.
Attempting to use functions in this module with any type which doesn't
obey those constraints will result in a very confusing type error.
Wrapper for single column tables. Use this when you need a table with only a single column, with table or selectValues.
Only aEnum a => Enum (Only a)Defined in selda-0.5.2.1 · Database.SeldaEq a => Eq (Only a)Defined in selda-0.5.2.1 · Database.SeldaFractional a => Fractional (Only a)Defined in selda-0.5.2.1 · Database.SeldaIntegral a => Integral (Only a)Defined in selda-0.5.2.1 · Database.SeldaNum a => Num (Only a)Defined in selda-0.5.2.1 · Database.SeldaOrd a => Ord (Only a)Defined in selda-0.5.2.1 · Database.SeldaRead a => Read (Only a)Defined in selda-0.5.2.1 · Database.SeldaReal a => Real (Only a)Defined in selda-0.5.2.1 · Database.SeldaShow a => Show (Only a)Defined in selda-0.5.2.1 · Database.SeldaIsString a => IsString (Only a)Defined in selda-0.5.2.1 · Database.SeldaGeneric (Only a)Defined in selda-0.5.2.1 · Database.SeldaThe (Only a)Defined in selda-0.5.2.1 · Database.SeldaSqlType a => SqlRow (Only a)Defined in selda-0.5.2.1 · Database.Selda(TypeError ((('Text "'Only "
':<>: 'ShowType a) ':<>: 'Text "' is not a proper SQL type."
) ':$$: 'Text "Use 'the' to access the value of the column."
), Typeable a) => SqlType (Only a)Defined in selda-0.5.2.1 · Database.SeldaThe (Row s (Only a))Defined in selda-0.5.2.1 · Database.Seldatype Rep (Only a) = D1 ('MetaData "Only"
"Database.Selda"
"selda-0.5.2.1-BXeKXoDkTgT20VcSie8JWe"
'True) (C1 ('MetaCons "Only"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))Defined in selda-0.5.2.1 · Database.Seldatype TheOnly (Only a) = aDefined in selda-0.5.2.1 · Database.Seldatype TheOnly (Row s (Only a)) = Col s aDefined in selda-0.5.2.1 · Database.Seldatype family TheOnly aA database table, based on some Haskell data type.
Any single constructor type can form the basis of a table, as long as
it derives Generic and all of its fields are instances of SqlType.
Name of the table. NOT guaranteed to be a valid SQL name.
An SQL query.
Monad (Query s)Defined in selda-0.5.2.1 · Database.Selda.Query.TypeFunctor (Query s)Defined in selda-0.5.2.1 · Database.Selda.Query.TypeApplicative (Query s)Defined in selda-0.5.2.1 · Database.Selda.Query.TypeSet (Query s)Defined in selda-0.5.2.1 · Database.SeldaResult a => Preparable (Query s a)Defined in selda-0.5.2.1 · Database.Selda.PreparedA database row. A row is a collection of one or more columns.
(SqlRow a, Columns b) => Columns (Row s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Column(SqlRow a, Result b) => Result (Row s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.CompileThe (Row s (Only a))Defined in selda-0.5.2.1 · Database.SeldaColumns (Row s a)Defined in selda-0.5.2.1 · Database.Selda.ColumnSqlRow a => Result (Row s a)Defined in selda-0.5.2.1 · Database.Selda.Compiletype TheOnly (Row s (Only a)) = Col s aDefined in selda-0.5.2.1 · Database.SeldaA database column. A column is often a literal column table, but can also be an expression over such a column or a constant expression.
Mappable ColDefined in selda-0.5.2.1 · Database.Selda(SqlType a, Columns b) => Columns (Col s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Column(SqlType a, Result b) => Result (Col s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Compile(SqlType a, Preparable b) => Preparable (Col s a -> b)Defined in selda-0.5.2.1 · Database.Selda.PreparedFractional (Col s Double)Defined in selda-0.5.2.1 · Database.Selda.ColumnFractional (Col s Int)Defined in selda-0.5.2.1 · Database.Selda.Column(SqlType a, Num a) => Num (Col s a)Defined in selda-0.5.2.1 · Database.Selda.ColumnIsString (Col s Text)Defined in selda-0.5.2.1 · Database.Selda.ColumnSemigroup (Col s Text)Defined in selda-0.5.2.1 · Database.Selda · orphanMonoid (Col s Text)Defined in selda-0.5.2.1 · Database.Selda · orphanColumns (Col s a)Defined in selda-0.5.2.1 · Database.Selda.ColumnSqlType a => Result (Col s a)Defined in selda-0.5.2.1 · Database.Selda.CompileTypeError ('Text "Columns are now allowed to nest other columns."
':$$: 'Text "Remove any fields of type 'Col s a' from your table type."
) => GRelation (K1 i (Col s a))Defined in selda-0.5.2.1 · Database.Selda.Generictype Container Col a = Maybe aDefined in selda-0.5.2.1 · Database.SeldaAn acceptable query result type; one or more columns stitched together
with :*:.
(SqlRow a, Result b) => Result (Row s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Compile(SqlType a, Result b) => Result (Col s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.CompileSqlType a => Result (Col s a)Defined in selda-0.5.2.1 · Database.Selda.CompileSqlRow a => Result (Row s a)Defined in selda-0.5.2.1 · Database.Selda.CompileRun a query within a Selda monad. In practice, this is often a SeldaT
transformer on top of some other monad.
Selda transformers are entered using backend-specific withX functions,
such as withSQLite from the SQLite backend.
Perform the given query, and insert the result into the given table. Returns the number of inserted rows.
Perform the given computation atomically. If an exception is raised during its execution, the entire transaction will be rolled back and the exception re-thrown, even if the exception is caught and handled within the transaction.
Run the given computation as a transaction without enforcing foreign key constraints.
If the computation finishes with the database in an inconsistent state with regards to foreign keys, the resulting behavior is undefined. Use with extreme caution, preferably only for migrations.
On the PostgreSQL backend, at least PostgreSQL 9.6 is required.
Using this should be avoided in favor of deferred foreign key constraints. See SQL backend documentation for deferred constraints.
Generate a new random UUID using the system's random number generator. UUIDs generated this way are (astronomically likely to be) unique, but not necessarily unpredictable.
For applications where unpredictability is crucial, take care to use a proper cryptographic PRNG to generate your UUIDs.
Any datatype representable in (Selda's subset of) SQL.
mkLit :: a -> Lit aCreate a literal of this type.
sqlType :: Proxy a -> SqlTypeRepThe SQL representation for this type.
fromSql :: SqlValue -> aConvert an SqlValue into this type.
defaultValue :: Lit aDefault value when using def at this type.
SqlType ByteStringDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType ByteStringDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType Int32Defined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType Int64Defined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType BoolDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType DoubleDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType IntDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType OrderingDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType RowIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType TextDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType TextDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType DayDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType UTCTimeDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType TimeOfDayDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlType UUIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypedefaultValue for UUIDs is the all-zero RFC4122 nil UUID.
Typeable a => SqlType (ID a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeTypeable a => SqlType (UUID' a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypedefaultValue for UUIDs is the all-zero RFC4122 nil UUID.
SqlType a => SqlType (Maybe a)Defined in selda-0.5.2.1 · Database.Selda.SqlType(TypeError ((('Text "'Only "
':<>: 'ShowType a) ':<>: 'Text "' is not a proper SQL type."
) ':$$: 'Text "Use 'the' to access the value of the column."
), Typeable a) => SqlType (Only a)Defined in selda-0.5.2.1 · Database.SeldanextResult :: ResultReader aRead the next, potentially composite, result from a stream of columns.
nestedCols :: Proxy a -> IntThe number of nested columns contained in this type.
SqlRow a => SqlRow (Maybe a)Defined in selda-0.5.2.1 · Database.Selda.SqlRowSqlType a => SqlRow (Only a)Defined in selda-0.5.2.1 · Database.Selda(Typeable (a, b), GSqlRow (Rep (a, b))) => SqlRow (a, b)Defined in selda-0.5.2.1 · Database.Selda.SqlRow(Typeable (a, b, c), GSqlRow (Rep (a, b, c))) => SqlRow (a, b, c)Defined in selda-0.5.2.1 · Database.Selda.SqlRow(Typeable (a, b, c, d), GSqlRow (Rep (a, b, c, d))) => SqlRow (a, b, c, d)Defined in selda-0.5.2.1 · Database.Selda.SqlRow(Typeable (a, b, c, d, e), GSqlRow (Rep (a, b, c, d, e))) => SqlRow (a, b, c, d, e)Defined in selda-0.5.2.1 · Database.Selda.SqlRow(Typeable (a, b, c, d, e, f), GSqlRow (Rep (a, b, c, d, e, f))) => SqlRow (a, b, c, d, e, f)Defined in selda-0.5.2.1 · Database.Selda.SqlRow(Typeable (a, b, c, d, e, f, g), GSqlRow (Rep (a, b, c, d, e, f, g))) => SqlRow (a, b, c, d, e, f, g)Defined in selda-0.5.2.1 · Database.Selda.SqlRowTypeError ('Text "Selda currently does not support creating tables from sum types."
':$$: 'Text "Restrict your table type to a single data constructor."
) => GSqlRow (a :+: b)Defined in selda-0.5.2.1 · Database.Selda.SqlRowSqlType a => GSqlRow (K1 i a)Defined in selda-0.5.2.1 · Database.Selda.SqlRow(GSqlRow a, GSqlRow b) => GSqlRow (a :*: b)Defined in selda-0.5.2.1 · Database.Selda.SqlRowGSqlRow f => GSqlRow (M1 c i f)Defined in selda-0.5.2.1 · Database.Selda.SqlRowAny type that's bounded, enumerable and has a text representation, and thus representable as a Selda enumerable.
While it would be more efficient to store enumerables as integers, this makes hand-rolled SQL touching the values inscrutable, and will break if the user a) derives Enum and b) changes the order of their constructors. Long-term, this should be implemented in PostgreSQL as a proper enum anyway, which mostly renders the performance argument moot.
Any column tuple.
(SqlRow a, Columns b) => Columns (Row s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Column(SqlType a, Columns b) => Columns (Col s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.ColumnColumns (Col s a)Defined in selda-0.5.2.1 · Database.Selda.ColumnColumns (Row s a)Defined in selda-0.5.2.1 · Database.Selda.ColumnDenotes that scopes s and t are identical.
An inductively defined "tuple", or heterogeneous, non-empty list.
(Eq a, Eq b) => Eq (a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Types(Ord a, Ord b) => Ord (a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Types(Show a, Show b) => Show (a :*: b)Defined in selda-0.5.2.1 · Database.Selda.TypesGeneric (a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Types(SqlRow a, Columns b) => Columns (Row s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Column(SqlType a, Columns b) => Columns (Col s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Column(SqlRow a, Result b) => Result (Row s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Compile(SqlType a, Result b) => Result (Col s a :*: b)Defined in selda-0.5.2.1 · Database.Selda.CompileAggregates b => Aggregates (Aggr (Inner s) a :*: b)Defined in selda-0.5.2.1 · Database.Selda.InnerTup (a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Typestype Rep (a :*: b) = D1 ('MetaData ":*:"
"Database.Selda.Types"
"selda-0.5.2.1-BXeKXoDkTgT20VcSie8JWe"
'False) (C1 ('MetaCons ":*:"
('InfixI 'RightAssociative 1
) 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)))Defined in selda-0.5.2.1 · Database.Selda.TypesQuery the given table.
Query an ad hoc table of type a. Each element in the given list represents
one row in the ad hoc table.
Convenient shorthand for fmap (! sel) q.
The following two queries are quivalent:
q1 = name `from` select people
q2 = do
person <- select people
return (person ! name)Remove all duplicates from the result set.
Restrict the query somehow. Roughly equivalent to WHERE.
Drop the first m rows, then get at most n of the remaining rows from the
given subquery.
Sort the result rows in ascending or descending order on the given row.
If multiple order directives are given, later directives are given
precedence but do not cancel out earlier ordering directives.
To get a list of persons sorted primarily on age and secondarily on name:
peopleInAgeAndNameOrder = do
person <- select people
order (person ! name) ascending
order (person ! age) ascending
return (person ! name)For a table [(, this query
will always return Alice, 20), (Bob, 20), (Eve, 18)][.Eve, Alice, Bob]
The reason for later orderings taking precedence and not the other way
around is composability: order should always sort the current
result set to avoid weird surprises when a previous order directive
is buried somewhere deep in an earlier query.
However, the ordering must always be stable, to ensure that previous
calls to order are not simply erased.
Ordering for order.
Ordering for order.
Sort the result rows in random order.
The set union of two queries. Equivalent to the SQL UNION operator.
The multiset union of two queries.
Equivalent to the SQL UNION ALL operator.
Explicitly create an inner query. Equivalent to innerJoin (const true).
Sometimes it's handy, for performance reasons and otherwise, to perform a subquery and restrict only that query before adding the result of the query to the result set, instead of first adding the query to the result set and restricting the whole result set afterwards.
Create and filter an inner query, before adding it to the current result set.
q suchThat p is generally more efficient than
select q >>= x -> restrict (p x) >> pure x.
SelectorLike SelectorDefined in selda-0.5.2.1 · Database.Selda.Table(Relational t, HasField name t, FieldType name t ~ a) => IsLabel name (Selector t a)Defined in selda-0.5.2.1 · Database.Selda.FieldSelectors · orphanclass (Relational t, SqlType (FieldType name t), GRSel name (Rep t), NonError (FieldType name t)) => HasField (name :: Symbol) tAny table type t, which has a field named name.
The type of the name field, in the record type t.
Extract the given column from the given row.
Extract the given column from the given nullable row.
Nullable rows usually result from left joins.
If a nullable column is extracted from a nullable row, the resulting
nested Maybes will be squashed into a single level of nesting.
A selector-value assignment pair.
(:=) :: Selector a a1 -> Col s a1 -> Assignment s ainfixl 2Set the given column to the given value.
For each selector-value pair in the given list, on the given tuple, update the field pointed out by the selector with the corresponding value.
Add the given column to the column pointed to by the given selector.
Subtract the given column from the column pointed to by the given selector.
Multiply the column pointed to by the given selector, by the given column.
Logically OR the column pointed to by the given selector with
the given column.
Logically AND the column pointed to by the given selector with
the given column.
Apply the given function to the given column.
Any container type for which we can check object membership.
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
(
law)
You can alternatively define mconcat instead of mempty, in which case the laws are:
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtypes and make those instances
of Monoid, e.g. Data.Semigroup.Sum and Data.Semigroup.Product.
NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.
mempty :: aIdentity of mappend
"Hello world" <> mempty"Hello world"
mempty <> [1, 2, 3][1,2,3]
mappend :: a -> a -> aAn associative operation
NOTE: This method is redundant and has the default
implementation mappend = (<>) since base-4.11.0.0.
Should it be implemented manually, since mappend is a synonym for
(<>), it is expected that the two functions are defined the same
way. In a future GHC release mappend will be removed from Monoid.
mconcat :: [a] -> aFold a list using the monoid.
For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.
mconcat ["Hello", " ", "Haskell", "!"]"Hello Haskell!"
Monoid ByteArrayDefined in base-4.20.2.0 · Data.Array.ByteMonoid BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.InternalMonoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeMonoid ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.InternalMonoid ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.InternalMonoid IntSetDefined in containers-0.7 · Data.IntSet.InternalMonoid AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalMonoid AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalMonoid EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.TypesMonoid EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.TypesMonoid LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Typesmappend takes the longer of two lifetimes.
Monoid ExceptionContextDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.ContextMonoid OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid OsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types"String-Concatenation" for OsString. This is not the same
as (</>).
Monoid PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesMonoid WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesMonoid DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJMonoid TextDefined in text-2.1.3 · Data.Text · orphanMonoid BuilderDefined in text-2.1.3 · Data.Text.Internal.BuilderMonoid TextDefined in text-2.1.3 · Data.Text.Lazy · orphanMonoid StrictTextBuilderDefined in text-2.1.3 · Data.Text.Internal.StrictBuilderMonoid CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDaysAdditive
Monoid CalendarDiffTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.CalendarDiffTimeAdditive
Monoid ()Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid (Comparison a)Defined in base-4.20.2.0 · Data.Functor.ContravariantMonoid (Equivalence a)Defined in base-4.20.2.0 · Data.Functor.ContravariantMonoid (Predicate a)Defined in base-4.20.2.0 · Data.Functor.ContravariantMonoid (PutM ())Defined in binary-0.8.9.3 · Data.Binary.PutMonoid (IntMap a)Defined in containers-0.7 · Data.IntMap.InternalMonoid (Seq a)Defined in containers-0.7 · Data.Sequence.InternalMonoid (MergeSet a)Defined in containers-0.7 · Data.Set.InternalMonoid (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidMonoid (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidMonoid (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalMonoid (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJMonoid [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid a => Monoid (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncMonoid a => Monoid (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityMonoid a => Monoid (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.OrdMonoid a => Monoid (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalMonoid a => Monoid (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid a => Monoid (Q a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxMonoid a => Monoid (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid m => Monoid (WrappedMonoid m)Defined in base-4.20.2.0 · Data.SemigroupMonoid p => Monoid (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsSemigroup a => Monoid (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseLift a semigroup into Maybe forming a Monoid according to
http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be
turned into a monoid simply by adjoining an element e not in S
and defining e*e = e and e*s = s = s*e for all s ∈ S."
Since 4.11.0: constraint on inner a value generalised from
Monoid to Semigroup.
Bits a => Monoid (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsBits a => Monoid (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsFiniteBits a => Monoid (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsThis constraint is arguably too strong. However,
as some types (such as Natural) have undefined complement, this is the
only safe choice.
FiniteBits a => Monoid (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsThis constraint is arguably
too strong. However, as some types (such as Natural) have undefined
complement, this is the only safe choice.
Num a => Monoid (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalNum a => Monoid (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalOrd a => Monoid (Set a)Defined in containers-0.7 · Data.Set.InternalOrd a => Monoid (Max a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsOrd a => Monoid (Min a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils(Generic a, Monoid (Rep a ())) => Monoid (Generically a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Ord a, Bounded a) => Monoid (Max a)Defined in base-4.20.2.0 · Data.Semigroup(Ord a, Bounded a) => Monoid (Min a)Defined in base-4.20.2.0 · Data.SemigroupMonoid (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyMonoid (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsMonoid a => Monoid (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariantmempty @(Op a b) without newtypes is mempty @(b->a)
= _ -> mempty.
mempty :: Op a b
mempty = Op _ -> mempty
Monoid a => Monoid (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.STMonoid b => Monoid (a -> b)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseOrd k => Monoid (Map k v)Defined in containers-0.7 · Data.Map.Internal(Monoid a, Monoid b) => Monoid (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative f => Monoid (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalMonoid (Col s Text)Defined in selda-0.5.2.1 · Database.Selda · orphanMonoid (f p) => Monoid (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsMonoid a => Monoid (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstMonoid a => Monoid (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant(Applicative f, Monoid a) => Monoid (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid c => Monoid (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Monoid (f a), Monoid (g a)) => Monoid (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product(Monoid (f p), Monoid (g p)) => Monoid ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid (f (g a)) => Monoid (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.ComposeMonoid (f (g p)) => Monoid ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsMonoid (f p) => Monoid (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseThe class of semigroups (types with an associative binary operation).
Instances should satisfy the following:
You can alternatively define sconcat instead of (<>), in which case the laws are:
(<>) :: a -> a -> ainfixr 6An associative operation.
[1,2,3] <> [4,5,6][1,2,3,4,5,6]
Just [1, 2, 3] <> Just [4, 5, 6]Just [1,2,3,4,5,6]
putStr "Hello, " <> putStrLn "World!"Hello, World!
Semigroup ByteArrayDefined in base-4.20.2.0 · Data.Array.ByteSemigroup BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.InternalSemigroup ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeSemigroup ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.InternalSemigroup ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.InternalSemigroup IntSetDefined in containers-0.7 · Data.IntSet.InternalSemigroup VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalSemigroup AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalSemigroup EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.TypesSemigroup EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.TypesSemigroup LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.TypesSemigroup ExceptionContextDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.ContextSemigroup OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup OsStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesSemigroup PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesSemigroup WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesSemigroup DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJSemigroup QueryFragmentDefined in selda-0.5.2.1 · Database.Selda.SQLSemigroup TextDefined in text-2.1.3 · Data.Text · orphanBeware: stimes will crash if the given number does not fit into
an Int.
Semigroup BuilderDefined in text-2.1.3 · Data.Text.Internal.BuilderSemigroup TextDefined in text-2.1.3 · Data.Text.Lazy · orphanSemigroup StrictTextBuilderDefined in text-2.1.3 · Data.Text.Internal.StrictBuilderConcatenation of StrictBuilder is right-biased: the right builder will be run first. This allows a builder to run tail-recursively when it was accumulated left-to-right.
Semigroup CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Calendar.CalendarDiffDaysAdditive
Semigroup CalendarDiffTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.CalendarDiffTimeAdditive
Semigroup ()Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseMonoid m => Semigroup (WrappedMonoid m)Defined in base-4.20.2.0 · Data.SemigroupSemigroup (FromMaybe b)Defined in base-4.20.2.0 · Data.Foldable1Semigroup (NonEmptyDList a)Defined in base-4.20.2.0 · Data.Foldable1Semigroup (Comparison a)Defined in base-4.20.2.0 · Data.Functor.ContravariantSemigroup (Equivalence a)Defined in base-4.20.2.0 · Data.Functor.ContravariantSemigroup (Predicate a)Defined in base-4.20.2.0 · Data.Functor.ContravariantSemigroup (First a)Defined in base-4.20.2.0 · Data.SemigroupSemigroup (Last a)Defined in base-4.20.2.0 · Data.SemigroupSemigroup (PutM ())Defined in binary-0.8.9.3 · Data.Binary.PutSemigroup (IntMap a)Defined in containers-0.7 · Data.IntMap.InternalSemigroup (Seq a)Defined in containers-0.7 · Data.Sequence.InternalSemigroup (MergeSet a)Defined in containers-0.7 · Data.Set.InternalSemigroup (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidSemigroup (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidSemigroup (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalSemigroup (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJSemigroup [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup a => Semigroup (JoinWith a)Defined in base-4.20.2.0 · Data.Foldable1Semigroup a => Semigroup (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncSemigroup a => Semigroup (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentitySemigroup a => Semigroup (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.OrdSemigroup a => Semigroup (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalSemigroup a => Semigroup (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup a => Semigroup (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup a => Semigroup (Q a)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxSemigroup a => Semigroup (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup p => Semigroup (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsBits a => Semigroup (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsBits a => Semigroup (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsBits a => Semigroup (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsFiniteBits a => Semigroup (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsThis constraint is arguably
too strong. However, as some types (such as Natural) have undefined
complement, this is the only safe choice.
Num a => Semigroup (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalNum a => Semigroup (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalOrd a => Semigroup (Max a)Defined in base-4.20.2.0 · Data.SemigroupOrd a => Semigroup (Min a)Defined in base-4.20.2.0 · Data.SemigroupOrd a => Semigroup (Intersection a)Defined in containers-0.7 · Data.Set.InternalOrd a => Semigroup (Set a)Defined in containers-0.7 · Data.Set.InternalOrd a => Semigroup (Max a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.UtilsOrd a => Semigroup (Min a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils(Generic a, Semigroup (Rep a ())) => Semigroup (Generically a)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsSemigroup (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.EitherSemigroup (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxySemigroup (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsSemigroup (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsSemigroup a => Semigroup (Op a b)Defined in base-4.20.2.0 · Data.Functor.ContravariantSemigroup a => Semigroup (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.STSemigroup b => Semigroup (a -> b)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseOrd k => Semigroup (Map k v)Defined in containers-0.7 · Data.Map.Internal(Semigroup a, Semigroup b) => Semigroup (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative f => Semigroup (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalSemigroup (Col s Text)Defined in selda-0.5.2.1 · Database.Selda · orphanSemigroup (f p) => Semigroup (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsSemigroup a => Semigroup (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstSemigroup a => Semigroup (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant(Applicative f, Semigroup a) => Semigroup (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid(Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup c => Semigroup (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product(Semigroup (f p), Semigroup (g p)) => Semigroup ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseSemigroup (f (g a)) => Semigroup (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.ComposeSemigroup (f (g p)) => Semigroup ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsSemigroup (f p) => Semigroup (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseA typed row identifier.
Generic tables should use this instead of RowID.
Use untyped to erase the type of a row identifier, and cast from the
Database.Selda.Unsafe module if you for some reason need to add a type
to a row identifier.
Eq (ID a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeOrd (ID a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeShow (ID a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeGeneric (ID a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeTypeable a => SqlOrd (ID a)Defined in selda-0.5.2.1 · Database.SeldaTypeable a => SqlType (ID a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypetype Rep (ID a) = D1 ('MetaData "ID"
"Database.Selda.SqlType"
"selda-0.5.2.1-BXeKXoDkTgT20VcSie8JWe"
'True) (C1 ('MetaCons "ID"
'PrefixI 'True) (S1 ('MetaSel ('Just "untyped"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RowID)))Defined in selda-0.5.2.1 · Database.Selda.SqlTypeA typed row identifier which is guaranteed to not match any row in any table.
Is the given typed row identifier invalid? I.e. is it guaranteed to not match any row in any table?
Create a typed row identifier from an integer. Use with caution, preferably only when reading user input.
Create a typed row identifier from an integer. Use with caution, preferably only when reading user input.
An UUID identifying a database row.
Eq (UUID' a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeOrd (UUID' a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeShow (UUID' a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeGeneric (UUID' a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeIsUUID (UUID' a)Defined in selda-0.5.2.1 · Database.SeldaTypeable a => SqlType (UUID' a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypedefaultValue for UUIDs is the all-zero RFC4122 nil UUID.
type Rep (UUID' a) = D1 ('MetaData "UUID'"
"Database.Selda.SqlType"
"selda-0.5.2.1-BXeKXoDkTgT20VcSie8JWe"
'True) (C1 ('MetaCons "UUID"
'PrefixI 'True) (S1 ('MetaSel ('Just "untypedUuid"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UUID)))Defined in selda-0.5.2.1 · Database.Selda.SqlTypeConvert an untyped UUID to a typed one. Use sparingly, preferably only during deserialization.
A row identifier for some table. This is the type of auto-incrementing primary keys.
Eq RowIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypeOrd RowIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypeShow RowIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypeGeneric RowIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypeSqlOrd RowIDDefined in selda-0.5.2.1 · Database.SeldaSqlType RowIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypetype Rep RowID = D1 ('MetaData "RowID"
"Database.Selda.SqlType"
"selda-0.5.2.1-BXeKXoDkTgT20VcSie8JWe"
'True) (C1 ('MetaCons "RowID"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))Defined in selda-0.5.2.1 · Database.Selda.SqlTypeA row identifier which is guaranteed to not match any row in any table.
Is the given row identifier invalid? I.e. is it guaranteed to not match any row in any table?
Inspect a row identifier.
Create a row identifier from an integer. Use with caution, preferably only when reading user input.
Comparisons over columns.
Note that when comparing nullable (i.e. Maybe) columns, SQL NULL
semantics are used. This means that comparing to a NULL field will remove
the row in question from the current set.
To test for NULL, use isNull instead of .== literal Nothing.
Comparisons over columns.
Note that when comparing nullable (i.e. Maybe) columns, SQL NULL
semantics are used. This means that comparing to a NULL field will remove
the row in question from the current set.
To test for NULL, use isNull instead of .== literal Nothing.
The SQL LIKE operator; matches strings with % wildcards.
For instance:
"%gon" `like` "dragon" .== trueBoolean negation.
A literal expression.
Returns true if the given field in the given row is equal to the given literal.
Specialization of literal for integers.
Specialization of literal for doubles.
Specialization of literal for text.
True and false boolean literals.
True and false boolean literals.
SQL NULL, at any type you like.
Round a column to the given number of decimals places.
Calculate the length of a string column.
Is the given column null?
Perform a conditional on a column
If the second value is Nothing, return the first value. Otherwise return the second value.
Applies the given function to the given nullable column where it isn't null, and returns the given default value where it is.
This is the Selda equivalent of maybe.
Convert the given string to uppercase.
Convert the given string to lowercase.
Create a new row with the given fields. Any unassigned fields will contain their default values.
Create a new row from the given value. This can be useful when you want to update all or most of a row:
update users (#uid `is` user_id)
(\old -> row user_info `with` [...])Create a singleton table column from an appropriate value.
Any container type which can be mapped over. Sort of like Functor, if you squint a bit.
Round a value to the nearest integer. Equivalent to roundTo 0.
Lift a non-nullable column to a nullable one. Useful for creating expressions over optional columns:
data Person = Person {name :: Text, age :: Int, pet :: Maybe Text}
deriving Generic
instance SqlRow Person
people :: Table Person
people = table "people" []
peopleWithCats = do
person <- select people
restrict (person ! #pet .== just "cat")
return (person ! #name)Convert a boolean column to any numeric type.
Convert an integer column to any numeric type.
Convert any SQL type to a string.
A single aggregate column.
Aggregate columns may not be used to restrict queries.
When returned from an aggregate subquery, an aggregate column is
converted into a non-aggregate column.
Mappable AggrDefined in selda-0.5.2.1 · Database.SeldaAggregates (Aggr (Inner s) a)Defined in selda-0.5.2.1 · Database.Selda.InnerAggregates b => Aggregates (Aggr (Inner s) a :*: b)Defined in selda-0.5.2.1 · Database.Selda.Innertype Container Aggr a = aDefined in selda-0.5.2.1 · Database.SeldaOne or more aggregate columns.
Aggregates (Aggr (Inner s) a)Defined in selda-0.5.2.1 · Database.Selda.InnerAggregates b => Aggregates (Aggr (Inner s) a :*: b)Defined in selda-0.5.2.1 · Database.Selda.InnerConvert one or more inner column to equivalent columns in the outer query.
OuterCols (Aggr (Inner s) a :*: Aggr (Inner s) b) = Col s a :*: Col s b,
for instance.
OuterCols (Col (Inner s) a :*: b) = Col s a :*: OuterCols bOuterCols (Col (Inner s) a) = Col s aOuterCols (Row (Inner s) a :*: b) = Row s a :*: OuterCols bOuterCols (Row (Inner s) a) = Row s aOuterCols (Col s a) = TypeError ('Text "An inner query can only return rows and columns from its own scope."
)OuterCols (Row s a) = TypeError ('Text "An inner query can only return rows and columns from its own scope."
)OuterCols a = TypeError ('Text "Only (inductive tuples of) row and columns can be returned from"
':$$: 'Text "an inner query."
)AggrCols (Aggr (Inner s) a :*: b) = Col s a :*: AggrCols bAggrCols (Aggr (Inner s) a) = Col s aAggrCols (Aggr s a) = TypeError ('Text "An aggregate query can only return columns from its own"
':$$: 'Text "scope."
)AggrCols a = TypeError ('Text "Only (inductive tuples of) aggregates can be returned from"
':$$: 'Text "an aggregate query."
)The results of a left join are always nullable, as there is no guarantee
that all joined columns will be non-null.
JoinCols a where a is an extensible tuple is that same tuple, but in
the outer query and with all elements nullable.
For instance:
LeftCols (Col (Inner s) Int :*: Col (Inner s) Text)
= Col s (Maybe Int) :*: Col s (Maybe Text)LeftCols (Col (Inner s) (Maybe a) :*: b) = Col s (Maybe a) :*: LeftCols bLeftCols (Col (Inner s) a :*: b) = Col s (Maybe a) :*: LeftCols bLeftCols (Col (Inner s) (Maybe a)) = Col s (Maybe a)LeftCols (Col (Inner s) a) = Col s (Maybe a)LeftCols (Row (Inner s) (Maybe a) :*: b) = Row s (Maybe a) :*: LeftCols bLeftCols (Row (Inner s) a :*: b) = Row s (Maybe a) :*: LeftCols bLeftCols (Row (Inner s) (Maybe a)) = Row s (Maybe a)LeftCols (Row (Inner s) a) = Row s (Maybe a)LeftCols a = TypeError ('Text "Only (inductive tuples of) rows and columns can be returned"
':$$: 'Text "from a join."
)Denotes an inner query.
For aggregation, treating sequencing as the cartesian product of queries
does not work well.
Instead, we treat the sequencing of aggregate with other
queries as the cartesian product of the aggregated result of the query,
a small but important difference.
However, for this to work, the aggregate query must not depend on any
columns in the outer product. Therefore, we let the aggregate query be
parameterized over Inner s if the parent query is parameterized over s,
to enforce this separation.
Aggregates (Aggr (Inner s) a)Defined in selda-0.5.2.1 · Database.Selda.InnerAggregates b => Aggregates (Aggr (Inner s) a :*: b)Defined in selda-0.5.2.1 · Database.Selda.InnerSqlOrd RowIDDefined in selda-0.5.2.1 · Database.SeldaSqlOrd TextDefined in selda-0.5.2.1 · Database.SeldaSqlOrd DayDefined in selda-0.5.2.1 · Database.SeldaSqlOrd UTCTimeDefined in selda-0.5.2.1 · Database.SeldaSqlOrd TimeOfDayDefined in selda-0.5.2.1 · Database.Selda(SqlType a, Num a) => SqlOrd aDefined in selda-0.5.2.1 · Database.SeldaTypeable a => SqlOrd (ID a)Defined in selda-0.5.2.1 · Database.SeldaSqlOrd a => SqlOrd (Maybe a)Defined in selda-0.5.2.1 · Database.SeldainnerJoin Perform an INNER JOIN with the current result set and the given query.
leftJoin Perform a LEFT JOIN with the current result set (i.e. the outer query)
as the left hand side, and the given query as the right hand side.
Like with aggregate, the inner (or right) query must not depend on the
outer (or right) one.
The given predicate over the values returned by the inner query determines for each row whether to join or not. This predicate may depend on any values from the outer query.
For instance, the following will list everyone in the people table
together with their address if they have one; if they don't, the address
field will be NULL.
getAddresses :: Query s (Col s Text :*: Col s (Maybe Text))
getAddresses = do
(name :*: _) <- select people
(_ :*: address) <- leftJoin (\(n :*: _) -> n .== name)
(select addresses)
return (name :*: address)Execute a query, returning an aggregation of its results.
The query must return an inductive tuple of Aggregate columns.
When aggregate returns, those columns are converted into non-aggregate
columns, which may then be used to further restrict the query.
Note that aggregate queries must not depend on outer queries, nor must they return any non-aggregate columns. Attempting to do either results in a type error.
The SQL HAVING keyword can be implemented by combining aggregate
and restrict:
-- Find the number of people living on every address, for all addresses
-- with more than one tenant:
-- SELECT COUNT(name) AS c, address FROM housing GROUP BY name HAVING c > 1
numPpl = do
(num_tenants :*: theAddress) <- aggregate $ do
h <- select housing
theAddress <- groupBy (h ! address)
return (count (h ! address) :*: theAddress)
restrict (num_tenants .> 1)
return (num_tenants :*: theAddress)Group an aggregate query by a column. Attempting to group a non-aggregate query is a type error. An aggregate representing the grouped-by column is returned, which can be returned from the aggregate query. For instance, if you want to find out how many people have a pet at home:
aggregate $ do
person <- select people
name' <- groupBy (person ! name)
return (name' :*: count(person ! pet_name) .> 0)The number of non-null values in the given column.
The average of all values in the given column.
Sum all values in the given column.
The greatest value in the given column. Texts are compared lexically.
The smallest value in the given column. Texts are compared lexically.
Insert the given values into the given table. All columns of the table
must be present. If your table has an auto-incrementing primary key,
use the special value def for that column to get the auto-incrementing
behavior.
Returns the number of rows that were inserted.
To insert a list of tuples into a table with auto-incrementing primary key:
data Person = Person
{ id :: ID Person
, name :: Text
, age :: Int
, pet :: Maybe Text
} deriving Generic
instance SqlResult Person
people :: Table Person
people = table "people" [autoPrimary :- id]
main = withSQLite "my_database.sqlite" $ do
insert_ people
[ Person def "Link" 125 (Just "horse")
, Person def "Zelda" 119 Nothing
, ...
]Note that if one or more of the inserted rows would cause a constraint violation, NO rows will be inserted; the whole insertion fails atomically.
Like insert, but does not return anything. Use this when you really don't care about how many rows were inserted.
Like insert, but returns the primary key of the last inserted row. Attempting to run this operation on a table without an auto-incrementing primary key will always return a row identifier that is guaranteed to not match any row in any table.
Attempt to insert a list of rows into a table, but don't raise an error
if the insertion fails. Returns True if the insertion succeeded, otherwise
False.
Like insert, if even one of the inserted rows would cause a constraint violation, the whole insert operation fails.
Perform the given insert, if no rows already present in the table match
the given predicate.
Returns the primary key of the last inserted row,
if the insert was performed.
If called on a table which doesn't have an auto-incrementing primary key,
Just id is always returned on successful insert, where id is a row
identifier guaranteed to not match any row in any table.
Like insertUnless, but performs the insert when at least one row matches the predicate.
The default value for a column during insertion. For an auto-incrementing primary key, the default value is the next key.
Using def in any other context than insertion results in a runtime error.
update Update the given table using the given update function, for all rows matching the given predicate. Returns the number of updated rows.
Like update, but doesn't return the number of updated rows.
Attempt to perform the given update. If no rows were updated, insert the
given row.
Returns the primary key of the inserted row, if the insert was performed.
Calling this function on a table which does not have a primary key will
return Just id on a successful insert, where id is a row identifier
guaranteed to not match any row in any table.
Note that this may perform two separate queries: one update, potentially followed by one insert.
From the given table, delete all rows matching the given predicate. Returns the number of deleted rows.
Like deleteFrom, but does not return the number of deleted rows.
Result a => Preparable (Query s a)Defined in selda-0.5.2.1 · Database.Selda.Prepared(SqlType a, Preparable b) => Preparable (Col s a -> b)Defined in selda-0.5.2.1 · Database.Selda.PreparedSome parameterized query q that can be prepared into a function f
in some MonadSelda.
Create a prepared Selda function. A prepared function has zero or more arguments, and will get compiled into a prepared statement by the first backend to execute it. Any subsequent calls to the function for the duration of the connection to the database will reuse the prepared statement.
Preparable functions are of the form
(SqlType a, SqlType b, ...) => Col s a -> Col s b -> ... -> Query s r.
The resulting prepared function will be of the form
MonadSelda m => a -> b -> ... -> m [Res r].
Note, however, that when using prepared, you must give a concrete type
for m due to how Haskell's type class resolution works.
Prepared functions rely on memoization for just-in-time preparation and
caching. This means that if GHC accidentally inlines your prepared function,
it may get prepared twice.
While this does not affect the correctness of your program, and is
fairly unlikely to happen, if you want to be absolutely sure that your
queries aren't re-prepared more than absolutely necessary,
consider adding a NOINLINE annotation to each prepared function.
Note that when using a constrained backend type variable (i.e.
foo :: Bar b => SeldaM b [Int]), optimizations must be enabled for
prepared statements to be effective.
A usage example:
persons :: Table (Text, Int)
(persons, name :*: age) = tableWithSelectors "ages" [name :- primary]
{-# NOINLINE ageOf #-}
ageOf :: Text -> SeldaM [Int]
ageOf = prepared $ \n -> do
person <- select ages
restrict $ (person!name .== n)
return ageGeneric ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.InternalGeneric ForeignSrcLangDefined in ghc-boot-th-9.10.3 · GHC.ForeignSrcLang.TypeGeneric ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.TypeGeneric VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrderGeneric ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypesGeneric AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalGeneric AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalGeneric VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.VersionGeneric FingerprintDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.ExceptionGeneric CCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric ConcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric DebugFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric DoCostCentresDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric DoHeapProfileDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric DoTraceDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric GCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric GiveGCStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric HpcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric MiscFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric ParFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric ProfFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric RTSFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric TickyFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric TraceFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.FlagsGeneric SrcLocDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.StatsGeneric RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.StatsGeneric GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric OsCharDefined in os-string-2.0.7 · System.OsString.Internal.TypesGeneric OsStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesGeneric PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.TypesGeneric PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesGeneric WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.TypesGeneric WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.TypesGeneric ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJGeneric StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJGeneric TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJGeneric DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJGeneric RowIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypeGeneric AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric ()Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Complex a)Defined in base-4.20.2.0 · Data.ComplexGeneric (First a)Defined in base-4.20.2.0 · Data.SemigroupGeneric (Last a)Defined in base-4.20.2.0 · Data.SemigroupGeneric (Max a)Defined in base-4.20.2.0 · Data.SemigroupGeneric (Min a)Defined in base-4.20.2.0 · Data.SemigroupGeneric (WrappedMonoid m)Defined in base-4.20.2.0 · Data.SemigroupGeneric (SCC vertex)Defined in containers-0.7 · Data.GraphGeneric (Digit a)Defined in containers-0.7 · Data.Sequence.InternalGeneric (Elem a)Defined in containers-0.7 · Data.Sequence.InternalGeneric (FingerTree a)Defined in containers-0.7 · Data.Sequence.InternalGeneric (Node a)Defined in containers-0.7 · Data.Sequence.InternalGeneric (ViewL a)Defined in containers-0.7 · Data.Sequence.InternalGeneric (ViewR a)Defined in containers-0.7 · Data.Sequence.InternalGeneric (Tree a)Defined in containers-0.7 · Data.TreeGeneric (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityGeneric (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidGeneric (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidGeneric (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalGeneric (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListGeneric (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJGeneric (Only a)Defined in selda-0.5.2.1 · Database.SeldaGeneric (ID a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeGeneric (UUID' a)Defined in selda-0.5.2.1 · Database.Selda.SqlTypeGeneric (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxGeneric (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (WrappedMonad m a)Defined in base-4.20.2.0 · Control.ApplicativeGeneric (Arg a b)Defined in base-4.20.2.0 · Data.SemigroupGeneric (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.LiftGeneric (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeGeneric (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a :*: b)Defined in selda-0.5.2.1 · Database.Selda.TypesGeneric (WrappedArrow a b c)Defined in base-4.20.2.0 · Control.ApplicativeGeneric (Kleisli m a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowGeneric (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstGeneric (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidGeneric (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalGeneric (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (URec Int p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (URec Word p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (URec (Ptr ()) p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsGeneric (AccumT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.AccumGeneric (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ExceptGeneric (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityGeneric (ReaderT r m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ReaderGeneric (SelectT r m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.SelectGeneric (StateT s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.LazyGeneric (StateT s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictGeneric (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPSGeneric (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.LazyGeneric (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.StrictGeneric (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.ConstantGeneric (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.ReverseGeneric (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Product f g a)Defined in base-4.20.2.0 · Data.Functor.ProductGeneric (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.SumGeneric (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (ContT r m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ContGeneric ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.ComposeGeneric (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (RWST r w s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPSGeneric (RWST r w s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.LazyGeneric (RWST r w s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.StrictGeneric ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsGeneric (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsName of a database table.
Name of a database column.
A generic column attribute.
Essentially a pair or a record selector over the type a and a column
attribute. An attribute may be either a Group attribute, meaning that
it can span multiple columns, or a Selector -- single column -- attribute.
(:-) :: SelectorLike g => g a a1 -> Attribute g a a1 -> Attr ainfixl 0Some attribute that may be set on a column of type c, in a table of
type t.
foreignKey :: Table t -> Selector t a -> Attribute Selector self bA foreign key constraint referencing the given table and column.
ForeignKey a aDefined in selda-0.5.2.1 · Database.Selda.TableForeignKey a (Maybe a)Defined in selda-0.5.2.1 · Database.Selda.TableForeignKey (Maybe a) aDefined in selda-0.5.2.1 · Database.Selda.TableSelectorLike SelectorDefined in selda-0.5.2.1 · Database.Selda.TableSelectorLike GroupDefined in selda-0.5.2.1 · Database.Selda.TableA non-empty list of selectors, where the element selectors need not have the same type. Used to specify constraints, such as uniqueness or primary key, potentially spanning multiple columns.
Annotation to force the type of a polymorphic label (i.e. #foo) to
be a selector. This is useful, for instance, when defining unique
constraints: sel #foo :- unique.
Generate a table from the given table name and list of column attributes.
All Maybe fields in the table's type will be represented by nullable
columns, and all non-Maybe fields fill be represented by required
columns.
For example:
data Person = Person
{ id :: ID Person
, name :: Text
, age :: Int
, pet :: Maybe Text
}
deriving Generic
people :: Table Person
people = table "people" [#id :- autoPrimary]This will result in a table of Persons, with an auto-incrementing primary
key.
If the given type does not have record selectors, the column names will be
col_1, col_2, etc.
Generate a table from the given table name, a list of column attributes and a function that maps from field names to column names. Ex.:
data Person = Person
{ personId :: Int
, personName :: Text
, personAge :: Int
, personPet :: Maybe Text
}
deriving Generic
people :: Table Person
people = tableFieldMod "people"
[#personName :- autoPrimary]
(fromJust . stripPrefix "person")This will create a table with the columns named
Id, Name, Age and Pet.
A primary key which does not auto-increment.
An auto-incrementing primary key.
A "weakly auto-incrementing" primary key. Behaves like autoPrimary, but the sequence of generated keys is not guaranteed to be monotonically increasing.
This gives better performance on some backends, but means that
the relation a > b = a was inserted at a later point in time than b
does not hold.
An untyped auto-incrementing primary key. You should really only use this for ad hoc tables, such as tuples.
Like weakAutoPrimary, but for untyped IDs.
A table-unique value.
Method to use for indexing with indexedUsing.
Index methods are ignored by the SQLite backend, as SQLite doesn't support
different index methods.
Eq IndexMethodDefined in selda-0.5.2.1 · Database.Selda.Table.TypeOrd IndexMethodDefined in selda-0.5.2.1 · Database.Selda.Table.TypeShow IndexMethodDefined in selda-0.5.2.1 · Database.Selda.Table.TypeCreate an index on these column(s).
Create an index using the given index method on this column.
Create a table from the given schema.
Create a table from the given schema, unless it already exists.
Drop the given table.
Drop the given table, if it exists.
Get the first element of an inductive tuple.
Get the second element of an inductive tuple.
Get the third element of an inductive tuple.
Get the fourth element of an inductive tuple.
Get the fifth element of an inductive tuple.
MonadIO IODefined in base-4.20.2.0 · Control.Monad.IO.ClassMonadIO QDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.SyntaxMonadIO m => MonadIO (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.PureMonadIO m => MonadIO (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeMonadIO m => MonadIO (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonadIO m => MonadIO (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ExceptMonadIO m => MonadIO (IdentityT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityMonadIO m => MonadIO (ReaderT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ReaderMonadIO m => MonadIO (SelectT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.SelectMonadIO m => MonadIO (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.LazyMonadIO m => MonadIO (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadIO m => MonadIO (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS(Monoid w, MonadIO m) => MonadIO (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Monoid w, MonadIO m) => MonadIO (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict(Monoid w, Functor m, MonadIO m) => MonadIO (AccumT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.AccumMonadIO m => MonadIO (ContT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.ContMonadIO m => MonadIO (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS(Monoid w, MonadIO m) => MonadIO (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy(Monoid w, MonadIO m) => MonadIO (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.StrictA class for monads which provide for the ability to account for all possible exit points from a computation, and to mask asynchronous exceptions. Continuation-based monads are invalid instances of this class.
Instances should ensure that, in the following code:
fg = f `finally` gThe action g is called regardless of what occurs within f, including
async exceptions. Some monads allow f to abort the computation via other
effects than throwing an exception. For simplicity, we will consider aborting
and throwing an exception to be two forms of "throwing an error".
If f and g both throw an error, the error thrown by fg depends on which
errors we're talking about. In a monad transformer stack, the deeper layers
override the effects of the inner layers; for example, ExceptT e1 (Except
e2) a represents a value of type Either e2 (Either e1 a), so throwing both
an e1 and an e2 will result in Left e2. If f and g both throw an
error from the same layer, instances should ensure that the error from g
wins.
Effects other than throwing an error are also overridden by the deeper layers.
For example, StateT s Maybe a represents a value of type s -> Maybe (a,
s), so if an error thrown from f causes this function to return Nothing,
any changes to the state which f also performed will be erased. As a
result, g will see the state as it was before f. Once g completes,
f's error will be rethrown, so g' state changes will be erased as well.
This is the normal interaction between effects in a monad transformer stack.
By contrast, lifted-base's
version of finally always discards all of g's non-IO effects, and g
never sees any of f's non-IO effects, regardless of the layer ordering and
regardless of whether f throws an error. This is not the result of
interacting effects, but a consequence of MonadBaseControl's approach.
MonadMask IODefined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (MaybeT m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonad m => MonadMask (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.PureNote: This instance is only valid if the underlying monad has a single exit point!
For example, IO or Either would be invalid base monads, but
Reader or State would be acceptable.
e ~ SomeException => MonadMask (Either e)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (SeldaT b m)Defined in selda-0.5.2.1 · Database.Selda.Backend.InternalMonadMask m => MonadMask (ExceptT e m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (IdentityT m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (ReaderT r m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.Catch(MonadMask m, Monoid w) => MonadMask (WriterT w m)Defined in exceptions-0.10.9 · Control.Monad.Catch(MonadMask m, Monoid w) => MonadMask (WriterT w m)Defined in exceptions-0.10.9 · Control.Monad.Catch(MonadMask m, Monoid w) => MonadMask (RWST r w s m)Defined in exceptions-0.10.9 · Control.Monad.Catch(MonadMask m, Monoid w) => MonadMask (RWST r w s m)Defined in exceptions-0.10.9 · Control.Monad.CatchLift a computation from the IO monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. IO is the base monad for the stack).
import Control.Monad.Trans.State -- from the "transformers" library
printState :: Show s => StateT s IO ()
printState = do
state <- get
liftIO $ print stateHad we omitted liftIO, we would have ended up with this error:
• Couldn't match type ‘IO’ with ‘StateT s IO’
Expected type: StateT s IO ()
Actual type: IO ()The important part here is the mismatch between StateT s IO () and IO ().
Luckily, we know of a function that takes an IO a and returns an (m a): liftIO,
enabling us to run the program and see the expected results:
> evalStateT printState "hello"
"hello"
> evalStateT printState 3
3
A space efficient, packed, unboxed Unicode text type.
IsList TextDefined in text-2.1.3 · Data.Text · orphanPerforms replacement on invalid scalar values:
:set -XOverloadedLists['\55555'] :: Text"\65533"
Eq TextDefined in text-2.1.3 · Data.Text · orphanData TextDefined in text-2.1.3 · Data.Text · orphanThis instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.
This instance was created by copying the updated behavior of
Data.Set.Set and Data.Map.Data.Map.Map. If you
feel a mistake has been made, please feel free to submit
improvements.
The original discussion is archived here: could we get a Data instance for Data.Text.Text?
The followup discussion that changed the behavior of Set
and Data.Map.Map is archived here:
Proposal: Allow gunfold for Data.Map, ...
Ord TextDefined in text-2.1.3 · Data.Text · orphanRead TextDefined in text-2.1.3 · Data.Text · orphanShow TextDefined in text-2.1.3 · Data.Text.Show · orphanIsString TextDefined in text-2.1.3 · Data.Text · orphanPerforms replacement on invalid scalar values:
:set -XOverloadedStrings"\55555" :: Text"\65533"
Semigroup TextDefined in text-2.1.3 · Data.Text · orphanBeware: stimes will crash if the given number does not fit into
an Int.
Monoid TextDefined in text-2.1.3 · Data.Text · orphanPrintfArg TextDefined in text-2.1.3 · Data.Text · orphanNFData TextDefined in text-2.1.3 · Data.Text · orphanBinary TextDefined in text-2.1.3 · Data.Text · orphanHashable TextDefined in hashable-1.4.7.0 · Data.Hashable.ClassSqlOrd TextDefined in selda-0.5.2.1 · Database.SeldaSqlType TextDefined in selda-0.5.2.1 · Database.Selda.SqlTypeLift TextDefined in text-2.1.3 · Data.Text · orphanIsString (Col s Text)Defined in selda-0.5.2.1 · Database.Selda.ColumnSemigroup (Col s Text)Defined in selda-0.5.2.1 · Database.Selda · orphanMonoid (Col s Text)Defined in selda-0.5.2.1 · Database.Selda · orphantype Item Text = CharDefined in text-2.1.3 · Data.Text · orphanThe Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.
Enum DayDefined in time-1.12.2 · Data.Time.Calendar.DaysEq DayDefined in time-1.12.2 · Data.Time.Calendar.DaysData DayDefined in time-1.12.2 · Data.Time.Calendar.DaysOrd DayDefined in time-1.12.2 · Data.Time.Calendar.DaysRead DayDefined in time-1.12.2 · Data.Time.Format.Parse · orphanShow DayDefined in time-1.12.2 · Data.Time.Calendar.Gregorian · orphanIx DayDefined in time-1.12.2 · Data.Time.Calendar.DaysNFData DayDefined in time-1.12.2 · Data.Time.Calendar.DaysDayPeriod DayDefined in time-1.12.2 · Data.Time.Calendar.DaysFormatTime DayDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanParseTime DayDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanISO8601 DayDefined in time-1.12.2 · Data.Time.Format.ISO8601yyyy-mm-dd (ISO 8601:2004(E) sec. 4.1.2.2 extended format)
SqlOrd DayDefined in selda-0.5.2.1 · Database.SeldaSqlType DayDefined in selda-0.5.2.1 · Database.Selda.SqlTypeTime of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.
TimeOfDay 24 0 0 is considered invalid for the purposes of makeTimeOfDayValid, as well as reading and parsing,
but valid for ISO 8601 parsing in Data.Time.Format.ISO8601.
Eq TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDayData TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDayOrd TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDayRead TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Parse · orphanShow TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDayNFData TimeOfDayDefined in time-1.12.2 · Data.Time.LocalTime.Internal.TimeOfDayFormatTime TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanParseTime TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanISO8601 TimeOfDayDefined in time-1.12.2 · Data.Time.Format.ISO8601hh:mm:ss[.sss] (ISO 8601:2004(E) sec. 4.2.2.2, 4.2.2.4(a) extended format)
SqlOrd TimeOfDayDefined in selda-0.5.2.1 · Database.SeldaSqlType TimeOfDayDefined in selda-0.5.2.1 · Database.Selda.SqlTypeThis is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.
Eq UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeData UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeOrd UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeRead UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphanShow UTCTimeDefined in time-1.12.2 · Data.Time.LocalTime.Internal.ZonedTime · orphanNFData UTCTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.UTCTimeFormatTime UTCTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanParseTime UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanISO8601 UTCTimeDefined in time-1.12.2 · Data.Time.Format.ISO8601yyyy-mm-ddThh:mm:ss[.sss]Z (ISO 8601:2004(E) sec. 4.3.2 extended format)
SqlOrd UTCTimeDefined in selda-0.5.2.1 · Database.SeldaSqlType UTCTimeDefined in selda-0.5.2.1 · Database.Selda.SqlTypeType representing Universally Unique Identifiers (UUID) as specified in RFC 4122.
Eq UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalData UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalOrd UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalRead UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalShow UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalStorable UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalNFData UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalRandom UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalUniform UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalBinary UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalHashable UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.InternalIsUUID UUIDDefined in selda-0.5.2.1 · Database.SeldaSqlType UUIDDefined in selda-0.5.2.1 · Database.Selda.SqlTypedefaultValue for UUIDs is the all-zero RFC4122 nil UUID.
Lift UUIDDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal