postgresql-typed-0.3.0: A PostgreSQL access library with compile-time SQL type inference

Copyright2015 Dylan Simon
Safe HaskellNone
LanguageHaskell98

Database.PostgreSQL.Typed.Enum

Description

Support for PostgreSQL enums.

Synopsis

Documentation

makePGEnum Source

Arguments

:: String

PostgreSQL enum type name

-> String

Haskell type to create

-> (String -> String)

How to generate constructor names from enum values, e.g. ("Type_"++)

-> DecsQ 

Create a new enum type corresponding to the given PostgreSQL enum type. For example, if you have CREATE TYPE foo AS ENUM ('abc', 'DEF');, then makePGEnum "foo" "Foo" ("Foo_"++) will be equivalent to:

data Foo = Foo_abc | Foo_DEF deriving (Eq, Ord, Enum, Bounded)
instance PGType Foo where ...
registerPGType "foo" (ConT ''Foo)

Requires language extensions: TemplateHaskell, FlexibleInstances, MultiParamTypeClasses, DataKinds