HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

  • Packageopaleye-0.10.8.0
  • Exports81
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceOperators.hs

Restriction operators

4 declarations
valuewhere_ :: Field SqlBool -> Select ()
#

Keep only the rows of a query satisfying a given condition, using an SQL WHERE clause. It is equivalent to the Haskell function

where_ :: Bool -> [()]
where_ True  = [()]
where_ False = []

Numerical operators

8 declarations

Numeric Column / Field types are instances of Num and Fractional, so you can use the standard Haskell numerical operators (e.g.. *, /, +, -) on them and you can create them with numerical literals such as 3.14 :: Field SqlFloat8.

method(+) :: a -> a -> a
#
method(-) :: a -> a -> a
#
method(*) :: a -> a -> a
#
method(/) :: a -> a -> a
#

Fractional division.

methodabs :: a -> a
#

Absolute value.

methodnegate :: a -> a
#

Unary negation.

methodsignum :: a -> a
#

Sign of a number. The functions abs and signum should satisfy the law:

abs x * signum x == x

For real numbers, the signum is either -1 (negative), 0 (zero) or 1 (positive).

Equality operators

4 declarations
value(.===) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
#

A polymorphic equality operator that works for all types that you have run makeAdaptorAndInstanceInferrable on. This may be unified with .== in a future version.

value(./==) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
#

A polymorphic inequality operator that works for all types that you have run makeAdaptorAndInstanceInferrable on. This may be unified with ./= in a future version.

Comparison operators

4 declarations

Numerical operators

2 declarations
valuerem_ :: SqlIntegral a => Field a -> Field a -> Field a
#

The remainder of integral division, named after rem. It maps to MOD (%) in Postgres, confusingly described as "modulo (remainder)".

Conditional operators

3 declarations

Logical operators

4 declarations

Text operators

6 declarations

Containment operators

3 declarations
valuein_ :: Foldable f => f (Field a) -> Field a -> Field SqlBool
#

in_ is designed to be used in prefix form.

in_ validUsers user checks whether user is a valid user. in_ validUsers is a function which checks whether a user is a valid user.

valueinMany
  1. :: (Foldable f, Default EqPP fields fields)
  2. => f fields
  3. -> fields
  4. -> Field SqlBool
#

inMany is a generalization of in_ to values with multiple fields. It is designed to be used in prefix form.

inMany validUsers user checks whether user is a valid user. inMany validUsers is a function which checks whether a user is a valid user.

valueinSelect
  1. :: Default EqPP fields fields
  2. => fields
  3. -> Select fields
  4. -> Select (Field SqlBool)
#

True if the first argument occurs amongst the rows of the second, false otherwise.

This operation is equivalent to Postgres's IN operator.

JSON operators

15 declarations
classclass SqlIsJson json
#

Class of Postgres types that represent json values. Used to overload functions and operators that work on both SqlJson and SqlJsonb.

Warning: making additional instances of this class can lead to broken code!

Instances2SqlIsJson
classclass SqlJsonIndex a
#

Class of Postgres types that can be used to index json values.

Warning: making additional instances of this class can lead to broken code!

Instances3SqlJsonIndex

SqlArray operators

10 declarations
valuesqlElem
  1. :: Field_ n a

    Needle

  2. -> Field (SqlArray_ n a)

    Haystack

  3. -> Field SqlBool
#

Whether the element (needle) exists in the array (haystack). N.B. this is implemented hackily using array_position. If you want the equivalent implemented using = any then use sqlElemAny.

Range operators

9 declarations

Other operators

9 declarations
classclass IntervalNum from to | from -> to
#

IntervalNum from to determines from which date or time types an interval can be added (addInterval) or subtracted (minusInterval) and which is the resulting type.

The instances should correspond to the interval + and - operations listed in:

https://www.postgresql.org/docs/current/functions-datetime.html#OPERATORS-DATETIME-TABLE

Instances5IntervalNum

Deprecated

0 declarations