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

Moduleopaleye-0.10.8.0Haskell2010

Opaleye.Field

Functions for working directly with Field_s.

Please note that numeric Field_ types are instances of Num, so you can use *, /, +, - on them. To create Field_s, see Opaleye.ToFields and Opaleye.SqlTypes.

Field_ used to be called Column and for technical reasons there are still a few uses of the old name around. If you see Column SqlType then you can understand it as Field SqlType, and if you see Column ( Nullable SqlType ) then you can understand it as FieldNullable SqlType.

Column will be removed in version 0.11.

(Due to Haddock formatting errors, this documentation previously incorrectly stated that Field_ would be removed. It won't be!)

  • 4 types
  • 11 values
  • Packageopaleye-0.10.8.0
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceField.hs
newtypenewtype Field_ (n :: Nullability) sqlType
#

A field of a Select, of type sqlType. For example a Field SqlInt4 is an int4 column and a Field SqlText is a text column.

Instances67Fractional, Num, IsString, Default, InferrableTableField, …
datadata Nullability
#
Instances10A, …
  • type A ('H HT) ('C '(h, o, N)) = Maybe hDefined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H HT) ('C '(h, o, NN)) = hDefined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H HT) ('TC '(t, b)) = A ('H HT) ('C t)Defined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H NullsT) ('C '(h, o, n)) = Column (Nullable o)Defined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H NullsT) ('TC '(t, b)) = A ('H NullsT) ('C t)Defined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H OT) ('C '(h, o, N)) = Column (Nullable o)Defined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H OT) ('C '(h, o, NN)) = Column oDefined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H OT) ('TC '(t, b)) = A ('H OT) ('C t)Defined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H WT) ('TC '(t, Opt)) = Maybe (A ('H OT) ('C t))Defined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies
  • type A ('H WT) ('TC '(t, Req)) = A ('H OT) ('C t)Defined in opaleye-0.10.8.0 · Opaleye.Internal.TypeFamilies

Casting fields

3 declarations
valueunsafeCast :: String -> Field_ n a -> Field_ n b
#

Cast a column to any other type. Implements Postgres's :: or CAST( ... AS ... ) operations. This is safe for some conversions, such as uuid to text.

Working with NULL

8 declarations

Instead of working with NULL you are recommended to use Opaleye.MaybeFields instead.

valuetypedNull :: IsSqlType a => FieldNullable a
#

Same as null, but with an explicit type CAST. This can help in situations when PostgreSQL can't figure out the type of a NULL. In a future major version this will replace null.

A NULL of any type with no CAST supplied. Use this in preference to null if you really don't want a type cast applied to your NULL.

valuematchNullable
  1. :: Field b
  2. -> (Field a -> Field b)
  3. -> FieldNullable a

    ͘

  4. -> Field b
#

If the Field 'Nullable a is NULL then return the Field 'NonNullable b otherwise map the underlying Field 'Nullable a using the provided function.

The Opaleye equivalent of maybe.

valuefromNullable
  1. :: Field a
  2. -> FieldNullable a

    ͘

  3. -> Field a
#

If the FieldNullable a is NULL then return the provided Field a otherwise return the underlying Field a.

The Opaleye equivalent of fromMaybe and very similar to PostgreSQL's COALESCE.