typed-encoding-encoding-0.1.0.0: Bridge between encoding and typed-encoding packages

Safe HaskellNone
LanguageHaskell2010

Data.TypedEncoding.Pkg.Encoding.Instances

Contents

Description

Key instances defined here are ToEncString and FromEncString. These allow to create encoded ByteString from a String (ToEncString) and decode ByteString back (ToEncString).

The String Encode, Decode instances is less interesting since is works with String type only.

See the warnings section of Data.TypedEncoding.Pkg.Encoding.Conv

Synopsis

    Documentation

    >>> :set -XOverloadedStrings -XDataKinds -XTypeApplications -XFlexibleContexts
    >>> import           Data.Functor.Identity
    >>> import qualified Data.TypedEncoding as Usage
    

    Orphan instances

    DynEnc s => EncodingSuperset s Source #

    All encoding encodings map characters to bytes This defines EncSuperset s as "r-CHAR8"

    Instance details

    Associated Types

    type EncSuperset s :: Symbol #

    Methods

    implEncInto :: Enc (s ': xs) c str -> Enc (EncSuperset s ': (s ': xs)) c str #

    (UnexpectedDecodeErr f, Monad f, DynEnc s, Algorithm s "enc-pkg/encoding") => Decode f s "enc-pkg/encoding" c String Source # 
    Instance details

    Methods

    decoding :: Decoding f s "enc-pkg/encoding" c String #

    (DynEnc s, Algorithm s "enc-pkg/encoding") => ToEncString (Either EncodeEx) s "enc-pkg/encoding" String ByteString Source # 
    Instance details

    Methods

    toEncF :: String -> Either EncodeEx (Enc (s ': []) () ByteString) #

    (DynEnc s, Algorithm s "enc-pkg/encoding") => ToEncString (Either EncodeEx) s "enc-pkg/encoding" String ByteString Source #
    >>> :{
    Usage.displ 
     <$> Usage.toEncStringF' 
      @"enc-pkg/encoding" 
      @"enc-pkg/encoding:cyrillic" 
      @(Either Usage.EncodeEx) 
      @String 
      @B.ByteString "Статья"
    :}
    Right "Enc '[enc-pkg/encoding:cyrillic] () (ByteString \193\226\208\226\236\239)"
    
    Instance details

    Methods

    toEncF :: String -> Either EncodeEx (Enc (s ': []) () ByteString) #

    (DynEnc s, Algorithm s "enc-pkg/encoding") => Encode (Either EncodeEx) s "enc-pkg/encoding" c String Source # 
    Instance details

    Methods

    encoding :: Encoding (Either EncodeEx) s "enc-pkg/encoding" c String #

    (UnexpectedDecodeErr f, Monad f, DynEnc s, Algorithm s "enc-pkg/encoding") => FromEncString (f :: Type -> Type) s "enc-pkg/encoding" String ByteString Source # 
    Instance details

    Methods

    fromEncF :: Enc (s ': []) () ByteString -> f String #

    (UnexpectedDecodeErr f, Monad f, DynEnc s, Algorithm s "enc-pkg/encoding") => FromEncString (f :: Type -> Type) s "enc-pkg/encoding" String ByteString Source #
    >>> :{
    Usage.displ <$> 
     Usage.fromEncStringF' 
      @"enc-pkg/encoding" 
      @"enc-pkg/encoding:cyrillic" 
      @(Either Usage.UnexpectedDecodeEx) 
      @String @B.ByteString 
       (Typed.unsafeSetPayload () "\193\226\208\226\236\239")
    :}
    Right "(String \1057\1090\1072\1090\1100\1103)"
    
    Instance details

    Methods

    fromEncF :: Enc (s ': []) () ByteString -> f String #