| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
String
Description
Type classes for convertion between different string representations.
- module Data.String
- module Text.Read
- module Data.Text
- module Data.Text.Lazy
- module Data.Text.Encoding
- module Data.Text.Encoding.Error
- module Data.ByteString
- class ConvertUtf8 a b where
- class ToString a where
- class ToLText a where
- class ToText a where
- class Buildable p
- readEither :: (ToString a, Read b) => a -> Either Text b
- show :: forall b a. (Show a, IsString b) => a -> b
- pretty :: Buildable a => a -> Text
- prettyL :: Buildable a => a -> LText
- type LText = Text
- type LByteString = ByteString
Documentation
module Data.String
Text
module Text.Read
module Data.Text
module Data.Text.Lazy
module Data.Text.Encoding
module Data.Text.Encoding.Error
module Data.ByteString
class ConvertUtf8 a b where Source #
Type class for conversion to utf8 representation of text.
Minimal complete definition
Methods
encodeUtf8 :: a -> b Source #
Encode as utf8 string (usually ByteString).
>>>encodeUtf8 @Text @ByteString "патак""\208\191\208\176\209\130\208\176\208\186"
decodeUtf8 :: b -> a Source #
Decode from utf8 string.
>>>decodeUtf8 @Text @ByteString "\208\191\208\176\209\130\208\176\208\186""\1087\1072\1090\1072\1082">>>putStrLn $ decodeUtf8 @Text @ByteString "\208\191\208\176\209\130\208\176\208\186"патак
decodeUtf8Strict :: b -> Either UnicodeException a Source #
Decode as utf8 string but returning execption if byte sequence is malformed.
>>>decodeUtf8 @Text @ByteString "\208\208\176\209\130\208\176\208\186""\65533\65533\1090\1072\1082">>>decodeUtf8Strict @Text @ByteString "\208\208\176\209\130\208\176\208\186"Left Cannot decode byte '\xd0': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream
class ToString a where Source #
Type class for converting other strings to String.
Minimal complete definition
class ToLText a where Source #
Type class for converting other strings to Text.
Minimal complete definition
Type class for converting other strings to Text.
Minimal complete definition
Buildable class
The class of types that can be rendered to a Builder.
Minimal complete definition
Instances
Show and read functions
readEither :: (ToString a, Read b) => a -> Either Text b Source #
Polymorhpic version of readEither.
>>>readEither @Text @Int "123"Right 123>>>readEither @Text @Int "aa"Left "Prelude.read: no parse"
pretty :: Buildable a => a -> Text Source #
Functions to show pretty output for buildable data types.
Convenient type aliases
type LByteString = ByteString Source #
Type synonym for ByteString.