Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- toFields :: Default ToFields haskells fields => haskells -> fields
- toFieldsI :: Default (Inferrable ToFields) haskells fields => haskells -> fields
- toToFields :: (haskells -> fields) -> ToFields haskells fields
- toFieldsExplicit :: ToFields haskells fields -> haskells -> fields
- data ToFields haskells fields
Creating Field
s from Haskell values
toFields :: Default ToFields haskells fields => haskells -> fields Source #
toFields
provides a convenient typeclass wrapper around the
Field_
creation functions in Opaleye.SqlTypes. Besides
convenience it doesn't provide any additional functionality.
It can be used with functions like runInsert
to insert custom Haskell types into the database.
The following is an example of a function for inserting custom types.
customInsert :: (Default
ToFields
haskells fields ) => Connection ->Table
fields fields' -> [haskells] -> IO Int64 customInsert conn table haskells =runInsert_
connInsert
{ iTable = table , iRows = maptoFields
haskells , iReturning = rCount , iOnConflict = Nothing }
In order to use this function with your custom types, you need to define an
instance of Default
ToFields
for your custom types.
:: Default (Inferrable ToFields) haskells fields | |
=> haskells | |
-> fields |
Version of toFields
with better type inference
Creating ToFields
toToFields :: (haskells -> fields) -> ToFields haskells fields Source #
Explicit versions
toFieldsExplicit :: ToFields haskells fields -> haskells -> fields Source #
Adaptor
data ToFields haskells fields Source #