typed-encoding-0.3.0.0: Type safe string transformations

Safe HaskellSafe
LanguageHaskell2010

Data.TypedEncoding.Common.Class.Encode

Synopsis

Documentation

class Encode f nm alg conf str where Source #

Using 2 Symbol type variables (nm and alg) creates what seems like redundant typing in statically defined instances such as "r-ASCII", however it provides future flexibility to constrain nm in some interesting way, different than AlgNm nm ~ alg.

It also seems to be easier to understand as type variables used in the definition of Encoding match with what is on the typeclass.

alg is expected to be very statically defined and is needed to support more open instances such as "r-ban".

Since: 0.3.0.0

Methods

encoding :: Encoding f nm alg conf str Source #

Instances
(HasA SizeLimit c, Applicative f) => Encode f "do-size-limit" "do-size-limit" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-size-limit" "do-size-limit" c ByteString Source #

(HasA SizeLimit c, Applicative f) => Encode f "do-size-limit" "do-size-limit" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-size-limit" "do-size-limit" c Text Source #

Applicative f => Encode f "do-reverse" "do-reverse" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-reverse" "do-reverse" c Text Source #

Applicative f => Encode f "do-reverse" "do-reverse" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-reverse" "do-reverse" c Text Source #

Applicative f => Encode f "do-Title" "do-Title" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-Title" "do-Title" c Text Source #

Applicative f => Encode f "do-Title" "do-Title" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-Title" "do-Title" c Text Source #

Applicative f => Encode f "do-lower" "do-lower" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-lower" "do-lower" c Text Source #

Applicative f => Encode f "do-lower" "do-lower" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-lower" "do-lower" c Text Source #

Applicative f => Encode f "do-UPPER" "do-UPPER" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-UPPER" "do-UPPER" c Text Source #

Applicative f => Encode f "do-UPPER" "do-UPPER" c Text Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Do.Sample

Methods

encoding :: Encoding f "do-UPPER" "do-UPPER" c Text Source #

Applicative f => Encode f "enc-B64" "enc-B64" c Text Source #

This instance will likely be removed in future versions (performance concerns)

Instance details

Defined in Data.TypedEncoding.Instances.Enc.Base64

Methods

encoding :: Encoding f "enc-B64" "enc-B64" c Text Source #

Applicative f => Encode f "enc-B64" "enc-B64" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Enc.Base64

Methods

encoding :: Encoding f "enc-B64" "enc-B64" c ByteString Source #

Applicative f => Encode f "enc-B64" "enc-B64" c ByteString Source # 
Instance details

Defined in Data.TypedEncoding.Instances.Enc.Base64

Methods

encoding :: Encoding f "enc-B64" "enc-B64" c ByteString Source #

Applicative f => Encode f "my-sign" "my-sign" c Text Source #

Because encoding function is pure we can create instance of EncodeF that is polymorphic in effect f. This is done using implTranP combinator.

Instance details

Defined in Examples.TypedEncoding.DiySignEncoding

Methods

encoding :: Encoding f "my-sign" "my-sign" c Text Source #

(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 #

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-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

>>> encodeFAll . toEncoding () $ "\xc3\xb1" :: Either EncodeEx (Enc '["r-UTF8"] () B.ByteString)
Right (UnsafeMkEnc 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

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 #

class EncodeAll f nms algs conf str where Source #

Since: 0.3.0.0

Methods

encodings :: Encodings f nms algs conf str Source #

Instances
EncodeAll f ([] :: [Symbol]) ([] :: [Symbol]) conf str Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Encode

Methods

encodings :: Encodings f [] [] conf str Source #

(EncodeAll f nms algs conf str, Encode f nm alg conf str) => EncodeAll f (nm ': nms) (alg ': algs) conf str Source # 
Instance details

Defined in Data.TypedEncoding.Common.Class.Encode

Methods

encodings :: Encodings f (nm ': nms) (alg ': algs) conf str Source #