Copyright | 2015 Dylan Simon |
---|---|
Safe Haskell | None |
Language | Haskell98 |
Support for PostgreSQL enums.
Documentation
:: String | PostgreSQL enum type name |
-> String | Haskell type to create |
-> (String -> String) | How to generate constructor names from enum values, e.g. |
-> 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