data-textual-0.3.0.2: Human-friendly textual representations.

Safe HaskellNone

Data.Textual

Contents

Description

Working with human-friendly (as opposed to the compiler-friendly Show and Read) textual representations.

Synopsis

Printing

maybePrint :: (Printer p, Printable α) => Maybe α -> pSource

A shorthand for maybe mempty print.

toString :: Printable α => α -> StringSource

A shorthand for buildString . print.

toText :: Printable α => α -> TextSource

A shorthand for buildText . print.

toLazyText :: Printable α => α -> TextSource

A shorthand for buildLazyText . print.

toAscii :: Printable α => α -> ByteStringSource

A shorthand for buildAscii . print.

toLazyAscii :: Printable α => α -> ByteStringSource

A shorthand for buildLazyAscii . print.

toUtf8 :: Printable α => α -> ByteStringSource

A shorthand for buildUtf8 . print.

toLazyUtf8 :: Printable α => α -> ByteStringSource

A shorthand for buildLazyUtf8 . print.

Parsing

class Printable α => Textual α whereSource

The default parser for values of a type, must satisfy fromString (toString x) = Just x

Methods

textual :: (Monad μ, CharParsing μ) => μ αSource

Built-in parser

data Parsed α Source

Parsing result.

Constructors

Parsed α 
Malformed [String] String 

maybeParsed :: Parsed α -> Maybe αSource

Map Parsed values to Just and Malformed to Nothing.

builtInParser :: (forall μ. (Monad μ, CharParsing μ) => μ α) -> String -> Parsed αSource

Use the built-in parser to parse a string. Intended for testing only.

parseString :: Textual α => String -> Parsed αSource

Parse a String to extract the Textual value.

parseStringAs :: Textual α => p α -> String -> Parsed αSource

Provide a hint for the type system when using parseString.

parseText :: Textual α => Text -> Parsed αSource

Parse a Text to extract the Textual value.

parseTextAs :: Textual α => p α -> Text -> Parsed αSource

Provide a hint for the type system when using parseText.

parseLazyText :: Textual α => Text -> Parsed αSource

Parse a lazy Text to extract the Textual value.

parseLazyTextAs :: Textual α => p α -> Text -> Parsed αSource

Provide a hint for the type system when using parseLazyText.

parseAscii :: Textual α => ByteString -> Parsed αSource

Decode and parse an ASCII ByteString to extract the Textual value.

parseAsciiAs :: Textual α => p α -> ByteString -> Parsed αSource

Provide a hint for the type system when using parseAscii.

parseLazyAscii :: Textual α => ByteString -> Parsed αSource

Decode and parse a lazy ASCII ByteString to extract the Textual value.

parseLazyAsciiAs :: Textual α => ByteString -> Parsed αSource

Provide a hint for the type system when using parseLazyAscii.

parseUtf8 :: Textual α => ByteString -> Parsed αSource

Decode and parse a UTF-8 ByteString to extract the Textual value.

parseUtf8As :: Textual α => p α -> ByteString -> Parsed αSource

Provide a hint for the type system when using parseUtf8.

parseLazyUtf8 :: Textual α => ByteString -> Parsed αSource

Decode and parse a lazy UTF-8 ByteString to extract the Textual value.

parseLazyUtf8As :: Textual α => p α -> ByteString -> Parsed αSource

Provide a hint for the type system when using parseLazyUtf8.

fromString :: Textual α => String -> Maybe αSource

A shorthand for maybeParsed . parseString

fromStringAs :: Textual α => p α -> String -> Maybe αSource

Provide a hint for the type system when using fromString.

fromText :: Textual α => Text -> Maybe αSource

A shorthand for maybeParsed . parseText

fromTextAs :: Textual α => p α -> Text -> Maybe αSource

Provide a hint for the type system when using fromText.

fromLazyTextAs :: Textual α => p α -> Text -> Maybe αSource

Provide a hint for the type system when using fromLazyText.

fromAsciiAs :: Textual α => p α -> ByteString -> Maybe αSource

Provide a hint for the type system when using fromAscii.

fromLazyAsciiAs :: Textual α => p α -> ByteString -> Maybe αSource

Provide a hint for the type system when using fromLazyAscii.

fromUtf8 :: Textual α => ByteString -> Maybe αSource

A shorthand for maybeParsed . parseUtf8

fromUtf8As :: Textual α => p α -> ByteString -> Maybe αSource

Provide a hint for the type system when using fromUtf8.

fromLazyUtf8As :: Textual α => p α -> ByteString -> Maybe αSource

Provide a hint for the type system when using fromLazyUtf8.