| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Data.TypedEncoding.Conv.ByteString.Char8
Description
Encoding safe version of Data.ByteString.Char8 @since 0.2.2.0
Synopsis
- pack :: (LLast xs ~ t, IsSuperset "r-ASCII" t ~ True) => Enc xs c String -> Enc xs c ByteString
- unpack :: (LLast xs ~ t, IsSuperset "r-ASCII" t ~ True) => Enc xs c ByteString -> Enc xs c String
Documentation
>>>:set -XDataKinds -XTypeApplications -XOverloadedStrings
pack :: (LLast xs ~ t, IsSuperset "r-ASCII" t ~ True) => Enc xs c String -> Enc xs c ByteString Source #
Type safer version of pack.
This assumes that each of the encodings in xs work work equivalently in String and ByteString.
Because of how ByteString.Char8.pack works, the first encoding (last in the list) must restrict character set to a subset of ASCII.
>>>:t pack (undefined :: Enc '["r-bar", "r-foo"] () String)... ... error: ... Couldn't match type ... ... "r-ASCII" "r-foo" ... ...
>>>displ $ pack (unsafeSetPayload () "Hello" :: Enc '["r-bar", "r-ASCII"] () String)"MkEnc '[r-bar,r-ASCII] () (ByteString Hello)"