hasql-class-0.0.0.1: Encodable and Decodable classes for hasql

Safe HaskellNone
LanguageHaskell2010

Hasql.Class.Internal.Encodable

Synopsis

Documentation

class Encodable a where Source

Datatypes that can be encoded as hasql PostgreSQL parameters. This class can be generically derived.

Note that the number of parameters is not necessarily the number of Haskell values. For example

data MyData = MyData { aChar :: Char, aText :: Text }
 deriving (Eq, Show, Generic, Encodable)

aData :: MyData
aData = MyDate 'a' "ha!"

-- Will only insert the char, and a NULL for the text value
wrong = query aData stmtUnit "INSERT INTO myTable ($1)" True

-- Will insert both the char and the text values
right = query aData stmtUnit "INSERT INTO myTable ($1, $2)" True

Minimal complete definition

Nothing

Methods

encode :: Params a Source