module Hasql.Private.Decoders.Composite where

import Hasql.Private.Prelude
import qualified PostgreSQL.Binary.Decoding as A

newtype Composite a
  = Composite (ReaderT Bool A.Composite a)
  deriving (forall a b. a -> Composite b -> Composite a
forall a b. (a -> b) -> Composite a -> Composite b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Composite b -> Composite a
$c<$ :: forall a b. a -> Composite b -> Composite a
fmap :: forall a b. (a -> b) -> Composite a -> Composite b
$cfmap :: forall a b. (a -> b) -> Composite a -> Composite b
Functor, Functor Composite
forall a. a -> Composite a
forall a b. Composite a -> Composite b -> Composite a
forall a b. Composite a -> Composite b -> Composite b
forall a b. Composite (a -> b) -> Composite a -> Composite b
forall a b c.
(a -> b -> c) -> Composite a -> Composite b -> Composite c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: forall a b. Composite a -> Composite b -> Composite a
$c<* :: forall a b. Composite a -> Composite b -> Composite a
*> :: forall a b. Composite a -> Composite b -> Composite b
$c*> :: forall a b. Composite a -> Composite b -> Composite b
liftA2 :: forall a b c.
(a -> b -> c) -> Composite a -> Composite b -> Composite c
$cliftA2 :: forall a b c.
(a -> b -> c) -> Composite a -> Composite b -> Composite c
<*> :: forall a b. Composite (a -> b) -> Composite a -> Composite b
$c<*> :: forall a b. Composite (a -> b) -> Composite a -> Composite b
pure :: forall a. a -> Composite a
$cpure :: forall a. a -> Composite a
Applicative, Applicative Composite
forall a. a -> Composite a
forall a b. Composite a -> Composite b -> Composite b
forall a b. Composite a -> (a -> Composite b) -> Composite b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: forall a. a -> Composite a
$creturn :: forall a. a -> Composite a
>> :: forall a b. Composite a -> Composite b -> Composite b
$c>> :: forall a b. Composite a -> Composite b -> Composite b
>>= :: forall a b. Composite a -> (a -> Composite b) -> Composite b
$c>>= :: forall a b. Composite a -> (a -> Composite b) -> Composite b
Monad, Monad Composite
forall a. String -> Composite a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
fail :: forall a. String -> Composite a
$cfail :: forall a. String -> Composite a
MonadFail)

{-# INLINE run #-}
run :: Composite a -> Bool -> A.Value a
run :: forall a. Composite a -> Bool -> Value a
run (Composite ReaderT Bool Composite a
imp) Bool
env =
  forall a. Composite a -> Value a
A.composite (forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT ReaderT Bool Composite a
imp Bool
env)

{-# INLINE value #-}
value :: (Bool -> A.Value a) -> Composite (Maybe a)
value :: forall a. (Bool -> Value a) -> Composite (Maybe a)
value Bool -> Value a
decoder' =
  forall a. ReaderT Bool Composite a -> Composite a
Composite forall a b. (a -> b) -> a -> b
$ forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT forall a b. (a -> b) -> a -> b
$ forall a. Value a -> Composite (Maybe a)
A.nullableValueComposite forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Bool -> Value a
decoder'

{-# INLINE nonNullValue #-}
nonNullValue :: (Bool -> A.Value a) -> Composite a
nonNullValue :: forall a. (Bool -> Value a) -> Composite a
nonNullValue Bool -> Value a
decoder' =
  forall a. ReaderT Bool Composite a -> Composite a
Composite forall a b. (a -> b) -> a -> b
$ forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT forall a b. (a -> b) -> a -> b
$ forall a. Value a -> Composite a
A.valueComposite forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Bool -> Value a
decoder'