-- 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.5 -- | 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, Semigroup 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 -- | Print a character. char c must be equivalent to -- string [c], but hopefully is faster. char :: Printer p => Char -> p -- | Print an ASCII character, can be faster than char. char7 :: Printer p => Char -> p -- | Print a string. string :: Printer p => String -> p -- | Print an ASCII string, can be faster than string. string7 :: Printer p => String -> p -- | Print a Text. text :: Printer p => Text -> p -- | Print a lazy Text. lazyText :: Printer p => Text -> p -- | Print an ASCII ByteString. ascii :: Printer p => ByteString -> p -- | Print a lazy ASCII ByteString. lazyAscii :: Printer p => ByteString -> p -- | Print a UTF-8 ByteString. utf8 :: Printer p => ByteString -> p -- | Print a lazy UTF-8 ByteString 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 newtype PrettyPrinter PrettyPrinter :: Doc -> PrettyPrinter [prettyPrinter] :: PrettyPrinter -> Doc -- | An alias for render . prettyPrinter renderPretty :: PrettyPrinter -> String -- | An infix synonym for mappend. (<>) :: Monoid m => m -> m -> m infixr 6 <> -- | 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 infixr 6 <+> -- | 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 -- | Combine two lines. Must be associative, i.e. x <-> -- (y <-> z) = (x <-> -- y) <-> z. (<->) :: 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 GHC.Generics.Generic (Text.Printer.LinePrinter p) instance GHC.Base.Monoid Text.Printer.PrettyPrinter instance Data.Semigroup.Semigroup Text.Printer.PrettyPrinter instance Data.String.IsString Text.Printer.PrettyPrinter instance GHC.Generics.Generic Text.Printer.PrettyPrinter instance GHC.Base.Monoid Text.Printer.Utf8Builder instance GHC.Generics.Generic Text.Printer.Utf8Builder instance GHC.Base.Monoid Text.Printer.AsciiBuilder instance GHC.Generics.Generic Text.Printer.AsciiBuilder instance GHC.Base.Monoid Text.Printer.StringBuilder instance Data.Semigroup.Semigroup Text.Printer.StringBuilder instance GHC.Generics.Generic Text.Printer.StringBuilder instance Text.Printer.Printer GHC.Base.String instance Data.String.IsString Text.Printer.StringBuilder instance Text.Printer.Printer Text.Printer.StringBuilder instance Text.Printer.Printer Data.Text.Internal.Builder.Builder instance Data.String.IsString Text.Printer.AsciiBuilder instance Data.Semigroup.Semigroup Text.Printer.AsciiBuilder instance Text.Printer.Printer Text.Printer.AsciiBuilder instance Data.String.IsString Text.Printer.Utf8Builder instance Data.Semigroup.Semigroup Text.Printer.Utf8Builder instance Text.Printer.Printer Text.Printer.Utf8Builder instance Text.Printer.Printer Text.Printer.PrettyPrinter instance Text.Printer.MultilinePrinter Text.Printer.PrettyPrinter instance Data.String.IsString p => Data.String.IsString (Text.Printer.LinePrinter p) instance Data.Semigroup.Semigroup p => Data.Semigroup.Semigroup (Text.Printer.LinePrinter p) instance GHC.Base.Monoid p => GHC.Base.Monoid (Text.Printer.LinePrinter p) instance Text.Printer.Printer p => Text.Printer.Printer (Text.Printer.LinePrinter p) instance Text.Printer.Printer p => Text.Printer.MultilinePrinter (Text.Printer.LinePrinter p) -- | Print integral numbers in common positional numeral systems. module Text.Printer.Integral -- | Positional numeral system. class PositionalSystem s where printDigitIn _ = char7 printZeroIn s = printDigitIn s $! intToDigitIn s 0 -- | The name of the system (e.g. "binary", "decimal"). systemName :: PositionalSystem s => s -> String -- | The radix of the system. radixIn :: (PositionalSystem s, Num α) => s -> α -- | Test if a character is a digit. isDigitIn :: PositionalSystem s => s -> Char -> Bool -- | Test if a character is a non-zero digit. isNzDigitIn :: PositionalSystem s => s -> Char -> Bool -- | Map digits to the corresponding numbers. Return Nothing on -- other inputs. fromDigitIn :: (PositionalSystem s, Num α) => s -> Char -> Maybe α -- | Map non-zero digits to the corresponding numbers. Return -- Nothing on other inputs. fromNzDigitIn :: (PositionalSystem s, Num α) => s -> Char -> Maybe α -- | Map digits to the corresponding numbers. No checks are performed. unsafeFromDigitIn :: (PositionalSystem s, Num α) => s -> Char -> α -- | Map Int values to the corresponding digits. Inputs must -- be non-negative and less than the radix. intToDigitIn :: PositionalSystem s => s -> Int -> Char -- | Print a digit. printDigitIn :: (PositionalSystem s, Printer p) => s -> Char -> p printZeroIn :: (PositionalSystem s, Printer p) => s -> p -- | Positonal numeral system with a power of two radix. class PositionalSystem s => BitSystem s -- | Numer of bits occupied by a digit. digitBitsIn :: BitSystem s => s -> Int -- | The number that has digitBitsIn least significant bits set to -- ones and all the other bits set to zeroes. digitMaskIn :: (BitSystem s, Num α) => s -> α -- | Map the last digit of a number to the corresponding Int value. 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 GHC.Read.Read Text.Printer.Integral.UpHex instance GHC.Show.Show Text.Printer.Integral.UpHex instance GHC.Classes.Ord Text.Printer.Integral.UpHex instance GHC.Classes.Eq Text.Printer.Integral.UpHex instance GHC.Generics.Generic Text.Printer.Integral.UpHex instance GHC.Read.Read Text.Printer.Integral.LowHex instance GHC.Show.Show Text.Printer.Integral.LowHex instance GHC.Classes.Ord Text.Printer.Integral.LowHex instance GHC.Classes.Eq Text.Printer.Integral.LowHex instance GHC.Generics.Generic Text.Printer.Integral.LowHex instance GHC.Read.Read Text.Printer.Integral.Hexadecimal instance GHC.Show.Show Text.Printer.Integral.Hexadecimal instance GHC.Classes.Ord Text.Printer.Integral.Hexadecimal instance GHC.Classes.Eq Text.Printer.Integral.Hexadecimal instance GHC.Generics.Generic Text.Printer.Integral.Hexadecimal instance GHC.Read.Read Text.Printer.Integral.Decimal instance GHC.Show.Show Text.Printer.Integral.Decimal instance GHC.Classes.Ord Text.Printer.Integral.Decimal instance GHC.Classes.Eq Text.Printer.Integral.Decimal instance GHC.Generics.Generic Text.Printer.Integral.Decimal instance GHC.Read.Read Text.Printer.Integral.Octal instance GHC.Show.Show Text.Printer.Integral.Octal instance GHC.Classes.Ord Text.Printer.Integral.Octal instance GHC.Classes.Eq Text.Printer.Integral.Octal instance GHC.Generics.Generic Text.Printer.Integral.Octal instance GHC.Read.Read Text.Printer.Integral.Binary instance GHC.Show.Show Text.Printer.Integral.Binary instance GHC.Classes.Ord Text.Printer.Integral.Binary instance GHC.Classes.Eq Text.Printer.Integral.Binary instance GHC.Generics.Generic Text.Printer.Integral.Binary instance Text.Printer.Integral.PositionalSystem Text.Printer.Integral.Binary instance Text.Printer.Integral.BitSystem Text.Printer.Integral.Binary instance Text.Printer.Integral.PositionalSystem Text.Printer.Integral.Octal instance Text.Printer.Integral.BitSystem Text.Printer.Integral.Octal instance Text.Printer.Integral.PositionalSystem Text.Printer.Integral.Decimal instance Text.Printer.Integral.PositionalSystem Text.Printer.Integral.Hexadecimal instance Text.Printer.Integral.BitSystem Text.Printer.Integral.Hexadecimal instance Text.Printer.Integral.PositionalSystem Text.Printer.Integral.LowHex instance Text.Printer.Integral.BitSystem Text.Printer.Integral.LowHex instance Text.Printer.Integral.PositionalSystem Text.Printer.Integral.UpHex instance Text.Printer.Integral.BitSystem Text.Printer.Integral.UpHex -- | Print fractions. module Text.Printer.Fractional -- | Positional numeral system. class PositionalSystem s where printDigitIn _ = char7 printZeroIn s = printDigitIn s $! intToDigitIn s 0 -- | The name of the system (e.g. "binary", "decimal"). systemName :: PositionalSystem s => s -> String -- | The radix of the system. radixIn :: (PositionalSystem s, Num α) => s -> α -- | Test if a character is a digit. isDigitIn :: PositionalSystem s => s -> Char -> Bool -- | Test if a character is a non-zero digit. isNzDigitIn :: PositionalSystem s => s -> Char -> Bool -- | Map digits to the corresponding numbers. Return Nothing on -- other inputs. fromDigitIn :: (PositionalSystem s, Num α) => s -> Char -> Maybe α -- | Map non-zero digits to the corresponding numbers. Return -- Nothing on other inputs. fromNzDigitIn :: (PositionalSystem s, Num α) => s -> Char -> Maybe α -- | Map digits to the corresponding numbers. No checks are performed. unsafeFromDigitIn :: (PositionalSystem s, Num α) => s -> Char -> α -- | Map Int values to the corresponding digits. Inputs must -- be non-negative and less than the radix. intToDigitIn :: PositionalSystem s => s -> Int -> Char -- | Print a digit. printDigitIn :: (PositionalSystem s, Printer p) => s -> Char -> p printZeroIn :: (PositionalSystem s, Printer p) => s -> p -- | Positonal numeral system with a power of two radix. class PositionalSystem s => BitSystem s -- | Numer of bits occupied by a digit. digitBitsIn :: BitSystem s => s -> Int -- | The number that has digitBitsIn least significant bits set to -- ones and all the other bits set to zeroes. digitMaskIn :: (BitSystem s, Num α) => s -> α -- | Map the last digit of a number to the corresponding Int value. 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 -- | Optionality characteristic. data Optional Optional :: Optional Required :: Optional -- | True if the supplied value is Optional and false otherwise. isOptional :: Optional -> Bool -- | True if the supplied value is Required and false otherwise. isRequired :: Optional -> Bool -- | Print a fraction, writing the numerator and the denominator in the -- specified positional numeral system. fraction' :: (PositionalSystem s, Real α, Printer p) => s -> p -> p -> p -> p -> Optional -> α -> p -- | Print a fraction. The numerator and the denominator are written in the -- decimal numeral system and separated by a slash. Negative values are -- prefixed with a minus sign. Invisible denominators are omitted. fraction :: (Real α, Printer p) => α -> p instance GHC.Arr.Ix Text.Printer.Fractional.Optional instance GHC.Enum.Bounded Text.Printer.Fractional.Optional instance GHC.Enum.Enum Text.Printer.Fractional.Optional instance GHC.Classes.Ord Text.Printer.Fractional.Optional instance GHC.Classes.Eq Text.Printer.Fractional.Optional instance GHC.Read.Read Text.Printer.Fractional.Optional instance GHC.Show.Show Text.Printer.Fractional.Optional instance GHC.Generics.Generic Text.Printer.Fractional.Optional