{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}

module Hasql.Interpolate.Internal.OneColumn
  ( OneColumn (..),
  )
where

import GHC.Generics (Generic)
import qualified Hasql.Decoders as D
import Hasql.Interpolate.Internal.Decoder

newtype OneColumn a = OneColumn
  { OneColumn a -> a
getOneColumn :: a
  }
  deriving stock (Int -> OneColumn a -> ShowS
[OneColumn a] -> ShowS
OneColumn a -> String
(Int -> OneColumn a -> ShowS)
-> (OneColumn a -> String)
-> ([OneColumn a] -> ShowS)
-> Show (OneColumn a)
forall a. Show a => Int -> OneColumn a -> ShowS
forall a. Show a => [OneColumn a] -> ShowS
forall a. Show a => OneColumn a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OneColumn a] -> ShowS
$cshowList :: forall a. Show a => [OneColumn a] -> ShowS
show :: OneColumn a -> String
$cshow :: forall a. Show a => OneColumn a -> String
showsPrec :: Int -> OneColumn a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> OneColumn a -> ShowS
Show, OneColumn a -> OneColumn a -> Bool
(OneColumn a -> OneColumn a -> Bool)
-> (OneColumn a -> OneColumn a -> Bool) -> Eq (OneColumn a)
forall a. Eq a => OneColumn a -> OneColumn a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OneColumn a -> OneColumn a -> Bool
$c/= :: forall a. Eq a => OneColumn a -> OneColumn a -> Bool
== :: OneColumn a -> OneColumn a -> Bool
$c== :: forall a. Eq a => OneColumn a -> OneColumn a -> Bool
Eq, (forall x. OneColumn a -> Rep (OneColumn a) x)
-> (forall x. Rep (OneColumn a) x -> OneColumn a)
-> Generic (OneColumn a)
forall x. Rep (OneColumn a) x -> OneColumn a
forall x. OneColumn a -> Rep (OneColumn a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (OneColumn a) x -> OneColumn a
forall a x. OneColumn a -> Rep (OneColumn a) x
$cto :: forall a x. Rep (OneColumn a) x -> OneColumn a
$cfrom :: forall a x. OneColumn a -> Rep (OneColumn a) x
Generic)

-- | Parse a single column row
instance DecodeField a => DecodeRow (OneColumn a) where
  decodeRow :: Row (OneColumn a)
decodeRow = a -> OneColumn a
forall a. a -> OneColumn a
OneColumn (a -> OneColumn a) -> Row a -> Row (OneColumn a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NullableOrNot Value a -> Row a
forall a. NullableOrNot Value a -> Row a
D.column NullableOrNot Value a
forall a. DecodeField a => NullableOrNot Value a
decodeField