mirror of
https://github.com/github/semantic.git
synced 2024-12-21 05:41:54 +03:00
withSGRCode takes a ShowS.
This commit is contained in:
parent
aca843ed3f
commit
fa3407f045
@ -167,7 +167,7 @@ data ErrorCause symbol
|
|||||||
-- | Pretty-print an Error with reference to the source where it occurred.
|
-- | Pretty-print an Error with reference to the source where it occurred.
|
||||||
showError :: Show symbol => Source.Source -> Error symbol -> ShowS
|
showError :: Show symbol => Source.Source -> Error symbol -> ShowS
|
||||||
showError source Error{..}
|
showError source Error{..}
|
||||||
= showSourcePos errorPos . showString ": " . withSGRCode [SetColor Foreground Vivid Red] "error" . showString ": " . showExpectation . showChar '\n'
|
= showSourcePos errorPos . showString ": " . withSGRCode [SetColor Foreground Vivid Red] (showString "error") . showString ": " . showExpectation . showChar '\n'
|
||||||
. showString context -- actualLines results include line endings, so no newline here
|
. showString context -- actualLines results include line endings, so no newline here
|
||||||
. showString (replicate (succ (Info.column errorPos + lineNumberDigits)) ' ') . showChar '^' . showChar '\n'
|
. showString (replicate (succ (Info.column errorPos + lineNumberDigits)) ' ') . showChar '^' . showChar '\n'
|
||||||
. showString (prettyCallStack callStack) . showChar '\n'
|
. showString (prettyCallStack callStack) . showChar '\n'
|
||||||
@ -180,7 +180,7 @@ showError source Error{..}
|
|||||||
showLineNumber n = let s = show n in replicate (lineNumberDigits - length s) ' ' <> s
|
showLineNumber n = let s = show n in replicate (lineNumberDigits - length s) ' ' <> s
|
||||||
lineNumberDigits = succ (floor (logBase 10 (fromIntegral (Info.line errorPos) :: Double)))
|
lineNumberDigits = succ (floor (logBase 10 (fromIntegral (Info.line errorPos) :: Double)))
|
||||||
showSGRCode = showString . setSGRCode
|
showSGRCode = showString . setSGRCode
|
||||||
withSGRCode code string = showSGRCode code . showString string . showSGRCode []
|
withSGRCode code s = showSGRCode code . s . showSGRCode []
|
||||||
|
|
||||||
showSymbols :: Show symbol => [symbol] -> ShowS
|
showSymbols :: Show symbol => [symbol] -> ShowS
|
||||||
showSymbols [] = showString "end of input nodes"
|
showSymbols [] = showString "end of input nodes"
|
||||||
|
Loading…
Reference in New Issue
Block a user