typed-encoding-0.2.1.0: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Data.TypedEncoding.Internal.Types

Contents

Description

Internal definition of types

Synopsis

Documentation

data UnexpectedDecodeEx where Source #

Type safety over encodings makes decoding process safe. However failures are still possible due to bugs or unsafe payload modifications. UnexpectedDecodeEx represents such errors.

Constructors

UnexpectedDecodeEx :: (Show a, KnownSymbol x) => Proxy x -> a -> UnexpectedDecodeEx 

data EncodeEx where Source #

Represents errors in encoding

Constructors

EncodeEx :: (Show a, KnownSymbol x) => Proxy x -> a -> EncodeEx 
Instances
Show EncodeEx Source # 
Instance details

Defined in Data.TypedEncoding.Internal.Types

EncodeF (Either EncodeEx) (Enc xs c ByteString) (Enc ("r-UTF8" ': xs) c ByteString :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.UTF8

Methods

encodeF :: Enc xs c ByteString -> Either EncodeEx (Enc ("r-UTF8" ': xs) c ByteString) Source #

EncodeF (Either EncodeEx) (Enc xs c ByteString) (Enc ("r-UTF8" ': xs) c ByteString :: Type) Source #

UTF8 encodings are defined for ByteString only as that would not make much sense for Text

>>> encodeFAll . toEncoding () $ "\xc3\xb1" :: Either EncodeEx (Enc '["r-UTF8"] () B.ByteString)
Right (MkEnc Proxy () "\195\177")
>>> encodeFAll . toEncoding () $ "\xc3\x28" :: Either EncodeEx (Enc '["r-UTF8"] () B.ByteString)
Left (EncodeEx "r-UTF8" (Cannot decode byte '\xc3': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream))

Following test uses verEncoding helper that checks that bytes are encoded as Right iff they are valid UTF8 bytes

\(b :: B.ByteString) -> verEncoding b (fmap (fromEncoding . decodeAll . proxiedId (Proxy :: Proxy (Enc '["r-UTF8"] _ _))) . (encodeFAll :: _ -> Either EncodeEx _). toEncoding () $ b)
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.UTF8

Methods

encodeF :: Enc xs c ByteString -> Either EncodeEx (Enc ("r-UTF8" ': xs) c ByteString) Source #

IsStringR str => EncodeF (Either EncodeEx) (Enc xs c str) (Enc ("r-Int-decimal" ': xs) c str :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Common

Methods

encodeF :: Enc xs c str -> Either EncodeEx (Enc ("r-Int-decimal" ': xs) c str) Source #

IsStringR str => EncodeF (Either EncodeEx) (Enc xs c str) (Enc ("r-Word8-decimal" ': xs) c str :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Common

Methods

encodeF :: Enc xs c str -> Either EncodeEx (Enc ("r-Word8-decimal" ': xs) c str) Source #

EncodeF (Either EncodeEx) (Enc xs c ByteString) (Enc ("r-ASCII" ': xs) c ByteString :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ASCII

Methods

encodeF :: Enc xs c ByteString -> Either EncodeEx (Enc ("r-ASCII" ': xs) c ByteString) Source #

EncodeF (Either EncodeEx) (Enc xs c ByteString) (Enc ("r-ASCII" ': xs) c ByteString :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ASCII

Methods

encodeF :: Enc xs c ByteString -> Either EncodeEx (Enc ("r-ASCII" ': xs) c ByteString) Source #

EncodeF (Either EncodeEx) (Enc xs c Text) (Enc ("r-ASCII" ': xs) c Text :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ASCII

Methods

encodeF :: Enc xs c Text -> Either EncodeEx (Enc ("r-ASCII" ': xs) c Text) Source #

EncodeF (Either EncodeEx) (Enc xs c Text) (Enc ("r-ASCII" ': xs) c Text :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ASCII

Methods

encodeF :: Enc xs c Text -> Either EncodeEx (Enc ("r-ASCII" ': xs) c Text) Source #

EncodeF (Either EncodeEx) (Enc xs c Char) (Enc ("r-ASCII" ': xs) c Char :: Type) Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ASCII

Methods

encodeF :: Enc xs c Char -> Either EncodeEx (Enc ("r-ASCII" ': xs) c Char) Source #

data RecreateEx where Source #

Represents errors in recovery (recreation of encoded types).

Constructors

RecreateEx :: (Show e, KnownSymbol x) => Proxy x -> e -> RecreateEx 
RecreateExUnkStep :: Show e => e -> RecreateEx 

encToRecrEx :: EncodeEx -> RecreateEx Source #

usefull when manually recreating using recovery

implEncodeF_ :: (Show err, KnownSymbol x) => Proxy x -> (str -> Either err str) -> Enc enc1 conf str -> Either EncodeEx (Enc enc2 conf str) Source #

implEncodeF :: forall x enc1 enc2 err conf str. (Show err, KnownSymbol x) => (str -> Either err str) -> Enc enc1 conf str -> Either EncodeEx (Enc enc2 conf str) Source #

implEncodeF_' :: (Show err, KnownSymbol x) => Proxy x -> (conf -> str -> Either err str) -> Enc enc1 conf str -> Either EncodeEx (Enc enc2 conf str) Source #

mergeErrs :: err -> (err -> Maybe err -> err) -> Either err a -> Either err b -> Either err c Source #

Main encoding type and basic combinators.

Untyped version and existentially quantified versions of Enc

Not verified encoded data

Commmon types