{-# OPTIONS_HADDOCK prune not-home #-}
module KeyedVals.Handle.Codec.HttpApiData (
HttpApiDataOf (..),
) where
import KeyedVals.Handle.Codec (DecodeKV (..), EncodeKV (..))
import Web.HttpApiData (
FromHttpApiData (..),
ToHttpApiData (..),
)
newtype HttpApiDataOf a = HttpApiDataOf {forall a. HttpApiDataOf a -> a
fromHttpApiDataOf :: a}
instance FromHttpApiData a => DecodeKV (HttpApiDataOf a) where
decodeKV :: Val -> Either Text (HttpApiDataOf a)
decodeKV = (a -> HttpApiDataOf a)
-> Either Text a -> Either Text (HttpApiDataOf a)
forall a b. (a -> b) -> Either Text a -> Either Text b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> HttpApiDataOf a
forall a. a -> HttpApiDataOf a
HttpApiDataOf (Either Text a -> Either Text (HttpApiDataOf a))
-> (Val -> Either Text a) -> Val -> Either Text (HttpApiDataOf a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Val -> Either Text a
forall a. FromHttpApiData a => Val -> Either Text a
parseHeader
instance ToHttpApiData a => EncodeKV (HttpApiDataOf a) where
encodeKV :: HttpApiDataOf a -> Val
encodeKV = a -> Val
forall a. ToHttpApiData a => a -> Val
toHeader (a -> Val) -> (HttpApiDataOf a -> a) -> HttpApiDataOf a -> Val
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HttpApiDataOf a -> a
forall a. HttpApiDataOf a -> a
fromHttpApiDataOf