mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-11-26 11:57:01 +03:00
Add "foldableArray" encoder
This commit is contained in:
parent
38e80351e6
commit
799fbca0ed
@ -17,6 +17,7 @@ module Hasql.Encoders
|
|||||||
-- * Value
|
-- * Value
|
||||||
Value,
|
Value,
|
||||||
array,
|
array,
|
||||||
|
foldableArray,
|
||||||
bool,
|
bool,
|
||||||
int2,
|
int2,
|
||||||
int4,
|
int4,
|
||||||
|
@ -122,6 +122,26 @@ array (Array (Array.Array valueOID arrayOID arrayEncoder renderer)) = let
|
|||||||
encoder env input = A.array (PTI.oidWord32 valueOID) (arrayEncoder env input)
|
encoder env input = A.array (PTI.oidWord32 valueOID) (arrayEncoder env input)
|
||||||
in Value (Value.Value arrayOID arrayOID encoder renderer)
|
in Value (Value.Value arrayOID arrayOID encoder renderer)
|
||||||
|
|
||||||
|
{-|
|
||||||
|
Lift a value encoder of element into a unidimensional array encoder of a foldable value.
|
||||||
|
|
||||||
|
E.g.,
|
||||||
|
|
||||||
|
@
|
||||||
|
vectorOfInts :: Value (Vector Int64)
|
||||||
|
vectorOfInts = 'foldableArray' ('nonNullable' 'int8')
|
||||||
|
@
|
||||||
|
|
||||||
|
This function is merely a shortcut for the following expression:
|
||||||
|
|
||||||
|
@
|
||||||
|
('array' . 'dimension' 'foldl'' . 'element')
|
||||||
|
@
|
||||||
|
-}
|
||||||
|
{-# INLINE foldableArray #-}
|
||||||
|
foldableArray :: Foldable foldable => NullableOrNot Value a -> Value (foldable a)
|
||||||
|
foldableArray = array . dimension foldl' . element
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
Encoder of @BOOL@ values.
|
Encoder of @BOOL@ values.
|
||||||
-}
|
-}
|
||||||
|
Loading…
Reference in New Issue
Block a user