{-# 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
  { forall a. OneColumn a -> a
getOneColumn :: a
  }
  deriving stock (Int -> OneColumn a -> ShowS
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
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 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 = forall a. a -> OneColumn a
OneColumn forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. NullableOrNot Value a -> Row a
D.column forall a. DecodeField a => NullableOrNot Value a
decodeField