{-# language GADTs #-}
{-# language NamedFieldPuns #-}
{-# language StandaloneKindSignatures #-}
{-# language StrictData #-}
module Rel8.Type.Information
( TypeInformation(..)
, mapTypeInformation
, parseTypeInformation
)
where
import Data.Kind ( Type )
import Prelude
import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
import Rel8.Type.Name (TypeName)
import Rel8.Type.Decoder (Decoder, parseDecoder)
type TypeInformation :: Type -> Type
data TypeInformation a = TypeInformation
{ forall a. TypeInformation a -> a -> PrimExpr
encode :: a -> Opaleye.PrimExpr
, forall a. TypeInformation a -> Decoder a
decode :: Decoder a
, forall a. TypeInformation a -> TypeName
typeName :: TypeName
}
mapTypeInformation :: ()
=> (a -> b) -> (b -> a)
-> TypeInformation a -> TypeInformation b
mapTypeInformation :: forall a b.
(a -> b) -> (b -> a) -> TypeInformation a -> TypeInformation b
mapTypeInformation = (a -> Either String b)
-> (b -> a) -> TypeInformation a -> TypeInformation b
forall a b.
(a -> Either String b)
-> (b -> a) -> TypeInformation a -> TypeInformation b
parseTypeInformation ((a -> Either String b)
-> (b -> a) -> TypeInformation a -> TypeInformation b)
-> ((a -> b) -> a -> Either String b)
-> (a -> b)
-> (b -> a)
-> TypeInformation a
-> TypeInformation b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> Either String b) -> (a -> b) -> a -> Either String b
forall a b. (a -> b) -> (a -> a) -> a -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> Either String b
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
parseTypeInformation :: ()
=> (a -> Either String b) -> (b -> a)
-> TypeInformation a -> TypeInformation b
parseTypeInformation :: forall a b.
(a -> Either String b)
-> (b -> a) -> TypeInformation a -> TypeInformation b
parseTypeInformation a -> Either String b
to b -> a
from TypeInformation {a -> PrimExpr
encode :: forall a. TypeInformation a -> a -> PrimExpr
encode :: a -> PrimExpr
encode, Decoder a
decode :: forall a. TypeInformation a -> Decoder a
decode :: Decoder a
decode, TypeName
typeName :: forall a. TypeInformation a -> TypeName
typeName :: TypeName
typeName} =
TypeInformation
{ encode :: b -> PrimExpr
encode = a -> PrimExpr
encode (a -> PrimExpr) -> (b -> a) -> b -> PrimExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
from
, decode :: Decoder b
decode = (a -> Either String b) -> Decoder a -> Decoder b
forall a b. (a -> Either String b) -> Decoder a -> Decoder b
parseDecoder a -> Either String b
to Decoder a
decode
, TypeName
typeName :: TypeName
typeName :: TypeName
typeName
}