HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulepersistent-2.14.6.3Haskell2010

Database.Persist.Quasi.Internal

This Internal module may have breaking changes that will not be reflected in major version bumps. Please use Database.Persist.Quasi instead. If you need something in this module, please file an issue on GitHub.

  • 13 types
  • 20 values
datadata PersistSettings
#

Constructors

datadata Token
#

A token used by the parser.

Constructors

  • Token Text

    Token tok is token tok already unquoted.

  • DocComment Text

    DocComment is a documentation comment, unmodified.

Instances2Eq, Show
  • Eq TokenDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
  • Show TokenDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal

UnboundEntityDef

19 declarations
datadata UnboundEntityDef
#

An EntityDef produced by the QuasiQuoter. It contains information that the QuasiQuoter is capable of knowing about the entities. It is inherently unfinished, though - there are many other Unbound datatypes that also contain partial information.

The unboundEntityDef is not complete or reliable - to know which fields are safe to use, consult the parsing code.

This type was completely internal until 2.13.0.0, when it was exposed as part of the Database.Persist.Quasi.Internal module.

TODO: refactor this so we can expose it for consumers.

Constructors

Instances4Eq, Ord, Show, Lift
datadata UnboundForeignDef
#

Define an explicit foreign key reference.

User
    name Text
    email Text

    Primary name email

Dog
    ownerName Text
    ownerEmail Text

    Foreign User fk_dog_user ownerName ownerEmail

Constructors

Instances4Eq, Ord, Show, Lift
datadata UnboundFieldDef
#

A representation of a database column, with everything that can be known at parse time.

Constructors

  • UnboundFieldDef
    • unboundFieldNameHS :: FieldNameHS

      The Haskell name of the field. This is parsed directly from the definition, and is used to generate the Haskell record field and the EntityField definition.

    • unboundFieldNameDB :: FieldNameDB

      The database name of the field. By default, this is determined by the PersistSettings record at parse time. You can customize this with a sql= attribute:

          name Text  sql=foo_name
      
    • unboundFieldAttrs :: [FieldAttr]

      The attributes present on the field. For rules on parsing and utility, see the comments on the datatype.

    • unboundFieldStrict :: Bool

      Whether or not the field should be strict in the generated Haskell code.

    • unboundFieldType :: FieldType

      The type of the field, as far as is known at parse time.

      The TemplateHaskell code will reconstruct a Type out of this, but the names will be imported as-is.

    • unboundFieldCascade :: FieldCascade

      We parse if there's a FieldCascade on the field. If the field is not a reference, this information is ignored.

      Post
         user UserId OnDeleteCascade
      
    • unboundFieldGenerated :: Maybe Text

      Contains an expression to generate the column. If this is present, then the column will not be written to the database, but generated by the expression every time.

      Item
          subtotal Int
          taxRate  Rational
          total    Int      generated="subtotal * tax_rate"
      
    • unboundFieldComments :: Maybe Text

      Any comments present on the field. Documentation comments use a Haskell-like syntax, and must be present before the field in question.

      Post
          -- | This is the blog post title.
          title Text
          -- | You can have multi-line comments.
          -- | But each line must have the pipe character.
          author UserId
      
Instances4Eq, Ord, Show, Lift
datadata UnboundCompositeDef
#

A definition for a composite primary key.

@since.2.13.0.0

Constructors

Instances4Eq, Ord, Show, Lift
datadata UnboundIdDef
#

This type represents an Id declaration in the QuasiQuoted syntax.

Id

This uses the implied settings, and is equivalent to omitting the Id statement entirely.

Id Text

This will set the field type of the ID to be Text.

Id Text sql=foo_id

This will set the field type of the Id to be Text and the SQL DB name to be foo_id.

Id FooId

This results in a shared primary key - the FooId refers to a Foo table.

Id FooId OnDelete Cascade

You can set a cascade behavior on an ID column.

Instances4Eq, Ord, Show, Lift
  • Eq UnboundIdDefDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
  • Ord UnboundIdDefDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
  • Show UnboundIdDefDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
  • Lift UnboundIdDefDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
datadata PrimarySpec
#

The specification for how an entity's primary key should be formed.

Persistent requires that every table have a primary key. By default, an implied ID is assigned, based on the mpsImplicitIdDef field on MkPersistSettings. Because we can't access that type at parse-time, we defer that decision until later.

Constructors

  • NaturalKey UnboundCompositeDef

    A NaturalKey contains columns that are defined on the datatype itself. This is defined using the Primary keyword and given a non-empty list of columns.

    User
        name    Text
        email   Text
    
        Primary name email
    

    A natural key may also contain only a single column. A natural key with multiple columns is called a 'composite key'.

  • SurrogateKey UnboundIdDef

    A surrogate key is not part of the domain model for a database table. You can specify a custom surro

    You can specify a custom surrogate key using the Id syntax.

    User
        Id    Text
        name  Text
    

    Note that you must provide a default= expression when using this in order to use insert or related functions. The insertKey function can be used instead, as it allows you to specify a key directly. Fixing this issue is tracked in #1247 on GitHub.

  • DefaultKey FieldNameDB

    The default key for the entity using the settings in MkPersistSettings.

    This is implicit - a table without an Id or Primary declaration will have a DefaultKey.

Instances4Eq, Ord, Show, Lift
  • Eq PrimarySpecDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
  • Ord PrimarySpecDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
  • Show PrimarySpecDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal
  • Lift PrimarySpecDefined in persistent-2.14.6.3 · Database.Persist.Quasi.Internal

A list of fields present on the foreign reference.

Constructors

  • FieldListImpliedId (NonEmpty FieldNameHS)

    If no References keyword is supplied, then it is assumed that you are referring to the Primary key or Id of the target entity.

  • FieldListHasReferences (NonEmpty ForeignFieldReference)

    You can specify the exact columns you're referring to here, if they aren't part of a primary key. Most databases expect a unique index on the columns you refer to, but Persistent doesnt' check that.

    User
        Id           UUID default="uuid_generate_v1mc()"
        name         Text
    
        UniqueName name
    
    Dog
        ownerName    Text
    
        Foreign User fk_dog_user ownerName References name
    
Instances4Eq, Ord, Show, Lift

A pairing of the FieldNameHS for the source table to the FieldNameHS for the target table.

Constructors

Instances4Eq, Ord, Show, Lift