diff --git a/benchmarks/Main.hs b/benchmarks/Main.hs index 19919f3..b4b7e7f 100644 --- a/benchmarks/Main.hs +++ b/benchmarks/Main.hs @@ -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 diff --git a/library/Hasql/Decoders.hs b/library/Hasql/Decoders.hs index b5ab1ea..c083188 100644 --- a/library/Hasql/Decoders.hs +++ b/library/Hasql/Decoders.hs @@ -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 diff --git a/profiling/Main.hs b/profiling/Main.hs index fd295f1..5089a4a 100644 --- a/profiling/Main.hs +++ b/profiling/Main.hs @@ -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 diff --git a/tasty/Main.hs b/tasty/Main.hs index c7f2565..1d9ed89 100644 --- a/tasty/Main.hs +++ b/tasty/Main.hs @@ -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 diff --git a/tasty/Main/Queries.hs b/tasty/Main/Queries.hs index 5619a44..2cd8ee2 100644 --- a/tasty/Main/Queries.hs +++ b/tasty/Main/Queries.hs @@ -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)