hasql/library/Hasql/Decoders/Value.hs
2024-01-27 00:23:09 +03:00

25 lines
556 B
Haskell

module Hasql.Decoders.Value where
import Hasql.Prelude
import qualified PostgreSQL.Binary.Decoding as A
newtype Value a
= Value (Bool -> A.Value a)
deriving (Functor)
{-# INLINE run #-}
run :: Value a -> Bool -> A.Value a
run (Value imp) integerDatetimes =
imp integerDatetimes
{-# INLINE decoder #-}
decoder :: (Bool -> A.Value a) -> Value a
decoder =
{-# SCC "decoder" #-}
Value
{-# INLINE decoderFn #-}
decoderFn :: (Bool -> ByteString -> Either Text a) -> Value a
decoderFn fn =
Value $ \integerDatetimes -> A.fn $ fn integerDatetimes