-- 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.1 -- | 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 -- | 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 -- | UTF-8 lazy ByteString builder. newtype Utf8Builder Utf8Builder :: Builder -> Utf8Builder utf8Builder :: Utf8Builder -> Builder buildUtf8 :: 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 -- | Print an unsigned number in the binary numeral system. unsignedBinary :: (Num α, Bits α, Printer p) => α -> p -- | Print an unsigned number in the octal numeral system. unsignedOctal :: (Num α, Bits α, Printer p) => α -> p -- | Print an unsigned number in the hexadecimal numeral system using upper -- case digits. unsignedUpHex :: (Num α, Bits α, Printer p) => α -> p -- | Print an unsigned number in the hexadecimal numeral system using lower -- case digits. unsignedLowHex :: (Num α, Bits α, Printer p) => α -> p -- | Print an unsigned number in the decimal numeral system. unsignedDecimal :: (Integral α, Printer p) => α -> p -- | Print a number in the binary numeral system. binary' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the binary numeral system. Negative values are -- prefixed with "-0b", postive values are prefixed with "0b". binary :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a number in the octal numeral system. octal' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the octal numeral system. Negative values are -- prefixed with "-0o", postive values are prefixed with "0o". octal :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a number in the hexadecimal numeral system using lower case -- digits. lowHex' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the hexadecimal numeral system using lower case -- digits. Negative values are prefixed with "-0x", positive values are -- prefixed with "0x". lowHex :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a number in the hexadecimal numeral system using upper case -- digits. upHex' :: (Ord α, Num α, Bits α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the hexadecimal numeral system using upper case -- digits. Negative values are prefixed with "-0x", positive values are -- prefixed with "0x". upHex :: (Ord α, Num α, Bits α, Printer p) => α -> p -- | Print a number in the decimal numeral system. decimal' :: (Integral α, Printer p) => p -> p -> p -> α -> p -- | Print a number in the decimal numeral system. Negative values are -- prefixed with "-". decimal :: (Integral α, Printer p) => α -> 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 -- | The default printer for values of a type. class Printable α where printList = defaultPrintList print :: (Printable α, Printer p) => α -> p printList :: (Printable α, Printer p) => [α] -> p defaultPrintList :: (Printable α, Printer p) => [α] -> p -- | Print a Printable value via StringBuilder, i.e. -- toString = buildString . print. toString :: Printable α => α -> String instance Typeable StringBuilder instance Typeable AsciiBuilder instance Typeable Utf8Builder instance Typeable1 LinePrinter instance Monoid StringBuilder instance Monoid AsciiBuilder instance Monoid Utf8Builder instance Printable Double instance Printable Float instance Printable Word64 instance Printable Word32 instance Printable Word16 instance Printable Word8 instance Printable Word instance Printable Int64 instance Printable Int32 instance Printable Int16 instance Printable Int8 instance Printable Int instance Printable Integer instance Printable Text instance Printable Text instance Printable Char instance Printable α => Printable [α] instance (Printable α, Printable β, Printable γ, Printable δ) => Printable (α, β, γ, δ) instance (Printable α, Printable β, Printable γ) => Printable (α, β, γ) instance (Printable α, Printable β) => Printable (α, β) instance Printable () 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 IsString Utf8Builder instance Printer AsciiBuilder instance IsString AsciiBuilder instance Printer Builder instance Printer StringBuilder instance IsString StringBuilder instance Printer String