-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Abstract interface for text builders/printers. -- -- This package provides an interface for injecting text into monoids -- such as builders and printers. @package text-printer @version 0.3 -- | Monoids with a homomorphism from String to themselves. module Text.Printer -- | Text monoid. string must be equivalent to fromString and -- be a monoid homomorphism, i.e. string mempty = -- mempty and mappend (string x) -- (string y) = string (mappend x -- y). Other operations must be monoid homomorphisms that are -- eqiuvalent (but possibly faster) to the composition of string -- and the corresponding embedding, e.g. text = string -- . unpack. class (IsString p, Monoid p) => Printer p where char c = string [c] char7 = char string = fromString string7 = string text = string . unpack lazyText = string . unpack ascii = string . unpack lazyAscii = string . unpack utf8 = text . decodeUtf8 lazyUtf8 = lazyText . decodeUtf8 char :: Printer p => Char -> p char7 :: Printer p => Char -> p string :: Printer p => String -> p string7 :: Printer p => String -> p text :: Printer p => Text -> p lazyText :: Printer p => Text -> p ascii :: Printer p => ByteString -> p lazyAscii :: Printer p => ByteString -> p utf8 :: Printer p => ByteString -> p lazyUtf8 :: Printer p => ByteString -> p -- | A simple string builder as used by Show. newtype StringBuilder StringBuilder :: (String -> String) -> StringBuilder stringBuilder :: StringBuilder -> String -> String buildString :: StringBuilder -> String buildText :: Builder -> Text buildLazyText :: Builder -> Text -- | Use this builder when you are sure that only ASCII characters will get -- printed to it. newtype AsciiBuilder AsciiBuilder :: Builder -> AsciiBuilder asciiBuilder :: AsciiBuilder -> Builder buildAscii :: AsciiBuilder -> ByteString buildLazyAscii :: AsciiBuilder -> ByteString -- | UTF-8 lazy ByteString builder. newtype Utf8Builder Utf8Builder :: Builder -> Utf8Builder utf8Builder :: Utf8Builder -> Builder buildUtf8 :: Utf8Builder -> ByteString buildLazyUtf8 :: Utf8Builder -> ByteString -- | An infix synonym for mappend. (<>) :: Monoid m => m -> m -> m -- | mconcat for Foldable data structures. hcat :: (Printer p, Foldable f) => f p -> p -- | Combine the items of a Foldable data structure using the -- provided function. If the data structure is empty, mempty is -- returned. fcat :: (Foldable f, Printer p) => (p -> p -> p) -> f p -> p -- | Concatenate two Printers with a separator between them. separate :: Printer p => p -> p -> p -> p -- | Concatenate two Printers with a space between them. (<+>) :: Printer p => p -> p -> p -- | Concatenate the items of a Foldable data structure with spaces -- between them. hsep :: (Printer p, Foldable f) => f p -> p -- | A shorthand for fcat . separate. fsep :: (Foldable f, Printer p) => p -> f p -> p -- | Concatenate the items of a Foldable data structure with commas -- between them. -- --
--   list = fsep (char7 ',')
--   
list :: (Foldable f, Printer p) => f p -> p -- | Enclose a Printer with parentheses. parens :: Printer p => p -> p -- | Enclose a Printer with square brackets. brackets :: Printer p => p -> p -- | Enclose a Printer with curly braces. braces :: Printer p => p -> p -- | Enclose a Printer with angle brackets. angles :: Printer p => p -> p -- | Enclose a Printer with single quotes. squotes :: Printer p => p -> p -- | Enclose a Printer with double quotes. dquotes :: Printer p => p -> p -- | Prepend all but the first element of a Traversable with the -- provided value, e.g. punctuateL p [x1, -- x2, ..., xN] = [x1, p <> -- x2, ..., p <> xN] punctuateL :: (Traversable t, Printer p) => p -> t p -> t p -- | Append the provided value to all but the last element of a -- Traversable, e.g. punctuateR p [x1, -- ..., xN-1, xN] = [x1 <> p, -- ..., xN-1 <> p, xN] punctuateR :: (Traversable t, Printer p) => p -> t p -> t p -- | Printers that can produce multiple lines of text. class Printer p => MultilinePrinter p (<->) :: MultilinePrinter p => p -> p -> p -- | Combine the items of a Foldable data structure with -- <->. lines :: (MultilinePrinter p, Foldable f) => f p -> p -- | Print the LF character ('\n'). newLine :: Printer p => p -- | Print CR ('\r') followed by LF ('\n'). crlf :: Printer p => p -- | A multiline printer that combines lines with the provided function. newtype LinePrinter p LinePrinter :: ((p -> p -> p) -> p) -> LinePrinter p linePrinter :: LinePrinter p -> (p -> p -> p) -> p -- | Separate lines with newLine. lfPrinter :: Printer p => LinePrinter p -> p -- | Separate lines with crlf. crlfPrinter :: Printer p => LinePrinter p -> p instance Typeable StringBuilder instance Typeable AsciiBuilder instance Typeable Utf8Builder instance Typeable1 LinePrinter instance Monoid StringBuilder instance Monoid AsciiBuilder instance Monoid Utf8Builder instance Printer p => MultilinePrinter (LinePrinter p) instance Printer p => Printer (LinePrinter p) instance Monoid p => Monoid (LinePrinter p) instance IsString p => IsString (LinePrinter p) instance MultilinePrinter Doc instance Printer Doc instance Printer Utf8Builder instance Semigroup Utf8Builder instance IsString Utf8Builder instance Printer AsciiBuilder instance Semigroup AsciiBuilder instance IsString AsciiBuilder instance Printer Builder instance Printer StringBuilder instance Semigroup StringBuilder instance IsString StringBuilder instance Printer String -- | Print numbers in common positional numeral systems. module Text.Printer.Numerals -- | Positional numeral system. class PositionalSystem s where printDigitIn _ = char7 systemName :: PositionalSystem s => s -> String radixIn :: (PositionalSystem s, Num α) => s -> α isDigitIn :: PositionalSystem s => s -> Char -> Bool isNzDigitIn :: PositionalSystem s => s -> Char -> Bool fromDigitIn :: (PositionalSystem s, Num α) => s -> Char -> Maybe α fromNzDigitIn :: (PositionalSystem s, Num α) => s -> Char -> Maybe α unsafeFromDigitIn :: (PositionalSystem s, Num α) => s -> Char -> α intToDigitIn :: PositionalSystem s => s -> Int -> Char printDigitIn :: (PositionalSystem s, Printer p) => s -> Char -> p -- | Positonal numeral system with a power of two radix. class PositionalSystem s => BitSystem s digitBitsIn :: BitSystem s => s -> Int digitMaskIn :: (BitSystem s, Num α) => s -> α lastDigitIn :: (BitSystem s, Bits α) => s -> α -> Int -- | The binary numeral system. data Binary Binary :: Binary -- | The octal numeral system. data Octal Octal :: Octal -- | The decimal numeral system. data Decimal Decimal :: Decimal -- | The hexadecimal numeral system. data Hexadecimal Hexadecimal :: Hexadecimal -- | The hexadecimal numeral system, using lower case digits. data LowHex LowHex :: LowHex -- | The hexadecimal numeral system, using upper case digits. data UpHex UpHex :: UpHex -- | Print a non-negative number in the specified positional numeral -- system. nonNegative :: (PositionalSystem s, Integral α, Printer p) => s -> α -> p -- | Print a non-negative number in the binary numeral system. nnBinary :: (Integral α, Printer p) => α -> p -- | Print a non-negative number in the octal numeral system. nnOctal :: (Integral α, Printer p) => α -> p -- | Print a non-negative number in the decimal numeral system. nnDecimal :: (Integral α, Printer p) => α -> p -- | Print a non-negative number in the hexadecimal numeral system using -- lower case digits. nnLowHex :: (Integral α, Printer p) => α -> p -- | Print a non-negative number in the hexadecimal numeral system using -- upper case digits. nnUpHex :: (Integral α, Printer p) => α -> p -- | Print a non-negative binary number in the specified positional numeral -- system. nnBits :: (BitSystem s, Num α, Bits α, Printer p) => s -> α -> p -- | Print a non-negative binary number in the binary numeral system. nnBinaryBits :: (Num α, Bits α, Printer p) => α -> p -- | Print a non-negative binary number in the octal numeral system. nnOctalBits :: (Num α, Bits α, Printer p) => α -> p -- | Print a non-negative binary number in the hexadecimal numeral system -- using lower case digits. nnLowHexBits :: (Num α, Bits α, Printer p) => α -> p -- | Print a non-negative binary number in the hexadecimal numeral system -- using upper case digits. nnUpHexBits :: (Num α, Bits α, Printer p) => α -> p -- | Print a non-positive number in the specified positional numeral -- system. For example, nonPositive Decimal -- (-123) would print "123". nonPositive :: (PositionalSystem s, Integral α, Printer p) => s -> α -> p -- | Print a non-positive number in the binary numeral system. npBinary :: (Integral α, Printer p) => α -> p -- | Print a non-positive number in the octal numeral system. npOctal :: (Integral α, Printer p) => α -> p -- | Print a non-positive number in the decimal numeral system. npDecimal :: (Integral α, Printer p) => α -> p -- | Print a non-positive number in the hexadecimal numeral system using -- lower case digits. npLowHex :: (Integral α, Printer p) => α -> p -- | Print a non-positive number in the hexadecimal numeral system using -- upper case digits. npUpHex :: (Integral α, Printer p) => α -> p -- | Print a non-positive two-compliment binary number in the specified -- positional numeral system. For example, npBits UpHex -- (-0xABC) would print "ABC". npBits :: (BitSystem s, Ord α, Num α, Bits α, Printer p) => s -> α -> p -- | Print a non-positive binary number in the binary numeral system. npBinaryBits :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a non-positive binary number in the octal numeral system. npOctalBits :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a non-positive binary number in the hexadecimal numeral system -- using lower case digits. npLowHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a non-positive binary number in the hexadecimal numeral system -- using upper case digits. npUpHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a number in the specified positional numeral system. number' :: (PositionalSystem s, Ord α, Integral α, Printer p) => s -> p -> p -> p -> α -> p -- | Print a number in the specified positional numeral system. Negative -- values are prefixed with a minus sign. number :: (PositionalSystem s, Ord α, Integral α, Printer p) => s -> α -> p -- | Print a number in the binary numeral system. binary' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the binary numeral system. Negative values are -- prefixed with a minus sign. binary :: (Ord α, Integral α, Printer p) => α -> p -- | Print a number in the octal numeral system. octal' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the octal numeral system. Negative values are -- prefixed with a minus sign. octal :: (Ord α, Integral α, Printer p) => α -> p -- | Print a number in the decimal numeral system. decimal' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the decimal numeral system. Negative values are -- prefixed with a minus sign. decimal :: (Ord α, Integral α, Printer p) => α -> p -- | Print a number in the hexadecimal numeral system using lower case -- digits. lowHex' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the hexadecimal numeral system using lower case -- digits. Negative values are prefixed with a minus sign. lowHex :: (Ord α, Integral α, Printer p) => α -> p -- | Print a number in the hexadecimal numeral system using upper case -- digits. upHex' :: (Ord α, Integral α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the hexadecimal numeral system using upper case -- digits. Negative values are prefixed with a minus sign. upHex :: (Ord α, Integral α, Printer p) => α -> p -- | Print a binary number in the specified positional numeral system. bits' :: (BitSystem s, Ord α, Num α, Bits α, Printer p) => s -> p -> p -> p -> α -> p -- | Print a binary number in the specified positional numeral system. -- Negative values are prefixed with a minus sign. bits :: (BitSystem s, Ord α, Num α, Bits α, Printer p) => s -> α -> p -- | Print a binary number in the binary numeral system. binaryBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a binary number in the binary numeral system. Negative values -- are prefixed with a minus sign. binaryBits :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a binary number in the octal numeral system. octalBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a binary number in the octal numeral system. Negative values are -- prefixed with a minus sign. octalBits :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a binary number in the hexadecimal numeral system using lower -- case digits. lowHexBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a binary number in the hexadecimal numeral system using lower -- case digits. Negative values are prefixed with a minus sign. lowHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a binary number in the hexadecimal numeral system using upper -- case digits. upHexBits' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a binary number in the hexadecimal numeral system using upper -- case digits. Negative values are prefixed with a minus sign. upHexBits :: (Ord α, Num α, Bits α, Printer p) => α -> p instance Typeable Binary instance Typeable Octal instance Typeable Decimal instance Eq Binary instance Ord Binary instance Show Binary instance Read Binary instance Eq Octal instance Ord Octal instance Show Octal instance Read Octal instance Eq Decimal instance Ord Decimal instance Show Decimal instance Read Decimal instance BitSystem UpHex instance PositionalSystem UpHex instance BitSystem LowHex instance PositionalSystem LowHex instance BitSystem Hexadecimal instance PositionalSystem Hexadecimal instance PositionalSystem Decimal instance BitSystem Octal instance PositionalSystem Octal instance BitSystem Binary instance PositionalSystem Binary