Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Type classes accompanying decoding types defined in Data.TypedEncoding.Common.Types.Enc
Examples.TypedEncoding.Instances.DiySignEncoding contains an implementation example.
Examples.TypedEncoding.Overview shows decoding usage examples.
This module is re-exported in Data.TypedEncoding and it is best not to import it directly.
Documentation
>>>
:set -XOverloadedStrings -XMultiParamTypeClasses -XDataKinds -XAllowAmbiguousTypes
>>>
import qualified Data.ByteString as B
>>>
import Data.Functor.Identity
>>>
import Data.TypedEncoding
>>>
import Data.TypedEncoding.Instances.Enc.Base64 ()
class Encode f nm alg conf str where Source #
Allows for polymorphic access to encoding, for example
>>>
displ (runIdentity . _runEncoding encoding $ toEncoding () "Hello" :: Enc '["enc-B64"] () B.ByteString)
"Enc '[enc-B64] () (ByteString SGVsbG8=)"
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
Instances
Applicative f => Encode f "enc-B64" "enc-B64" c Text Source # | This instance will likely be removed in future versions (performance concerns) (Moved from Data.TypedEncoding.Instances.Enc.Base64) |
Applicative f => Encode f "enc-B64" "enc-B64" c ByteString Source # | Since: 0.3.0.0 |
Defined in Data.TypedEncoding.Instances.Enc.Base64 encoding :: Encoding f "enc-B64" "enc-B64" c ByteString Source # | |
Applicative f => Encode f "enc-B64" "enc-B64" c ByteString Source # | Since: 0.3.0.0 |
Defined in Data.TypedEncoding.Instances.Enc.Base64 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 This is done using |
(HasA SizeLimit c, Applicative f) => Encode f "do-size-limit" "do-size-limit" c ByteString Source # | |
Defined in Examples.TypedEncoding.Instances.Do.Sample 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 # | Since: 0.3.0.0 |
Applicative f => Encode f "do-reverse" "do-reverse" c Text Source # | |
Applicative f => Encode f "do-reverse" "do-reverse" c Text Source # | Since: 0.3.0.0 |
Applicative f => Encode f "do-Title" "do-Title" c Text Source # | |
Applicative f => Encode f "do-Title" "do-Title" c Text Source # | Since: 0.3.0.0 |
Applicative f => Encode f "do-lower" "do-lower" c Text Source # | |
Applicative f => Encode f "do-lower" "do-lower" c Text Source # | Since: 0.3.0.0 |
Applicative f => Encode f "do-UPPER" "do-UPPER" c Text Source # | |
Applicative f => Encode f "do-UPPER" "do-UPPER" c Text Source # | Since: 0.3.0.0 |
(Ban s, Algorithm s "r-ban", IsStringR str) => Encode (Either EncodeEx) s "r-ban" c str Source # | |
Char8Find str => Encode (Either EncodeEx) "r-ASCII" "r-ASCII" c str Source # | |
Encode (Either EncodeEx) "r-ASCII" "r-ASCII" c Char Source # | |
Encode (Either EncodeEx) "r-B64" "r-B64" c String Source # | |
Encode (Either EncodeEx) "r-B64" "r-B64" c Text Source # | |
Encode (Either EncodeEx) "r-B64" "r-B64" c Text Source # | |
Encode (Either EncodeEx) "r-B64" "r-B64" c ByteString Source # | |
Encode (Either EncodeEx) "r-B64" "r-B64" c ByteString Source # | |
Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c String Source # | |
Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c ByteString Source # | |
Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c ByteString Source # | |
Encode (Either EncodeEx) "r-ByteRep" "r-ByteRep" c Char Source # | |
IsStringR str => Encode (Either EncodeEx) "r-Int-decimal" "r-Int-decimal" c str Source # | |
Encode (Either EncodeEx) "r-UNICODE.D76" "r-UNICODE.D76" c String Source # | |
Encode (Either EncodeEx) "r-UNICODE.D76" "r-UNICODE.D76" c Char Source # | |
Encode (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
Following test uses
|
IsStringR str => Encode (Either EncodeEx) "r-Word8-decimal" "r-Word8-decimal" c str Source # | |
class EncodeAll f nms algs conf str where Source #
Allows for polymorphic access to Encodings
For example
>>>
displ (runIdentity . _runEncodings encodings $ toEncoding () "Hello" :: (Enc '["enc-B64", "enc-B64"] () B.ByteString))
"Enc '[enc-B64,enc-B64] () (ByteString U0dWc2JHOD0=)"
You can also use convenience functions like encodeAll
Since: 0.3.0.0