HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulepg-entity-0.0.4.4Haskell2010

Database.PostgreSQL.Entity.Types

Types and classes

  • 13 types
  • 3 classes
  • 4 values

The Entity Typeclass

1 declaration
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

6 declarations
datadata Field
#

A wrapper for table fields.

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

    Using the Overloaded String syntax for Field names is forbidden.

valuefield :: QuasiQuoter
#

A quasi-quoter for safely constructing Fields.

Example:

instance Entity BlogPost where
  tableName  = "blogposts"
  primaryKey = [field| blogpost_id |]
  fields = [ [field| blogpost_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.4.4 · Database.PostgreSQL.Entity.Types
  • Show a => Show (UpdateRow a)Defined in pg-entity-0.0.4.4 · Database.PostgreSQL.Entity.Types
  • ToRow a => ToRow (UpdateRow a)Defined in pg-entity-0.0.4.4 · Database.PostgreSQL.Entity.Types
  • Entity a => Entity (UpdateRow a)Defined in pg-entity-0.0.4.4 · Database.PostgreSQL.Entity.Types

Generics

2 declarations

DerivingVia Options

11 declarations
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