Rename some result decoders

This commit is contained in:
Nikita Volkov 2018-05-23 18:11:16 +08:00
parent 8eb3830a7f
commit 726097efd5
5 changed files with 27 additions and 27 deletions

View File

@ -100,8 +100,8 @@ queryWithManyRows decoder =
queryWithManyRowsInVector :: C.Query () (Vector (Int64, Int64))
queryWithManyRowsInVector =
queryWithManyRows D.rowsVector
queryWithManyRows D.rowVector
queryWithManyRowsInList :: C.Query () (List (Int64, Int64))
queryWithManyRowsInList =
queryWithManyRows D.rowsList
queryWithManyRows D.rowList

View File

@ -8,9 +8,9 @@ module Hasql.Decoders
rowsAffected,
singleRow,
-- ** Specialized multi-row results
maybeRow,
rowsVector,
rowsList,
rowMaybe,
rowVector,
rowList,
-- ** Multi-row traversers
foldlRows,
foldrRows,
@ -134,28 +134,28 @@ foldrRows step init (Row row) =
-- |
-- Maybe one row or none.
--
{-# INLINABLE maybeRow #-}
maybeRow :: Row a -> Result (Maybe a)
maybeRow (Row row) =
{-# INLINABLE rowMaybe #-}
rowMaybe :: Row a -> Result (Maybe a)
rowMaybe (Row row) =
Result (Results.single (Result.maybe row))
-- |
-- Zero or more rows packed into the vector.
--
-- It's recommended to prefer this function to 'rowsList',
-- It's recommended to prefer this function to 'rowList',
-- since it performs notably better.
--
{-# INLINABLE rowsVector #-}
rowsVector :: Row a -> Result (Vector a)
rowsVector (Row row) =
{-# INLINABLE rowVector #-}
rowVector :: Row a -> Result (Vector a)
rowVector (Row row) =
Result (Results.single (Result.vector row))
-- |
-- Zero or more rows packed into the list.
--
{-# INLINABLE rowsList #-}
rowsList :: Row a -> Result [a]
rowsList =
{-# INLINABLE rowList #-}
rowList :: Row a -> Result [a]
rowList =
foldrRows strictCons []
@ -174,23 +174,23 @@ instance Default (Result Int64) where
def =
rowsAffected
-- | Maps to @('maybeRow' def)@.
-- | Maps to @('rowMaybe' def)@.
instance Default (Row a) => Default (Result (Maybe a)) where
{-# INLINE def #-}
def =
maybeRow def
rowMaybe def
-- | Maps to @('rowsVector' def)@.
-- | Maps to @('rowVector' def)@.
instance Default (Row a) => Default (Result (Vector a)) where
{-# INLINE def #-}
def =
rowsVector def
rowVector def
-- | Maps to @('rowsList' def)@.
-- | Maps to @('rowList' def)@.
instance Default (Row a) => Default (Result ([] a)) where
{-# INLINE def #-}
def =
rowsList def
rowList def
-- | Maps to @(fmap Identity ('singleRow' def)@.
instance Default (Row a) => Default (Result (Identity a)) where

View File

@ -91,8 +91,8 @@ queryWithManyRows decoder =
queryWithManyRowsInVector :: C.Query () (Vector (Int64, Int64))
queryWithManyRowsInVector =
queryWithManyRows D.rowsVector
queryWithManyRows D.rowVector
queryWithManyRowsInList :: C.Query () (List (Int64, Int64))
queryWithManyRowsInList =
queryWithManyRows D.rowsList
queryWithManyRows D.rowList

View File

@ -32,7 +32,7 @@ tree =
(Encoders.param (Encoders.array (Encoders.dimension foldl' (Encoders.element Encoders.int8))))
(Encoders.param Encoders.text)
decoder =
fmap (maybe False (const True)) (Decoders.maybeRow (Decoders.column Decoders.bool))
fmap (maybe False (const True)) (Decoders.rowMaybe (Decoders.column Decoders.bool))
session =
Session.query ([3, 7], "a") query
in do
@ -49,7 +49,7 @@ tree =
encoder =
Encoders.param (Encoders.array (Encoders.dimension foldl' (Encoders.element Encoders.int8)))
decoder =
fmap (maybe False (const True)) (Decoders.maybeRow (Decoders.column Decoders.bool))
fmap (maybe False (const True)) (Decoders.rowMaybe (Decoders.column Decoders.bool))
session =
do
result1 <- Session.query [1, 2] query
@ -67,7 +67,7 @@ tree =
encoder =
Encoders.param (Encoders.array (Encoders.dimension foldl' (Encoders.element Encoders.int8)))
decoder =
fmap (maybe False (const True)) (Decoders.maybeRow (Decoders.column Decoders.bool))
fmap (maybe False (const True)) (Decoders.rowMaybe (Decoders.column Decoders.bool))
session =
do
result1 <- Session.query [1, 2] query

View File

@ -33,4 +33,4 @@ selectList =
sql =
"values (1,2), (3,4), (5,6)"
decoder =
HD.rowsList ((,) <$> HD.column HD.int8 <*> HD.column HD.int8)
HD.rowList ((,) <$> HD.column HD.int8 <*> HD.column HD.int8)