mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-12-28 04:57:14 +03:00
Docs
This commit is contained in:
parent
9e80ecf577
commit
d1425a7ccb
@ -150,7 +150,7 @@ disconnect (Connection pqConnection _ _) =
|
||||
-- sql =
|
||||
-- "select ($1 + $2)"
|
||||
-- encoder =
|
||||
-- 'contramap' 'fst' (Hasql.Encoding.'Hasql.Encoding.value' Hasql.Encoding.'Hasql.Encoding.int8') <>
|
||||
-- 'contramap' 'fst' (Hasql.Encoding.'Hasql.Encoding.value' Hasql.Encoding.'Hasql.Encoding.int8') '<>'
|
||||
-- 'contramap' 'snd' (Hasql.Encoding.'Hasql.Encoding.value' Hasql.Encoding.'Hasql.Encoding.int8')
|
||||
-- decoder =
|
||||
-- Hasql.Decoding.'Hasql.Decoding.singleRow' (Hasql.Decoding.'Hasql.Decoding.value' Hasql.Decoding.'Hasql.Decoding.int8')
|
||||
|
@ -59,18 +59,14 @@ import qualified Hasql.Prelude as Prelude
|
||||
-- @
|
||||
-- someParamsEncoder :: Params (Int64, Maybe Text)
|
||||
-- someParamsEncoder =
|
||||
-- 'contramap' fst (value int8) <>
|
||||
-- 'contramap' snd (nullableValue text)
|
||||
-- 'contramap' 'fst' (value int8) '<>'
|
||||
-- 'contramap' 'snd' (nullableValue text)
|
||||
-- @
|
||||
--
|
||||
-- As a general solution for tuples of any arity, instead of 'fst' and 'snd',
|
||||
-- consider such solutions as
|
||||
-- the @<http://hackage.haskell.org/package/tuple-th-0.2.5/docs/TupleTH.html#v:proj proj>@ macro.
|
||||
--
|
||||
-- Alternatively you can achieve the same using the functions of the @contrazip@ family
|
||||
-- from the \"contravariant-extras\" package,
|
||||
-- which are especially helpful when dealing with tuples.
|
||||
-- E.g.,
|
||||
-- consider the functions of the @contrazip@ family
|
||||
-- from the \"contravariant-extras\" package.
|
||||
-- E.g., here's how you can achieve the same as the above:
|
||||
--
|
||||
-- @
|
||||
-- someParamsEncoder :: Params (Int64, Maybe Text)
|
||||
@ -89,8 +85,8 @@ import qualified Hasql.Prelude as Prelude
|
||||
--
|
||||
-- personParams :: Params Person
|
||||
-- personParams =
|
||||
-- 'contramap' name (value text) <>
|
||||
-- 'contramap' gender (value genderValue) <>
|
||||
-- 'contramap' name (value text) '<>'
|
||||
-- 'contramap' gender (value genderValue) '<>'
|
||||
-- 'contramap' (fromIntegral . age) (value int8)
|
||||
--
|
||||
-- genderValue :: Value Gender
|
||||
|
Loading…
Reference in New Issue
Block a user