hasql-class-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Hasql.Class.Encodable

Synopsis

Documentation

class Encodable a where Source

Datatypes that can be encoded as hasql PostgreSQL parameters.

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