-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | pretty printer for data types with a 'Show' instance. -- -- Please see README.md. @package pretty-simple @version 3.2.3.0 module Text.Pretty.Simple.Internal.Color -- | These options are for colorizing the output of functions like -- pPrint. -- -- For example, if you set colorQuote to something like -- colorVividBlueBold, then the quote character (") will -- be output as bright blue in bold. -- -- If you don't want to use a color for one of the options, use -- colorNull. data ColorOptions ColorOptions :: Builder -> Builder -> Builder -> Builder -> [Builder] -> ColorOptions -- | Color to use for quote characters (") around strings. [colorQuote] :: ColorOptions -> Builder -- | Color to use for strings. [colorString] :: ColorOptions -> Builder -- | (currently not used) [colorError] :: ColorOptions -> Builder -- | Color to use for numbers. [colorNum] :: ColorOptions -> Builder -- | A list of Builder colors to use for rainbow parenthesis output. -- Use '[]' if you don't want rainbow parenthesis. Use just a single item -- if you want all the rainbow parenthesis to be colored the same. [colorRainbowParens] :: ColorOptions -> [Builder] -- | Default color options for use on a dark background. -- -- colorQuote is defaultColorQuoteDarkBg. -- colorString is defaultColorStringDarkBg. -- colorError is defaultColorErrorDarkBg. colorNum -- is defaultColorNumDarkBg. colorRainbowParens is -- defaultColorRainboxParensDarkBg. defaultColorOptionsDarkBg :: ColorOptions -- | Default color for colorQuote for dark backgrounds. This is -- colorVividWhiteBold. defaultColorQuoteDarkBg :: Builder -- | Default color for colorString for dark backgrounds. This is -- colorVividBlueBold. defaultColorStringDarkBg :: Builder -- | Default color for colorError for dark backgrounds. This is -- colorVividRedBold. defaultColorErrorDarkBg :: Builder -- | Default color for colorNum for dark backgrounds. This is -- colorVividGreenBold. defaultColorNumDarkBg :: Builder -- | Default colors for colorRainbowParens for dark backgrounds. defaultColorRainbowParensDarkBg :: [Builder] -- | Default color options for use on a light background. -- -- colorQuote is defaultColorQuoteLightBg. -- colorString is defaultColorStringLightBg. -- colorError is defaultColorErrorLightBg. colorNum -- is defaultColorNumLightBg. colorRainbowParens is -- defaultColorRainboxParensLightBg. defaultColorOptionsLightBg :: ColorOptions -- | Default color for colorQuote for light backgrounds. This is -- colorVividWhiteBold. defaultColorQuoteLightBg :: Builder -- | Default color for colorString for light backgrounds. This is -- colorVividBlueBold. defaultColorStringLightBg :: Builder -- | Default color for colorError for light backgrounds. This is -- colorVividRedBold. defaultColorErrorLightBg :: Builder -- | Default color for colorNum for light backgrounds. This is -- colorVividGreenBold. defaultColorNumLightBg :: Builder -- | Default colors for colorRainbowParens for light backgrounds. defaultColorRainbowParensLightBg :: [Builder] colorVividBlackBold :: Builder colorVividBlueBold :: Builder colorVividCyanBold :: Builder colorVividGreenBold :: Builder colorVividMagentaBold :: Builder colorVividRedBold :: Builder colorVividWhiteBold :: Builder colorVividYellowBold :: Builder colorDullBlackBold :: Builder colorDullBlueBold :: Builder colorDullCyanBold :: Builder colorDullGreenBold :: Builder colorDullMagentaBold :: Builder colorDullRedBold :: Builder colorDullWhiteBold :: Builder colorDullYellowBold :: Builder colorVividBlack :: Builder colorVividBlue :: Builder colorVividCyan :: Builder colorVividGreen :: Builder colorVividMagenta :: Builder colorVividRed :: Builder colorVividWhite :: Builder colorVividYellow :: Builder colorDullBlack :: Builder colorDullBlue :: Builder colorDullCyan :: Builder colorDullGreen :: Builder colorDullMagenta :: Builder colorDullRed :: Builder colorDullWhite :: Builder colorDullYellow :: Builder -- | Change the intensity to BoldIntensity. colorBold :: Builder -- | Reset the console color back to normal. colorReset :: Builder -- | Empty string. colorNull :: Builder -- | Helper for creating a Builder for an ANSI escape sequence color -- based on a ColorIntensity and a Color. colorHelper :: ColorIntensity -> Color -> Builder -- | Convert a list of SGR to a Builder. setSGRCodeBuilder :: [SGR] -> Builder instance GHC.Show.Show Text.Pretty.Simple.Internal.Color.ColorOptions instance GHC.Generics.Generic Text.Pretty.Simple.Internal.Color.ColorOptions instance GHC.Classes.Eq Text.Pretty.Simple.Internal.Color.ColorOptions module Text.Pretty.Simple.Internal.Expr newtype CommaSeparated a CommaSeparated :: [a] -> CommaSeparated a [unCommaSeparated] :: CommaSeparated a -> [a] data Expr Brackets :: !CommaSeparated [Expr] -> Expr Braces :: !CommaSeparated [Expr] -> Expr Parens :: !CommaSeparated [Expr] -> Expr StringLit :: !String -> Expr CharLit :: !String -> Expr -- | We could store this as a Rational, say, instead of a -- String. However, we will never need to use its value for -- anything. Indeed, the only thing we will be doing with it is turning -- it back into a string at some stage, so we might as well cut -- out the middle man and store it directly like this. NumberLit :: !String -> Expr Other :: !String -> Expr instance GHC.Show.Show Text.Pretty.Simple.Internal.Expr.Expr instance GHC.Generics.Generic Text.Pretty.Simple.Internal.Expr.Expr instance GHC.Classes.Eq Text.Pretty.Simple.Internal.Expr.Expr instance Data.Data.Data Text.Pretty.Simple.Internal.Expr.Expr instance GHC.Show.Show a => GHC.Show.Show (Text.Pretty.Simple.Internal.Expr.CommaSeparated a) instance GHC.Generics.Generic (Text.Pretty.Simple.Internal.Expr.CommaSeparated a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.Pretty.Simple.Internal.Expr.CommaSeparated a) instance Data.Data.Data a => Data.Data.Data (Text.Pretty.Simple.Internal.Expr.CommaSeparated a) module Text.Pretty.Simple.Internal.ExprParser -- | testString1 and testString2 are convenient to use in -- GHCi when playing around with how parsing works. testString1 :: String -- | See testString1. testString2 :: String expressionParse :: String -> [Expr] parseExpr :: String -> (Expr, String) -- | Parse multiple expressions. -- --
--   >>> parseExprs "Just 'a'"
--   ([Other "Just ",CharLit "a"],"")
--   
-- -- Handle escaped characters correctly -- --
--   >>> parseExprs $ "Foo \"hello \\\"world!\""
--   ([Other "Foo ",StringLit "hello \\\"world!"],"")
--   
--   >>> parseExprs $ "'\\''"
--   ([CharLit "\\'"],"")
--   
parseExprs :: String -> ([Expr], String) parseCSep :: Char -> String -> ([[Expr]], String) -- | Parse string literals until a trailing double quote. -- --
--   >>> parseStringLit "foobar\" baz"
--   ("foobar"," baz")
--   
-- -- Keep literal back slashes: -- --
--   >>> parseStringLit "foobar\\\" baz\" after"
--   ("foobar\\\" baz"," after")
--   
parseStringLit :: String -> (String, String) -- | Parse character literals until a trailing single quote. -- --
--   >>> parseCharLit "a' foobar"
--   ("a"," foobar")
--   
-- -- Keep literal back slashes: -- --
--   >>> parseCharLit "\\'' hello"
--   ("\\'"," hello")
--   
parseCharLit :: String -> (String, String) -- | Parses integers and reals, like 123 and 45.67. -- -- To be more precise, any numbers matching the regex -- \d+(\.\d+)? should get parsed by this function. -- --
--   >>> parseNumberLit '3' "456hello world []"
--   ("3456","hello world []")
--   
--   >>> parseNumberLit '0' ".12399880 foobar"
--   ("0.12399880"," foobar")
--   
parseNumberLit :: Char -> String -> (String, String) -- | This function consumes input, stopping only when it hits a special -- character or a digit. However, if the digit is in the middle of a -- Haskell-style identifier (e.g. foo123), then keep going -- anyway. -- -- This is almost the same as the function -- --
--   parseOtherSimple = span $ \c ->
--     notElem c ("{[()]}\"," :: String) && not (isDigit c) && (c /= '\'')
--   
-- -- except parseOther ignores digits and single quotes that appear -- in Haskell-like identifiers. -- --
--   >>> parseOther "hello world []"
--   ("hello world ","[]")
--   
--   >>> parseOther "hello234 world"
--   ("hello234 world","")
--   
--   >>> parseOther "hello 234 world"
--   ("hello ","234 world")
--   
--   >>> parseOther "hello{[ 234 world"
--   ("hello","{[ 234 world")
--   
--   >>> parseOther "H3110 World"
--   ("H3110 World","")
--   
--   >>> parseOther "Node' (Leaf' 1) (Leaf' 2)"
--   ("Node' ","(Leaf' 1) (Leaf' 2)")
--   
--   >>> parseOther "I'm One"
--   ("I'm One","")
--   
--   >>> parseOther "I'm 2"
--   ("I'm ","2")
--   
parseOther :: String -> (String, String) module Text.Pretty.Simple.Internal.Output -- | Datatype representing how much something is nested. -- -- For example, a NestLevel of 0 would mean an Output token -- is at the very highest level, not in any braces. -- -- A NestLevel of 1 would mean that an Output token is in -- one single pair of { and }, or [ and ], -- or <math>@. -- -- A NestLevel of 2 would mean that an Output token is two -- levels of brackets, etc. newtype NestLevel NestLevel :: Int -> NestLevel [unNestLevel] :: NestLevel -> Int -- | These are the output tokens that we will be printing to the screen. data OutputType -- | This represents the } character. OutputCloseBrace :: OutputType -- | This represents the ] character. OutputCloseBracket :: OutputType -- | This represents the ) character. OutputCloseParen :: OutputType -- | This represents the , character. OutputComma :: OutputType -- | This represents an indentation. OutputIndent :: OutputType -- | This represents the \n character. OutputNewLine :: OutputType -- | This represents the { character. OutputOpenBrace :: OutputType -- | This represents the [ character. OutputOpenBracket :: OutputType -- | This represents the ( character. OutputOpenParen :: OutputType -- | This represents some collection of characters that don't fit into any -- of the other tokens. OutputOther :: !String -> OutputType -- | This represents a string literal. For instance, "foobar". OutputStringLit :: !String -> OutputType -- | This represents a char literal. For example, x or -- '\b' OutputCharLit :: !String -> OutputType -- | This represents a numeric literal. For example, 12345 or -- 3.14159. OutputNumberLit :: !String -> OutputType -- | An OutputType token together with a NestLevel. -- Basically, each OutputType keeps track of its own -- NestLevel. data Output Output :: {-# UNPACK #-} !NestLevel -> !OutputType -> Output [outputNestLevel] :: Output -> {-# UNPACK #-} !NestLevel [outputOutputType] :: Output -> !OutputType instance GHC.Show.Show Text.Pretty.Simple.Internal.Output.Output instance GHC.Read.Read Text.Pretty.Simple.Internal.Output.Output instance GHC.Generics.Generic Text.Pretty.Simple.Internal.Output.Output instance GHC.Classes.Eq Text.Pretty.Simple.Internal.Output.Output instance Data.Data.Data Text.Pretty.Simple.Internal.Output.Output instance GHC.Show.Show Text.Pretty.Simple.Internal.Output.OutputType instance GHC.Read.Read Text.Pretty.Simple.Internal.Output.OutputType instance GHC.Generics.Generic Text.Pretty.Simple.Internal.Output.OutputType instance GHC.Classes.Eq Text.Pretty.Simple.Internal.Output.OutputType instance Data.Data.Data Text.Pretty.Simple.Internal.Output.OutputType instance GHC.Show.Show Text.Pretty.Simple.Internal.Output.NestLevel instance GHC.Read.Read Text.Pretty.Simple.Internal.Output.NestLevel instance GHC.Classes.Ord Text.Pretty.Simple.Internal.Output.NestLevel instance GHC.Num.Num Text.Pretty.Simple.Internal.Output.NestLevel instance GHC.Generics.Generic Text.Pretty.Simple.Internal.Output.NestLevel instance GHC.Classes.Eq Text.Pretty.Simple.Internal.Output.NestLevel instance Data.Data.Data Text.Pretty.Simple.Internal.Output.NestLevel instance Data.String.IsString Text.Pretty.Simple.Internal.Output.OutputType module Text.Pretty.Simple.Internal.ExprToOutput -- | Newtype around Int to represent a line number. After a newline, -- the LineNum will increase by 1. newtype LineNum LineNum :: Int -> LineNum [unLineNum] :: LineNum -> Int data PrinterState PrinterState :: {-# UNPACK #-} !LineNum -> {-# UNPACK #-} !NestLevel -> PrinterState [currLine] :: PrinterState -> {-# UNPACK #-} !LineNum [nestLevel] :: PrinterState -> {-# UNPACK #-} !NestLevel -- | Smart-constructor for PrinterState. printerState :: LineNum -> NestLevel -> PrinterState addOutput :: MonadState PrinterState m => OutputType -> m Output addOutputs :: MonadState PrinterState m => [OutputType] -> m [Output] initPrinterState :: PrinterState -- | Print a surrounding expression (like [] or {} or -- ()). -- -- If the CommaSeparated expressions are empty, just print the -- start and end markers. -- --
--   >>> testInit $ putSurroundExpr "[" "]" (CommaSeparated [])
--   [Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputOpenBracket},Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputCloseBracket}]
--   
-- -- If there is only one expression, and it will print out on one line, -- then just print everything all on one line, with spaces around the -- expressions. -- --
--   >>> testInit $ putSurroundExpr "{" "}" (CommaSeparated [[Other "hello"]])
--   [Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputOpenBrace},Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputOther " "},Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputOther "hello"},Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputOther " "},Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputCloseBrace}]
--   
-- -- If there is only one expression, but it will print out on multiple -- lines, then go to newline and print out on multiple lines. -- --
--   >>> 1 + 1  -- TODO: Example here.
--   2
--   
-- -- If there are multiple expressions, then first go to a newline. Print -- out on multiple lines. -- --
--   >>> 1 + 1  -- TODO: Example here.
--   2
--   
putSurroundExpr :: MonadState PrinterState m => OutputType -> OutputType -> CommaSeparated [Expr] -> m [Output] putCommaSep :: forall m. MonadState PrinterState m => CommaSeparated [Expr] -> m [Output] putComma :: MonadState PrinterState m => m [Output] doIndent :: MonadState PrinterState m => m [Output] newLine :: MonadState PrinterState m => m Output newLineAndDoIndent :: MonadState PrinterState m => m [Output] addToNestLevel :: MonadState PrinterState m => NestLevel -> m () addToCurrentLine :: MonadState PrinterState m => LineNum -> m () putExpression :: MonadState PrinterState m => Expr -> m [Output] runPrinterState :: PrinterState -> [Expr] -> [Output] runInitPrinterState :: [Expr] -> [Output] expressionsToOutputs :: [Expr] -> [Output] -- | A function that performs optimizations and modifications to a list of -- input Exprs. -- -- An sample of an optimization is -- removeEmptyInnerCommaSeparatedExprList which removes empty -- inner lists in a CommaSeparated value. modificationsExprList :: [Expr] -> [Expr] removeEmptyInnerCommaSeparatedExprList :: [Expr] -> [Expr] removeEmptyInnerCommaSeparatedExpr :: Expr -> Expr removeEmptyInnerCommaSeparated :: CommaSeparated [Expr] -> CommaSeparated [Expr] -- | Remove empty lists from a list of lists. -- --
--   >>> removeEmptyList [[1,2,3], [], [4,5]]
--   [[1,2,3],[4,5]]
--   
-- --
--   >>> removeEmptyList [[]]
--   []
--   
-- --
--   >>> removeEmptyList [[1]]
--   [[1]]
--   
-- --
--   >>> removeEmptyList [[1,2], [10,20], [100,200]]
--   [[1,2],[10,20],[100,200]]
--   
removeEmptyList :: forall a. [[a]] -> [[a]] instance GHC.Show.Show Text.Pretty.Simple.Internal.ExprToOutput.PrinterState instance GHC.Generics.Generic Text.Pretty.Simple.Internal.ExprToOutput.PrinterState instance Data.Data.Data Text.Pretty.Simple.Internal.ExprToOutput.PrinterState instance GHC.Classes.Eq Text.Pretty.Simple.Internal.ExprToOutput.PrinterState instance GHC.Show.Show Text.Pretty.Simple.Internal.ExprToOutput.LineNum instance GHC.Read.Read Text.Pretty.Simple.Internal.ExprToOutput.LineNum instance GHC.Classes.Ord Text.Pretty.Simple.Internal.ExprToOutput.LineNum instance GHC.Num.Num Text.Pretty.Simple.Internal.ExprToOutput.LineNum instance GHC.Generics.Generic Text.Pretty.Simple.Internal.ExprToOutput.LineNum instance GHC.Classes.Eq Text.Pretty.Simple.Internal.ExprToOutput.LineNum instance Data.Data.Data Text.Pretty.Simple.Internal.ExprToOutput.LineNum module Text.Pretty.Simple.Internal.OutputPrinter -- | Determines whether pretty-simple should check if the output -- Handle is a TTY device. Normally, users only want to print in -- color if the output Handle is a TTY device. data CheckColorTty -- | Check if the output Handle is a TTY device. If the output -- Handle is a TTY device, determine whether to print in color -- based on outputOptionsColorOptions. If not, then set -- outputOptionsColorOptions to Nothing so the output does -- not get colorized. CheckColorTty :: CheckColorTty -- | Don't check if the output Handle is a TTY device. Determine -- whether to colorize the output based solely on the value of -- outputOptionsColorOptions. NoCheckColorTty :: CheckColorTty -- | Data-type wrapping up all the options available when rendering the -- list of Outputs. data OutputOptions OutputOptions :: Int -> Maybe ColorOptions -> Bool -> OutputOptions -- | Number of spaces to use when indenting. It should probably be either 2 -- or 4. [outputOptionsIndentAmount] :: OutputOptions -> Int -- | If this is Nothing, then don't colorize the output. If this is -- Just colorOptions, then use colorOptions to -- colorize the output. [outputOptionsColorOptions] :: OutputOptions -> Maybe ColorOptions -- | Whether to replace non-printable characters with hexadecimal escape -- sequences. [outputOptionsEscapeNonPrintable] :: OutputOptions -> Bool -- | Default values for OutputOptions when printing to a console -- with a dark background. outputOptionsIndentAmount is 4, and -- outputOptionsColorOptions is defaultColorOptionsDarkBg. defaultOutputOptionsDarkBg :: OutputOptions -- | Default values for OutputOptions when printing to a console -- with a light background. outputOptionsIndentAmount is 4, and -- outputOptionsColorOptions is defaultColorOptionsLightBg. defaultOutputOptionsLightBg :: OutputOptions -- | Default values for OutputOptions when printing using using ANSI -- escape sequences for color. outputOptionsIndentAmount is 4, and -- outputOptionsColorOptions is Nothing. defaultOutputOptionsNoColor :: OutputOptions -- | Given OutputOptions, disable colorful output if the given -- handle is not connected to a TTY. hCheckTTY :: MonadIO m => Handle -> OutputOptions -> m OutputOptions -- | Given OutputOptions and a list of Output, turn the -- Output into a lazy Text. render :: OutputOptions -> [Output] -> Text -- | Render a single Output as a Builder, using the options -- specified in the OutputOptions. renderOutput :: MonadReader OutputOptions m => Output -> m Builder -- | Replace non-printable characters with hex escape sequences. -- --
--   >>> escapeNonPrintable "\x1\x2"
--   "\\x1\\x2"
--   
-- -- Newlines will not be escaped. -- --
--   >>> escapeNonPrintable "hello\nworld"
--   "hello\nworld"
--   
-- -- Printable characters will not be escaped. -- --
--   >>> escapeNonPrintable "h\101llo"
--   "hello"
--   
escapeNonPrintable :: String -> String escape :: Char -> ShowS -- |
--   >>> indentSubsequentLinesWith "  " "aaa"
--   "aaa"
--   
-- --
--   >>> indentSubsequentLinesWith "  " "aaa\nbbb\nccc"
--   "aaa\n  bbb\n  ccc"
--   
-- --
--   >>> indentSubsequentLinesWith "  " ""
--   ""
--   
indentSubsequentLinesWith :: String -> String -> String -- | Produce a Builder corresponding to the ANSI escape sequence for -- the color for the ", based on whether or not -- outputOptionsColorOptions is Just or Nothing, and -- the value of colorQuote. useColorQuote :: forall m. MonadReader OutputOptions m => m Builder -- | Produce a Builder corresponding to the ANSI escape sequence for -- the color for the characters of a string, based on whether or not -- outputOptionsColorOptions is Just or Nothing, and -- the value of colorString. useColorString :: forall m. MonadReader OutputOptions m => m Builder useColorError :: forall m. MonadReader OutputOptions m => m Builder useColorNum :: forall m. MonadReader OutputOptions m => m Builder -- | Produce a Builder corresponding to the ANSI escape sequence for -- resetting the console color back to the default. Produces an empty -- Builder if outputOptionsColorOptions is Nothing. useColorReset :: forall m. MonadReader OutputOptions m => m Builder -- | Produce a Builder representing the ANSI escape sequence for the -- color of the rainbow parenthesis, given an input NestLevel and -- Builder to use as the input character. -- -- If outputOptionsColorOptions is Nothing, then just -- return the input character. If it is Just, then return the -- input character colorized. renderRainbowParenFor :: MonadReader OutputOptions m => NestLevel -> Builder -> m Builder useColorRainbowParens :: forall m. MonadReader OutputOptions m => NestLevel -> m Builder -- | This is simply fmap fold . -- sequence. sequenceFold :: (Monad f, Monoid a, Traversable t) => t (f a) -> f a -- | A function that performs optimizations and modifications to a list of -- input Outputs. -- -- An sample of an optimization is removeStartingNewLine which -- just removes a newline if it is the first item in an Output -- list. modificationsOutputList :: [Output] -> [Output] -- | Remove a OutputNewLine if it is the first item in the -- Output list. -- --
--   >>> removeStartingNewLine [Output 3 OutputNewLine, Output 3 OutputComma]
--   [Output {outputNestLevel = NestLevel {unNestLevel = 3}, outputOutputType = OutputComma}]
--   
removeStartingNewLine :: [Output] -> [Output] -- | Remove trailing spaces from the end of a OutputOther token if -- it is followed by a OutputNewLine, or if it is the final -- Output in the list. This function assumes that there is a -- single OutputOther before any OutputNewLine (and before -- the end of the list), so it must be run after running -- compressOthers. -- --
--   >>> removeTrailingSpacesInOtherBeforeNewLine [Output 2 (OutputOther "foo  "), Output 4 OutputNewLine]
--   [Output {outputNestLevel = NestLevel {unNestLevel = 2}, outputOutputType = OutputOther "foo"},Output {outputNestLevel = NestLevel {unNestLevel = 4}, outputOutputType = OutputNewLine}]
--   
removeTrailingSpacesInOtherBeforeNewLine :: [Output] -> [Output] -- | If there are two subsequent OutputOther tokens, combine them -- into just one OutputOther. -- --
--   >>> compressOthers [Output 0 (OutputOther "foo"), Output 0 (OutputOther "bar")]
--   [Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputOther "foobar"}]
--   
compressOthers :: [Output] -> [Output] -- | In each OutputOther token, compress multiple whitespaces to -- just one whitespace. -- --
--   >>> shrinkWhitespaceInOthers [Output 0 (OutputOther "  hello  ")]
--   [Output {outputNestLevel = NestLevel {unNestLevel = 0}, outputOutputType = OutputOther " hello "}]
--   
shrinkWhitespaceInOthers :: [Output] -> [Output] shrinkWhitespaceInOther :: Output -> Output shrinkWhitespace :: String -> String instance GHC.Show.Show Text.Pretty.Simple.Internal.OutputPrinter.OutputOptions instance GHC.Generics.Generic Text.Pretty.Simple.Internal.OutputPrinter.OutputOptions instance GHC.Classes.Eq Text.Pretty.Simple.Internal.OutputPrinter.OutputOptions instance GHC.Show.Show Text.Pretty.Simple.Internal.OutputPrinter.CheckColorTty instance GHC.Generics.Generic Text.Pretty.Simple.Internal.OutputPrinter.CheckColorTty instance GHC.Classes.Eq Text.Pretty.Simple.Internal.OutputPrinter.CheckColorTty module Text.Pretty.Simple.Internal -- | This module contains the functions pPrint, pShow, and -- pString for pretty-printing any Haskell data type with a -- Show instance. -- -- pPrint is the main go-to function when debugging Haskell code. -- pShow and pString are slight variations on -- pPrint. -- -- pPrint, pShow, and pString will pretty-print in -- color using ANSI escape codes. They look good on a console with a dark -- (black) background. The variations pPrintLightBg, -- pShowLightBg, and pStringLightBg are for printing in -- color to a console with a light (white) background. The variations -- pPrintNoColor, pShowNoColor, and pStringNoColor -- are for pretty-printing without using color. -- -- pPrint and pPrintLightBg will intelligently decide -- whether or not to use ANSI escape codes for coloring depending on -- whether or not the output is a TTY. This works in most cases. If you -- want to force color output, you can use the pPrintForceColor or -- pPrintForceColorLightBg functions. -- -- The variations pPrintOpt, pShowOpt, and -- pStringOpt are used when specifying the OutputOptions. -- Most users can ignore these. -- -- There are a few other functions available that are similar to -- pPrint. -- -- See the Examples section at the end of this module for examples of -- acutally using pPrint. See the README.md for examples of -- printing in color. module Text.Pretty.Simple -- | Pretty-print any data type that has a Show instance. -- -- If you've never seen MonadIO before, you can think of this -- function as having the following type signature: -- --
--   pPrint :: Show a => a -> IO ()
--   
-- -- This function will only use colors if it detects it's printing to a -- TTY. -- -- This function is for printing to a dark background. Use -- pPrintLightBg for printing to a terminal with a light -- background. Different colors are used. -- -- Prints to stdout. Use pHPrint to print to a different -- Handle. -- --
--   >>> pPrint [Just (1, "hello")]
--   [ Just
--       ( 1
--       , "hello"
--       )
--   ]
--   
pPrint :: (MonadIO m, Show a) => a -> m () -- | Similar to pPrint, but take a Handle to print to. -- --
--   >>> pHPrint stdout [Just (1, "hello")]
--   [ Just
--       ( 1
--       , "hello"
--       )
--   ]
--   
pHPrint :: (MonadIO m, Show a) => Handle -> a -> m () -- | Similar to pPrint, but the first argument is a String -- representing a data type that has already been showed. -- --
--   >>> pPrintString $ show [ Just (1, "hello"), Nothing ]
--   [ Just
--       ( 1
--       , "hello"
--       )
--   , Nothing
--   ]
--   
pPrintString :: MonadIO m => String -> m () -- | Similar to pHPrintString, but take a Handle to print to. -- --
--   >>> pHPrintString stdout $ show [ Just (1, "hello"), Nothing ]
--   [ Just
--       ( 1
--       , "hello"
--       )
--   , Nothing
--   ]
--   
pHPrintString :: MonadIO m => Handle -> String -> m () -- | Similar to pPrint, but print in color regardless of whether the -- output goes to a TTY or not. -- -- See pPrint for an example of how to use this function. pPrintForceColor :: (MonadIO m, Show a) => a -> m () -- | Similar to pPrintForceColor, but take a Handle to print -- to. -- -- See pHPrint for an example of how to use this function. pHPrintForceColor :: (MonadIO m, Show a) => Handle -> a -> m () -- | Similar to pPrintString, but print in color regardless of -- whether the output goes to a TTY or not. -- -- See pPrintString for an example of how to use this function. pPrintStringForceColor :: MonadIO m => String -> m () -- | Similar to pHPrintString, but print in color regardless of -- whether the output goes to a TTY or not. -- -- See pHPrintString for an example of how to use this function. pHPrintStringForceColor :: MonadIO m => Handle -> String -> m () -- | Similar to pPrintForceColor, but just return the resulting -- pretty-printed data type as a Text instead of printing it to -- the screen. -- -- This function is for printing to a dark background. -- -- See pShowNoColor for an example of how to use this function. pShow :: Show a => a -> Text -- | Similar to pShow, but the first argument is a String -- representing a data type that has already been showed. -- -- This will work on any String that is similar to a Haskell data -- type. The only requirement is that the strings are quoted, and braces, -- parentheses, and brackets are correctly used to represent indentation. -- For example, pString will correctly pretty-print JSON. -- -- This function is for printing to a dark background. -- -- See pStringNoColor for an example of how to use this function. pString :: String -> Text -- | Alias for pPrint. pPrintDarkBg :: (MonadIO m, Show a) => a -> m () -- | Alias for pHPrint. pHPrintDarkBg :: (MonadIO m, Show a) => Handle -> a -> m () -- | Alias for pPrintString. pPrintStringDarkBg :: MonadIO m => String -> m () -- | Alias for pHPrintString. pHPrintStringDarkBg :: MonadIO m => Handle -> String -> m () -- | Alias for pPrintForceColor. pPrintForceColorDarkBg :: (MonadIO m, Show a) => a -> m () -- | Alias for pHPrintForceColor. pHPrintForceColorDarkBg :: (MonadIO m, Show a) => Handle -> a -> m () -- | Alias for pPrintStringForceColor. pPrintStringForceColorDarkBg :: MonadIO m => String -> m () -- | Alias for pHPrintStringForceColor. pHPrintStringForceColorDarkBg :: MonadIO m => Handle -> String -> m () -- | Alias for pShow. pShowDarkBg :: Show a => a -> Text -- | Alias for pString. pStringDarkBg :: String -> Text -- | Just like pPrintDarkBg, but for printing to a light background. pPrintLightBg :: (MonadIO m, Show a) => a -> m () -- | Just like pHPrintDarkBg, but for printing to a light -- background. pHPrintLightBg :: (MonadIO m, Show a) => Handle -> a -> m () -- | Just like pPrintStringDarkBg, but for printing to a light -- background. pPrintStringLightBg :: MonadIO m => String -> m () -- | Just like pHPrintStringDarkBg, but for printing to a light -- background. pHPrintStringLightBg :: MonadIO m => Handle -> String -> m () -- | Just like pPrintForceColorDarkBg, but for printing to a light -- background. pPrintForceColorLightBg :: (MonadIO m, Show a) => a -> m () -- | Just like pHPrintForceColorDarkBg, but for printing to a light -- background. pHPrintForceColorLightBg :: (MonadIO m, Show a) => Handle -> a -> m () -- | Just like pPrintStringForceColorDarkBg, but for printing to a -- light background. pPrintStringForceColorLightBg :: MonadIO m => String -> m () -- | Just like pHPrintStringForceColorDarkBg, but for printing to a -- light background. pHPrintStringForceColorLightBg :: MonadIO m => Handle -> String -> m () -- | Just like pShowDarkBg, but for printing to a light background. pShowLightBg :: Show a => a -> Text -- | Just like pStringDarkBg, but for printing to a light -- background. pStringLightBg :: String -> Text -- | Similar to pPrint, but doesn't print in color. However, data -- types will still be indented nicely. -- --
--   >>> pPrintNoColor $ Just ["hello", "bye"]
--   Just
--       [ "hello"
--       , "bye"
--       ]
--   
pPrintNoColor :: (MonadIO m, Show a) => a -> m () -- | Like pPrintNoColor, but take a Handle to determine where -- to print to. -- --
--   >>> pHPrintNoColor stdout $ Just ["hello", "bye"]
--   Just
--       [ "hello"
--       , "bye"
--       ]
--   
pHPrintNoColor :: (MonadIO m, Show a) => Handle -> a -> m () -- | Similar to pPrintString, but doesn't print in color. However, -- data types will still be indented nicely. -- --
--   >>> pPrintStringNoColor $ show $ Just ["hello", "bye"]
--   Just
--       [ "hello"
--       , "bye"
--       ]
--   
pPrintStringNoColor :: MonadIO m => String -> m () -- | Like pPrintStringNoColor, but take a Handle to determine -- where to print to. -- --
--   >>> pHPrintStringNoColor stdout $ show $ Just ["hello", "bye"]
--   Just
--       [ "hello"
--       , "bye"
--       ]
--   
pHPrintStringNoColor :: MonadIO m => Handle -> String -> m () -- | Like pShow, but without color. -- --
--   >>> pShowNoColor [ Nothing, Just (1, "hello") ]
--   "[ Nothing\n, Just\n    ( 1\n    , \"hello\"\n    )\n]"
--   
pShowNoColor :: Show a => a -> Text -- | LIke pString, but without color. -- --
--   >>> pStringNoColor $ show [1, 2, 3]
--   "[ 1\n, 2\n, 3\n]"
--   
pStringNoColor :: String -> Text -- | Similar to pPrint but takes OutputOptions to change how -- the pretty-printing is done. -- -- For example, pPrintOpt can be used to make the indentation much -- smaller than normal. -- -- This is what the normal indentation looks like: -- --
--   >>> pPrintOpt NoCheckColorTty defaultOutputOptionsNoColor $ Just ("hello", "bye")
--   Just
--       ( "hello"
--       , "bye"
--       )
--   
-- -- This is what smaller indentation looks like: -- --
--   >>> let smallIndent = defaultOutputOptionsNoColor {outputOptionsIndentAmount = 1}
--   
--   >>> pPrintOpt CheckColorTty smallIndent $ Just ("hello", "bye")
--   Just
--    ( "hello"
--    , "bye"
--    )
--   
-- -- Lines in strings get indented -- --
--   >>> pPrintOpt NoCheckColorTty defaultOutputOptionsNoColor (1, (2, "foo\nbar\nbaz", 3))
--   ( 1
--   ,
--       ( 2
--       , "foo
--         bar
--         baz"
--       , 3
--       )
--   )
--   
-- -- Lines get indented even in custom show instances -- --
--   >>> data Foo = Foo
--   
--   >>> instance Show Foo where show _ = "foo\nbar\nbaz"
--   
--   >>> pPrintOpt CheckColorTty defaultOutputOptionsNoColor (1, (2, Foo, 3))
--   ( 1
--   ,
--       ( 2
--       , foo
--         bar
--         baz
--       , 3
--       )
--   )
--   
-- -- CheckColorTty determines whether to test stdout for -- whether or not it is connected to a TTY. -- -- If set to NoCheckColorTty, then pPrintOpt won't check if -- stdout is a TTY. It will print in color depending on the value -- of outputOptionsColorOptions. -- -- If set to CheckColorTty, then pPrintOpt will check if -- stdout is conneted to a TTY. If stdout is determined to -- be connected to a TTY, then it will print in color depending on the -- value of outputOptionsColorOptions. If stdout is -- determined to NOT be connected to a TTY, then it will NOT print in -- color, regardless of the value of outputOptionsColorOptions. pPrintOpt :: (MonadIO m, Show a) => CheckColorTty -> OutputOptions -> a -> m () -- | Similar to pPrintOpt, but take a Handle to determine -- where to print to. pHPrintOpt :: (MonadIO m, Show a) => CheckColorTty -> OutputOptions -> Handle -> a -> m () -- | Similar to pPrintOpt, but the last argument is a string -- representing a data structure that has already been showed. -- --
--   >>> let foo = show (1, (2, "hello", 3))
--   
--   >>> pPrintStringOpt CheckColorTty defaultOutputOptionsNoColor foo
--   ( 1
--   ,
--       ( 2
--       , "hello"
--       , 3
--       )
--   )
--   
pPrintStringOpt :: MonadIO m => CheckColorTty -> OutputOptions -> String -> m () -- | Similar to pPrintStringOpt, but take a Handle to -- determine where to print to. -- --
--   >>> let foo = show (1, (2, "hello", 3))
--   
--   >>> pHPrintStringOpt CheckColorTty defaultOutputOptionsNoColor stdout foo
--   ( 1
--   ,
--       ( 2
--       , "hello"
--       , 3
--       )
--   )
--   
pHPrintStringOpt :: MonadIO m => CheckColorTty -> OutputOptions -> Handle -> String -> m () -- | Like pShow but takes OutputOptions to change how the -- pretty-printing is done. pShowOpt :: Show a => OutputOptions -> a -> Text -- | Like pString but takes OutputOptions to change how the -- pretty-printing is done. pStringOpt :: OutputOptions -> String -> Text -- | Data-type wrapping up all the options available when rendering the -- list of Outputs. data OutputOptions OutputOptions :: Int -> Maybe ColorOptions -> Bool -> OutputOptions -- | Number of spaces to use when indenting. It should probably be either 2 -- or 4. [outputOptionsIndentAmount] :: OutputOptions -> Int -- | If this is Nothing, then don't colorize the output. If this is -- Just colorOptions, then use colorOptions to -- colorize the output. [outputOptionsColorOptions] :: OutputOptions -> Maybe ColorOptions -- | Whether to replace non-printable characters with hexadecimal escape -- sequences. [outputOptionsEscapeNonPrintable] :: OutputOptions -> Bool -- | Default values for OutputOptions when printing to a console -- with a dark background. outputOptionsIndentAmount is 4, and -- outputOptionsColorOptions is defaultColorOptionsDarkBg. defaultOutputOptionsDarkBg :: OutputOptions -- | Default values for OutputOptions when printing to a console -- with a light background. outputOptionsIndentAmount is 4, and -- outputOptionsColorOptions is defaultColorOptionsLightBg. defaultOutputOptionsLightBg :: OutputOptions -- | Default values for OutputOptions when printing using using ANSI -- escape sequences for color. outputOptionsIndentAmount is 4, and -- outputOptionsColorOptions is Nothing. defaultOutputOptionsNoColor :: OutputOptions -- | Determines whether pretty-simple should check if the output -- Handle is a TTY device. Normally, users only want to print in -- color if the output Handle is a TTY device. data CheckColorTty -- | Check if the output Handle is a TTY device. If the output -- Handle is a TTY device, determine whether to print in color -- based on outputOptionsColorOptions. If not, then set -- outputOptionsColorOptions to Nothing so the output does -- not get colorized. CheckColorTty :: CheckColorTty -- | Don't check if the output Handle is a TTY device. Determine -- whether to colorize the output based solely on the value of -- outputOptionsColorOptions. NoCheckColorTty :: CheckColorTty -- | Default color options for use on a dark background. -- -- colorQuote is defaultColorQuoteDarkBg. -- colorString is defaultColorStringDarkBg. -- colorError is defaultColorErrorDarkBg. colorNum -- is defaultColorNumDarkBg. colorRainbowParens is -- defaultColorRainboxParensDarkBg. defaultColorOptionsDarkBg :: ColorOptions -- | Default color options for use on a light background. -- -- colorQuote is defaultColorQuoteLightBg. -- colorString is defaultColorStringLightBg. -- colorError is defaultColorErrorLightBg. colorNum -- is defaultColorNumLightBg. colorRainbowParens is -- defaultColorRainboxParensLightBg. defaultColorOptionsLightBg :: ColorOptions -- | This module contains the same functionality with Prelude's -- Debug.Trace module, with pretty printing the debug strings. -- -- Warning: This module also shares the same unsafety of -- Debug.Trace module. module Debug.Pretty.Simple -- | The pTrace function pretty prints the trace message given as -- its first argument, before returning the second argument as its -- result. -- -- For example, this returns the value of f x but first outputs -- the message. -- --
--   pTrace ("calling f with x = " ++ show x) (f x)
--   
-- -- The pTrace function should only be used for debugging, -- or for monitoring execution. The function is not referentially -- transparent: its type indicates that it is a pure function but it has -- the side effect of outputting the trace message. pTrace :: String -> a -> a -- | Like pTrace but returns the message instead of a third value. pTraceId :: String -> String -- | Like pTrace, but uses show on the argument to convert it -- to a String. -- -- This makes it convenient for printing the values of interesting -- variables or expressions inside a function. For example here we print -- the value of the variables x and z: -- --
--   f x y =
--       pTraceShow (x, z) $ result
--     where
--       z = ...
--       ...
--   
pTraceShow :: Show a => a -> b -> b -- | Like pTraceShow but returns the shown value instead of a third -- value. pTraceShowId :: Show a => a -> a -- | The pTraceIO function outputs the trace message from the IO -- monad. This sequences the output with respect to other IO actions. pTraceIO :: String -> IO () -- | Like pTrace but returning unit in an arbitrary -- Applicative context. Allows for convenient use in do-notation. -- -- Note that the application of pTraceM is not an action in the -- Applicative context, as pTraceIO is in the IO -- type. While the fresh bindings in the following example will force the -- traceM expressions to be reduced every time the -- do-block is executed, traceM "not crashed" would -- only be reduced once, and the message would only be printed once. If -- your monad is in MonadIO, liftIO . pTraceIO may be a -- better option. -- --
--   ... = do
--     x <- ...
--     pTraceM $ "x: " ++ show x
--     y <- ...
--     pTraceM $ "y: " ++ show y
--   
pTraceM :: Applicative f => String -> f () -- | Like pTraceM, but uses show on the argument to convert -- it to a String. -- --
--   ... = do
--     x <- ...
--     pTraceShowM $ x
--     y <- ...
--     pTraceShowM $ x + y
--   
pTraceShowM :: (Show a, Applicative f) => a -> f () -- | like pTrace, but additionally prints a call stack if one is -- available. -- -- In the current GHC implementation, the call stack is only available if -- the program was compiled with -prof; otherwise -- pTraceStack behaves exactly like pTrace. Entries in the -- call stack correspond to SCC annotations, so it is a good -- idea to use -fprof-auto or -fprof-auto-calls to add -- SCC annotations automatically. pTraceStack :: String -> a -> a -- | The pTraceEvent function behaves like trace with the -- difference that the message is emitted to the eventlog, if eventlog -- profiling is available and enabled at runtime. -- -- It is suitable for use in pure code. In an IO context use -- pTraceEventIO instead. -- -- Note that when using GHC's SMP runtime, it is possible (but rare) to -- get duplicate events emitted if two CPUs simultaneously evaluate the -- same thunk that uses pTraceEvent. pTraceEvent :: String -> a -> a -- | The pTraceEventIO function emits a message to the eventlog, if -- eventlog profiling is available and enabled at runtime. -- -- Compared to pTraceEvent, pTraceEventIO sequences the -- event with respect to other IO actions. pTraceEventIO :: String -> IO () -- | The pTraceMarker function emits a marker to the eventlog, if -- eventlog profiling is available and enabled at runtime. The -- String is the name of the marker. The name is just used in -- the profiling tools to help you keep clear which marker is which. -- -- This function is suitable for use in pure code. In an IO context use -- pTraceMarkerIO instead. -- -- Note that when using GHC's SMP runtime, it is possible (but rare) to -- get duplicate events emitted if two CPUs simultaneously evaluate the -- same thunk that uses pTraceMarker. pTraceMarker :: String -> a -> a -- | The pTraceMarkerIO function emits a marker to the eventlog, if -- eventlog profiling is available and enabled at runtime. -- -- Compared to pTraceMarker, pTraceMarkerIO sequences the -- event with respect to other IO actions. pTraceMarkerIO :: String -> IO () -- | Similar to pTrace, but forcing color. pTraceForceColor :: String -> a -> a -- | Similar to pTraceId, but forcing color. pTraceIdForceColor :: String -> String -- | Similar to pTraceShow, but forcing color. pTraceShowForceColor :: Show a => a -> b -> b -- | Similar to pTraceShowId, but forcing color. pTraceShowIdForceColor :: Show a => a -> a -- | Similar to pTraceM, but forcing color. pTraceMForceColor :: Applicative f => String -> f () -- | Similar to pTraceShowM, but forcing color. pTraceShowMForceColor :: (Show a, Applicative f) => a -> f () -- | Similar to pTraceStack, but forcing color. pTraceStackForceColor :: String -> a -> a -- | Similar to pTraceEvent, but forcing color. pTraceEventForceColor :: String -> a -> a -- | Similar to pTraceEventIO, but forcing color. pTraceEventIOForceColor :: String -> IO () -- | Similar to pTraceMarker, but forcing color. pTraceMarkerForceColor :: String -> a -> a -- | Similar to pTraceMarkerIO, but forcing color. pTraceMarkerIOForceColor :: String -> IO () -- | Similar to pTraceIO, but forcing color. pTraceIOForceColor :: String -> IO () -- | Similar to pTrace, but without color. -- --
--   >>> pTraceNoColor "wow" ()
--   wow
--   ()
--   
pTraceNoColor :: String -> a -> a -- | Similar to pTraceId, but without color. -- --
--   >>> pTraceIdNoColor "(1, 2, 3)" `seq` ()
--   ( 1
--   , 2
--   , 3
--   )
--   ()
--   
pTraceIdNoColor :: String -> String -- | Similar to pTraceShow, but without color. -- --
--   >>> import qualified Data.Map as M
--   
--   >>> pTraceShowNoColor (M.fromList [(1, True)]) ()
--   fromList
--       [
--           ( 1
--           , True
--           )
--       ]
--   ()
--   
pTraceShowNoColor :: Show a => a -> b -> b -- | Similar to pTraceShowId, but without color. -- --
--   >>> import qualified Data.Map as M
--   
--   >>> pTraceShowIdNoColor (M.fromList [(1, True)]) `seq` ()
--   fromList
--       [
--           ( 1
--           , True
--           )
--       ]
--   ()
--   
pTraceShowIdNoColor :: Show a => a -> a -- | Similar to pTraceM, but without color. -- --
--   >>> pTraceMNoColor "wow"
--   wow
--   
pTraceMNoColor :: Applicative f => String -> f () -- | Similar to pTraceShowM, but without color. -- --
--   >>> pTraceShowMNoColor [1,2,3]
--   [ 1
--   , 2
--   , 3
--   ]
--   
pTraceShowMNoColor :: (Show a, Applicative f) => a -> f () -- | Similar to pTraceStack, but without color. -- --
--   >>> pTraceStackNoColor "wow" () `seq` ()
--   wow
--   ()
--   
pTraceStackNoColor :: String -> a -> a -- | Similar to pTraceEvent, but without color. pTraceEventNoColor :: String -> a -> a -- | Similar to pTraceEventIO, but without color. pTraceEventIONoColor :: String -> IO () -- | Similar to pTraceMarker, but without color. pTraceMarkerNoColor :: String -> a -> a -- | Similar to pTraceMarkerIO, but without color. pTraceMarkerIONoColor :: String -> IO () -- | Similar to pTraceIO, but without color. -- --
--   >>> pTraceIONoColor "(1, 2, 3)"
--   ( 1
--   , 2
--   , 3
--   )
--   
pTraceIONoColor :: String -> IO () -- | Like pTrace but takes OutputOptions. pTraceOpt :: CheckColorTty -> OutputOptions -> String -> a -> a -- | Like pTraceId but takes OutputOptions. pTraceIdOpt :: CheckColorTty -> OutputOptions -> String -> String -- | Like pTraceShow but takes OutputOptions. pTraceShowOpt :: Show a => CheckColorTty -> OutputOptions -> a -> b -> b -- | Like pTraceShowId but takes OutputOptions. pTraceShowIdOpt :: Show a => CheckColorTty -> OutputOptions -> a -> a -- | Like pTraceIO but takes OutputOptions. pTraceOptIO :: CheckColorTty -> OutputOptions -> String -> IO () -- | Like pTraceM but takes OutputOptions. pTraceOptM :: Applicative f => CheckColorTty -> OutputOptions -> String -> f () -- | Like pTraceShowM but takes OutputOptions. pTraceShowOptM :: (Show a, Applicative f) => CheckColorTty -> OutputOptions -> a -> f () -- | Like pTraceStack but takes OutputOptions. pTraceStackOpt :: CheckColorTty -> OutputOptions -> String -> a -> a -- | Like pTraceEvent but takes OutputOptions. pTraceEventOpt :: CheckColorTty -> OutputOptions -> String -> a -> a -- | Like pTraceEventIO but takes OutputOptions. pTraceEventOptIO :: CheckColorTty -> OutputOptions -> String -> IO () -- | Like pTraceMarker but takes OutputOptions. pTraceMarkerOpt :: CheckColorTty -> OutputOptions -> String -> a -> a -- | Like pTraceMarkerIO but takes OutputOptions. pTraceMarkerOptIO :: CheckColorTty -> OutputOptions -> String -> IO ()