mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-11-22 18:22:05 +03:00
24 lines
653 B
Haskell
24 lines
653 B
Haskell
module Hasql.Decoders.Composite where
|
|
|
|
import Hasql.Prelude
|
|
import qualified PostgreSQL.Binary.Decoding as A
|
|
|
|
newtype Composite a
|
|
= Composite (ReaderT Bool A.Composite a)
|
|
deriving (Functor, Applicative, Monad, MonadFail)
|
|
|
|
{-# INLINE run #-}
|
|
run :: Composite a -> Bool -> A.Value a
|
|
run (Composite imp) env =
|
|
A.composite (runReaderT imp env)
|
|
|
|
{-# INLINE value #-}
|
|
value :: (Bool -> A.Value a) -> Composite (Maybe a)
|
|
value decoder' =
|
|
Composite $ ReaderT $ A.nullableValueComposite . decoder'
|
|
|
|
{-# INLINE nonNullValue #-}
|
|
nonNullValue :: (Bool -> A.Value a) -> Composite a
|
|
nonNullValue decoder' =
|
|
Composite $ ReaderT $ A.valueComposite . decoder'
|