data-textual-0.3.0.3: Human-friendly textual representations.
Safe HaskellNone
LanguageHaskell2010

Data.Textual

Description

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

Synopsis

Printing

class Printable α where Source #

The default printer for values of a type.

Methods

print :: Printer p => α -> p Source #

Instances

Instances details
Printable Char Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Char -> p Source #

Printable Double Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Double -> p Source #

Printable Float Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Float -> p Source #

Printable Int Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Int -> p Source #

Printable Int8 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Int8 -> p Source #

Printable Int16 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Int16 -> p Source #

Printable Int32 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Int32 -> p Source #

Printable Int64 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Int64 -> p Source #

Printable Integer Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Integer -> p Source #

Printable Word Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Word -> p Source #

Printable Word8 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Word8 -> p Source #

Printable Word16 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Word16 -> p Source #

Printable Word32 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Word32 -> p Source #

Printable Word64 Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Word64 -> p Source #

Printable String Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => String -> p Source #

Printable Text Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Text -> p Source #

Printable Text Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Text -> p Source #

Integral α => Printable (Ratio α) Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Ratio α -> p Source #

HasResolution α => Printable (Fixed α) Source # 
Instance details

Defined in Data.Textual

Methods

print :: Printer p => Fixed α -> p Source #

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

A shorthand for maybe mempty print.

toString :: Printable α => α -> String Source #

A shorthand for buildString . print.

toText :: Printable α => α -> Text Source #

A shorthand for buildText . print.

toLazyText :: Printable α => α -> Text Source #

A shorthand for buildLazyText . print.

toAscii :: Printable α => α -> ByteString Source #

A shorthand for buildAscii . print.

toLazyAscii :: Printable α => α -> ByteString Source #

A shorthand for buildLazyAscii . print.

toUtf8 :: Printable α => α -> ByteString Source #

A shorthand for buildUtf8 . print.

toLazyUtf8 :: Printable α => α -> ByteString Source #

A shorthand for buildLazyUtf8 . print.

Parsing

class Printable α => Textual α where Source #

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

Methods

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

Instances

Instances details
Textual Char Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Char Source #

Textual Int Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Int Source #

Textual Int8 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Int8 Source #

Textual Int16 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Int16 Source #

Textual Int32 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Int32 Source #

Textual Int64 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Int64 Source #

Textual Integer Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Integer Source #

Textual Word Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Word Source #

Textual Word8 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Word8 Source #

Textual Word16 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Word16 Source #

Textual Word32 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Word32 Source #

Textual Word64 Source # 
Instance details

Defined in Data.Textual

Methods

textual :: (Monad μ, CharParsing μ) => μ Word64 Source #

Integral α => Textual (Ratio α) Source # 
Instance details

Defined in Data.Textual

Methods

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

HasResolution α => Textual (Fixed α) Source # 
Instance details

Defined in Data.Textual

Methods

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

Built-in parser

data Parsed α Source #

Parsing result.

Constructors

Parsed α 
Malformed [String] String 

Instances

Instances details
Functor Parsed Source # 
Instance details

Defined in Data.Textual

Methods

fmap :: (a -> b) -> Parsed a -> Parsed b

(<$) :: a -> Parsed b -> Parsed a

Applicative Parsed Source # 
Instance details

Defined in Data.Textual

Methods

pure :: a -> Parsed a

(<*>) :: Parsed (a -> b) -> Parsed a -> Parsed b

liftA2 :: (a -> b -> c) -> Parsed a -> Parsed b -> Parsed c

(*>) :: Parsed a -> Parsed b -> Parsed b

(<*) :: Parsed a -> Parsed b -> Parsed a

Foldable Parsed Source # 
Instance details

Defined in Data.Textual

Methods

fold :: Monoid m => Parsed m -> m

foldMap :: Monoid m => (a -> m) -> Parsed a -> m

foldMap' :: Monoid m => (a -> m) -> Parsed a -> m

foldr :: (a -> b -> b) -> b -> Parsed a -> b

foldr' :: (a -> b -> b) -> b -> Parsed a -> b

foldl :: (b -> a -> b) -> b -> Parsed a -> b

foldl' :: (b -> a -> b) -> b -> Parsed a -> b

foldr1 :: (a -> a -> a) -> Parsed a -> a

foldl1 :: (a -> a -> a) -> Parsed a -> a

toList :: Parsed a -> [a]

null :: Parsed a -> Bool

length :: Parsed a -> Int

elem :: Eq a => a -> Parsed a -> Bool

maximum :: Ord a => Parsed a -> a

minimum :: Ord a => Parsed a -> a

sum :: Num a => Parsed a -> a

product :: Num a => Parsed a -> a

Traversable Parsed Source # 
Instance details

Defined in Data.Textual

Methods

traverse :: Applicative f => (a -> f b) -> Parsed a -> f (Parsed b)

sequenceA :: Applicative f => Parsed (f a) -> f (Parsed a)

mapM :: Monad m => (a -> m b) -> Parsed a -> m (Parsed b)

sequence :: Monad m => Parsed (m a) -> m (Parsed a)

Alternative Parsed Source # 
Instance details

Defined in Data.Textual

Methods

empty :: Parsed a

(<|>) :: Parsed a -> Parsed a -> Parsed a

some :: Parsed a -> Parsed [a]

many :: Parsed a -> Parsed [a]

Eq α => Eq (Parsed α) Source # 
Instance details

Defined in Data.Textual

Methods

(==) :: Parsed α -> Parsed α -> Bool

(/=) :: Parsed α -> Parsed α -> Bool

Show α => Show (Parsed α) Source # 
Instance details

Defined in Data.Textual

Methods

showsPrec :: Int -> Parsed α -> ShowS

show :: Parsed α -> String

showList :: [Parsed α] -> ShowS

isParsed :: Parsed α -> Bool Source #

Map Parsed to True and Malformed to False.

isMalformed :: Parsed α -> Bool Source #

Map Parsed to False and Malformed to True.

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.

fromLazyText :: Textual α => Text -> Maybe α Source #

A shorthand for maybeParsed . parseLazyText

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

Provide a hint for the type system when using fromLazyText.

fromAscii :: Textual α => ByteString -> Maybe α Source #

A shorthand for maybeParsed . parseAscii

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

Provide a hint for the type system when using fromAscii.

fromLazyAscii :: Textual α => ByteString -> Maybe α Source #

A shorthand for maybeParsed . parseLazyAscii

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.

fromLazyUtf8 :: Textual α => ByteString -> Maybe α Source #

A shorthand for maybeParsed . parseLazyUtf8

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

Provide a hint for the type system when using fromLazyUtf8.