module Hasql.Interpolate
(
sql,
Sql,
interp,
interpFoldl,
interpWith,
DecodeValue (..),
DecodeField (..),
DecodeRow (..),
DecodeResult (..),
EncodeValue (..),
EncodeField,
OneRow (..),
OneColumn (..),
RowsAffected (..),
Json (..),
Jsonb (..),
AsJson (..),
AsJsonb (..),
CompositeValue (..),
toTable,
EncodeRow (..),
)
where
import Control.Monad.Trans.State.Strict (evalState)
import Data.ByteString.Builder (toLazyByteString)
import Data.ByteString.Lazy (toStrict)
import Hasql.Decoders (Result, foldlRows)
import Hasql.Interpolate.Internal.CompositeValue
import Hasql.Interpolate.Internal.Decoder
import Hasql.Interpolate.Internal.EncodeRow
import Hasql.Interpolate.Internal.Encoder
import Hasql.Interpolate.Internal.Json
import Hasql.Interpolate.Internal.OneColumn
import Hasql.Interpolate.Internal.OneRow
import Hasql.Interpolate.Internal.RowsAffected
import Hasql.Interpolate.Internal.Sql
import Hasql.Interpolate.Internal.TH
import Hasql.Statement (Statement (..))
interp ::
DecodeResult b =>
Bool ->
Sql ->
Statement () b
interp :: forall b. DecodeResult b => Bool -> Sql -> Statement () b
interp Bool
prepared = forall b. Bool -> Result b -> Sql -> Statement () b
interpWith Bool
prepared forall a. DecodeResult a => Result a
decodeResult
interpFoldl :: DecodeRow a => Bool -> (b -> a -> b) -> b -> Sql -> Statement () b
interpFoldl :: forall a b.
DecodeRow a =>
Bool -> (b -> a -> b) -> b -> Sql -> Statement () b
interpFoldl Bool
prepared b -> a -> b
f b
z = forall b. Bool -> Result b -> Sql -> Statement () b
interpWith Bool
prepared (forall a b. (a -> b -> a) -> a -> Row b -> Result a
foldlRows b -> a -> b
f b
z forall a. DecodeRow a => Row a
decodeRow)
interpWith :: Bool -> Result b -> Sql -> Statement () b
interpWith :: forall b. Bool -> Result b -> Sql -> Statement () b
interpWith Bool
prepare Result b
decoder (Sql State Int Builder
bldr Params ()
enc) = forall a b.
ByteString -> Params a -> Result b -> Bool -> Statement a b
Statement (ByteString -> ByteString
toStrict (Builder -> ByteString
toLazyByteString (forall s a. State s a -> s -> a
evalState State Int Builder
bldr Int
1))) Params ()
enc Result b
decoder Bool
prepare