typed-encoding-0.5.2.1: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Data.TypedEncoding.Common.Types.Exceptions

Contents

Description

Exception types used in typed-encoding

This module is re-exported in Data.TypedEncoding and it is best not to import it directly.

Synopsis

Documentation

>>> :set -XOverloadedStrings -XMultiParamTypeClasses -XDataKinds -XAllowAmbiguousTypes
>>> import qualified Data.Text as T

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 
Instances
Show RecreateEx Source # 
Instance details

Defined in Data.TypedEncoding.Common.Types.Exceptions

IsStringR str => Validate (Either RecreateEx) "r-Int-decimal" "r-Int-decimal" c str Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Misc

Methods

validation :: Validation (Either RecreateEx) "r-Int-decimal" "r-Int-decimal" c str Source #

IsStringR str => Validate (Either RecreateEx) "r-Word8-decimal" "r-Word8-decimal" c str Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Misc

Methods

validation :: Validation (Either RecreateEx) "r-Word8-decimal" "r-Word8-decimal" c str Source #

RecreateErr (Either RecreateEx) Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Validate

data EncodeEx where Source #

Represents errors in encoding @since 0.1.0.0

Constructors

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

Defined in Data.TypedEncoding.Common.Types.Exceptions

(Ban s, Algorithm s "r-ban", IsStringR str) => Encode (Either EncodeEx) s "r-ban" c str Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.BoundedAlphaNums

Methods

encoding :: Encoding (Either EncodeEx) s "r-ban" c str Source #

Char8Find str => Encode (Either EncodeEx) "r-ASCII" "r-ASCII" c str Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ASCII

Methods

encoding :: Encoding (Either EncodeEx) "r-ASCII" "r-ASCII" c str Source #

Encode (Either EncodeEx) "r-ASCII" "r-ASCII" c Char Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ASCII

Methods

encoding :: Encoding (Either EncodeEx) "r-ASCII" "r-ASCII" c Char Source #

Encode (Either EncodeEx) "r-B64" "r-B64" c String Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Base64

Methods

encoding :: Encoding (Either EncodeEx) "r-B64" "r-B64" c String Source #

Encode (Either EncodeEx) "r-B64" "r-B64" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Base64

Methods

encoding :: Encoding (Either EncodeEx) "r-B64" "r-B64" c Text Source #

Encode (Either EncodeEx) "r-B64" "r-B64" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Base64

Methods

encoding :: Encoding (Either EncodeEx) "r-B64" "r-B64" c Text Source #

Encode (Either EncodeEx) "r-B64" "r-B64" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Base64

Methods

encoding :: Encoding (Either EncodeEx) "r-B64" "r-B64" c ByteString Source #

Encode (Either EncodeEx) "r-B64" "r-B64" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Base64

Methods

encoding :: Encoding (Either EncodeEx) "r-B64" "r-B64" c ByteString Source #

Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c String Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ByteRep

Methods

encoding :: Encoding (Either EncodeEx) "r-ByteRep" "r-ByteRep" c String Source #

Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ByteRep

Methods

encoding :: Encoding (Either EncodeEx) "r-ByteRep" "r-ByteRep" c ByteString Source #

Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ByteRep

Methods

encoding :: Encoding (Either EncodeEx) "r-ByteRep" "r-ByteRep" c ByteString Source #

Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c Char Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.ByteRep

Methods

encoding :: Encoding (Either EncodeEx) "r-ByteRep" "r-ByteRep" c Char Source #

IsStringR str => Encode (Either EncodeEx) "r-Int-decimal" "r-Int-decimal" c str Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Misc

Methods

encoding :: Encoding (Either EncodeEx) "r-Int-decimal" "r-Int-decimal" c str Source #

Encode (Either EncodeEx) "r-UNICODE.D76" "r-UNICODE.D76" c String Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.D76

Methods

encoding :: Encoding (Either EncodeEx) "r-UNICODE.D76" "r-UNICODE.D76" c String Source #

Encode (Either EncodeEx) "r-UNICODE.D76" "r-UNICODE.D76" c Char Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.D76

Methods

encoding :: Encoding (Either EncodeEx) "r-UNICODE.D76" "r-UNICODE.D76" c Char Source #

Encode (Either EncodeEx) "r-UTF8" "r-UTF8" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.UTF8

Methods

encoding :: Encoding (Either EncodeEx) "r-UTF8" "r-UTF8" c ByteString Source #

Encode (Either EncodeEx) "r-UTF8" "r-UTF8" c ByteString Source #

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

>>> _runEncodings encodings . toEncoding () $ "\xc3\xb1" :: Either EncodeEx (Enc '["r-UTF8"] () B.ByteString)
Right (UnsafeMkEnc Proxy () "\195\177")
>>> _runEncodings encodings . toEncoding () $ "\xc3\x28" :: Either EncodeEx (Enc '["r-UTF8"] () B.ByteString)
Left (EncodeEx "r-UTF8" (Cannot decode byte '\xc3': ...

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

>>> :{
quickCheck $ \(b :: B.ByteString) -> verEncoding b $ fmap (
         fromEncoding 
         . decodeAll @'["r-UTF8"]
         ) . encodeFAll @'["r-UTF8"] @(Either EncodeEx)
         . toEncoding () $ b
:}
+++ OK, passed 100 tests.
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.UTF8

Methods

encoding :: Encoding (Either EncodeEx) "r-UTF8" "r-UTF8" c ByteString Source #

IsStringR str => Encode (Either EncodeEx) "r-Word8-decimal" "r-Word8-decimal" c str Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Restriction.Misc

Methods

encoding :: Encoding (Either EncodeEx) "r-Word8-decimal" "r-Word8-decimal" c str Source #

asEncodeEx :: (Show a, KnownSymbol x) => Proxy x -> Either a b -> Either EncodeEx b Source #

Since: 0.2.2.0

encToRecrEx :: EncodeEx -> RecreateEx Source #

Useful when manually recreating using recovery @since 0.2.2.0

emptyEncErr :: KnownSymbol x => Proxy x -> EncodeEx Source #

Since: 0.2.1.0

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.

Since: 0.1.0.0

Constructors

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

Base combinators that rely on types defined here

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

Since: 0.2.1.0