Safe Haskell | None |
---|
Monoids with a homomorphism from String
to themselves.
- class (IsString p, Monoid p) => Printer p where
- char :: Char -> p
- char7 :: Char -> p
- string :: String -> p
- string7 :: String -> p
- text :: Text -> p
- lazyText :: Text -> p
- ascii :: ByteString -> p
- lazyAscii :: ByteString -> p
- utf8 :: ByteString -> p
- lazyUtf8 :: ByteString -> p
- newtype StringBuilder = StringBuilder {
- stringBuilder :: String -> String
- buildString :: StringBuilder -> String
- buildText :: Builder -> Text
- buildLazyText :: Builder -> Text
- newtype AsciiBuilder = AsciiBuilder {}
- buildAscii :: AsciiBuilder -> ByteString
- buildLazyAscii :: AsciiBuilder -> ByteString
- newtype Utf8Builder = Utf8Builder {}
- buildUtf8 :: Utf8Builder -> ByteString
- buildLazyUtf8 :: Utf8Builder -> ByteString
- (<>) :: Monoid m => m -> m -> m
- hcat :: (Printer p, Foldable f) => f p -> p
- fcat :: (Foldable f, Printer p) => (p -> p -> p) -> f p -> p
- separate :: Printer p => p -> p -> p -> p
- (<+>) :: Printer p => p -> p -> p
- hsep :: (Printer p, Foldable f) => f p -> p
- fsep :: (Foldable f, Printer p) => p -> f p -> p
- list :: (Foldable f, Printer p) => f p -> p
- parens :: Printer p => p -> p
- brackets :: Printer p => p -> p
- braces :: Printer p => p -> p
- angles :: Printer p => p -> p
- squotes :: Printer p => p -> p
- dquotes :: Printer p => p -> p
- punctuateL :: (Traversable t, Printer p) => p -> t p -> t p
- punctuateR :: (Traversable t, Printer p) => p -> t p -> t p
- class Printer p => MultilinePrinter p where
- (<->) :: p -> p -> p
- lines :: (MultilinePrinter p, Foldable f) => f p -> p
- newLine :: Printer p => p
- crlf :: Printer p => p
- newtype LinePrinter p = LinePrinter {
- linePrinter :: (p -> p -> p) -> p
- lfPrinter :: Printer p => LinePrinter p -> p
- crlfPrinter :: Printer p => LinePrinter p -> p
The class
class (IsString p, Monoid p) => Printer p whereSource
Text monoid. string
must be equivalent to fromString
and be a monoid
homomorphism, i.e.
and
string
mempty
= mempty
.
Other operations must be monoid homomorphisms that are eqiuvalent (but
possibly faster) to the composition of mappend
(string
x) (string
y) = string
(mappend
x y)string
and the corresponding
embedding, e.g.
.
text
= string
. unpack
Print an ASCII character, can be faster than char
.
Print a string.
Print an ASCII string, can be faster than string
.
Print a Text
.
Print a lazy Text
.
ascii :: ByteString -> pSource
Print an ASCII ByteString
.
lazyAscii :: ByteString -> pSource
Print a lazy ASCII ByteString
.
utf8 :: ByteString -> pSource
Print a UTF-8 ByteString
.
lazyUtf8 :: ByteString -> pSource
Print a lazy UTF-8 ByteString
Builders
newtype StringBuilder Source
A simple string builder as used by Show
.
buildLazyText :: Builder -> TextSource
newtype AsciiBuilder Source
Use this builder when you are sure that only ASCII characters will get printed to it.
newtype Utf8Builder Source
UTF-8 lazy ByteString
builder.
Combinators
:: Printer p | |
=> p | The separator |
-> p | |
-> p | |
-> p |
Concatenate two Printer
s with a separator between them.
hsep :: (Printer p, Foldable f) => f p -> pSource
Concatenate the items of a Foldable
data structure
with spaces between them.
punctuateL :: (Traversable t, Printer p) => p -> t p -> t pSource
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]
punctuateR :: (Traversable t, Printer p) => p -> t p -> t pSource
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]
Multiline printers
lines :: (MultilinePrinter p, Foldable f) => f p -> pSource
newtype LinePrinter p Source
A multiline printer that combines lines with the provided function.
LinePrinter | |
|
Typeable1 LinePrinter | |
IsString p => IsString (LinePrinter p) | |
Monoid p => Monoid (LinePrinter p) | |
Printer p => MultilinePrinter (LinePrinter p) | |
Printer p => Printer (LinePrinter p) |
lfPrinter :: Printer p => LinePrinter p -> pSource
Separate lines with newLine
.
crlfPrinter :: Printer p => LinePrinter p -> pSource
Separate lines with crlf
.