{-# language GADTs #-}
{-# language NamedFieldPuns #-}
{-# language StandaloneKindSignatures #-}
{-# language StrictData #-}
module Rel8.Type.Information (
TypeInformation(..),
mapTypeInformation,
parseTypeInformation,
) where
import Data.Functor.Contravariant ((>$<))
import Data.Kind (Type)
import Prelude
import Rel8.Type.Decoder (Decoder, parseDecoder)
import Rel8.Type.Encoder (Encoder)
import Rel8.Type.Name (TypeName)
type TypeInformation :: Type -> Type
data TypeInformation a = TypeInformation
{ forall a. TypeInformation a -> Encoder a
encode :: Encoder a
, forall a. TypeInformation a -> Decoder a
decode :: Decoder a
, forall a. TypeInformation a -> Char
delimiter :: Char
, 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 {Encoder a
encode :: forall a. TypeInformation a -> Encoder a
encode :: Encoder a
encode, Decoder a
decode :: forall a. TypeInformation a -> Decoder a
decode :: Decoder a
decode, Char
delimiter :: forall a. TypeInformation a -> Char
delimiter :: Char
delimiter, TypeName
typeName :: forall a. TypeInformation a -> TypeName
typeName :: TypeName
typeName} =
TypeInformation
{ 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
, encode :: Encoder b
encode = b -> a
from (b -> a) -> Encoder a -> Encoder b
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
>$< Encoder a
encode
, Char
delimiter :: Char
delimiter :: Char
delimiter
, TypeName
typeName :: TypeName
typeName :: TypeName
typeName
}