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

Modulepg-entity-0.0.6.0Haskell2010

Database.PostgreSQL.Entity.Types

Types and classes

Contents
  1. The Entity Typeclass
  2. Associated Types
  3. Generics
  4. DerivingVia Options
Synopsis

The Entity Typeclass

classclass Entity e where

An Entity stores the following information about the structure of a database table:

  • Its name

  • Its primary key

  • The fields it contains

Example

data ExampleEntity = E
  { key    :: Key
  , field1 :: Int
  , field2 :: Bool
  }
  deriving stock (Eq, Show, Generic)
  deriving anyclass (FromRow, ToRow)
  deriving Entity
     via (GenericEntity '[TableName "entities"] ExampleEntity)

When using the functions provided by this library, you will sometimes need to be explicit about the Entity you are referring to.

Methods

Instances2Entity

Associated Types

datadata Field

A wrapper for table fields.

Instances3Eq, Show, IsString
  • Eq FieldDefined in pg-entity-0.0.6.0 · Database.PostgreSQL.Entity.Internal.Unsafe
  • Show FieldDefined in pg-entity-0.0.6.0 · Database.PostgreSQL.Entity.Internal.Unsafe
  • ForbiddenIsString => IsString FieldDefined in pg-entity-0.0.6.0 · Database.PostgreSQL.Entity.Internal.Unsafe

    Using the Overloaded String syntax for Field names is forbidden.

A quasi-quoter for safely constructing Fields.

Example:

instance Entity BlogPost where
  tableName  = "blogposts"
  primaryKey = [field| blog_post_id |]
  fields = [ [field| blog_post_id |]
           , [field| author_id |]
           , [field| uuid_list :: uuid[] |] -- ← This is where we specify an optional PostgreSQL type annotation
           , [field| title |]
           , [field| content |]
           , [field| created_at |]
           ]
newtypenewtype UpdateRow a

Wrapper used by the update function in order to have the primary key as the last parameter passed, since it appears in the WHERE clause.

Constructors

Instances4Eq, Show, ToRow, Entity
  • Eq a => Eq (UpdateRow a)Defined in pg-entity-0.0.6.0 · Database.PostgreSQL.Entity.Types
  • Show a => Show (UpdateRow a)Defined in pg-entity-0.0.6.0 · Database.PostgreSQL.Entity.Types
  • ToRow a => ToRow (UpdateRow a)Defined in pg-entity-0.0.6.0 · Database.PostgreSQL.Entity.Types
  • Entity a => Entity (UpdateRow a)Defined in pg-entity-0.0.6.0 · Database.PostgreSQL.Entity.Types

Generics

DerivingVia Options

classclass EntityOptions (xs :: k) where

Type-level options for Deriving Via

Instances5EntityOptions
classclass TextModifier (t :: k) where

The modifiers that you can apply to the fields:

Instances4TextModifier
datadata CamelTo (separator :: Symbol)

FieldModifier taking a separator Char when transforming from CamelCase.

Instances1TextModifier