HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

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

Contents
  1. Casting fields
  2. Working with NULL
Synopsis
  • 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

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

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

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.