database-id-groundhog: HasId/Groundhog interop

[ bsd3, database, library ] [ Propose Tags ]

A class and some instances for HasId/Groundhog interoperation

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
Dependencies aeson, base (>=4.11 && <4.13), database-id-class, groundhog (<=, template-haskell [details]
License BSD-3-Clause
Copyright 2019 Obsidian Systems LLC
Author Obsidian Systems LLC
Category Database
Uploaded by abrar at 2019-07-21T07:34:58Z
Distributions NixOS:
Downloads 511 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for database-id-groundhog-

[back to package description]


This package provides support for groundhog database interaction to database-id-class, in particular, the functions

toId :: DefaultKeyId a => DefaultKey a -> Id a
fromId :: DefaultKeyId a => Id a -> DefaultKey a

which convert back and forth between the Id and groundhog's DefaultKey representation according to the instances of the DefaultKeyId class.

It also includes the Template Haskell macro makeDefaultKeyIdInt64 which, given the Name of a datatype and the Name of the data constructor for its groundhog-generated key datatype (typically named the same as the type, with the suffix "Key"), produces an instance of DefaultKeyId in cases where the primary key is an Int64.

Similar to this, makeDefaultKeyIdSimple exists for cases where all that is required to go between DefaultKey a and IdData a is to remove (or put back) Groundhog's type-specific Key data constructor.

It also includes instances of PersistField and PrimitivePersistField for Id a.