on master help sign in
Improve error pretty-printing
commit3e401fb90466f272b671678caef289f5818a795f authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateTue 11 Mar 2014, 14:07 (13 years ago) parenta23e89f
2 files changed+8−7
src/Idris/AbsSyntax.hs+5−4 src/Idris/Delaborate.hs+3−3
src/Idris/AbsSyntax.hs+5−4
@@ -641,13 +641,14 @@ isetPrompt p = do i <- getIState
641641
642642ihWarn :: Handle -> FC -> Doc OutputAnnotation -> Idris ()
643643ihWarn h fc err = do i <- getIState
644− err' <- iRender . fmap (fancifyAnnots i) $ err
645644 case idris_outputmode i of
646645 RawOutput ->
647− runIO $
648− hPutStrLn h (show fc ++ ":" ++ displayDecorated (consoleDecorate i) err')
646+ do err' <- iRender . fmap (fancifyAnnots i) $
647+ text (show fc) <> colon <//> err
648+ runIO . hPutStrLn h $ displayDecorated (consoleDecorate i) err'
649649 IdeSlave n ->
650− do let (str, spans) = displaySpans err'
650+ do err' <- iRender . fmap (fancifyAnnots i) $ err
651+ let (str, spans) = displaySpans err'
651652 runIO . hPutStrLn h $
652653 convSExp "warning" (fc_fname fc, fc_line fc, fc_column fc, str, spans) n
653654
src/Idris/Delaborate.hs+3−3
@@ -220,13 +220,13 @@ pprintErr' i (Elaborating s n e) = text "When elaborating" <+> text s <>
220220pprintErr' i (ProviderError msg) = text ("Type provider error: " ++ msg)
221221pprintErr' i (LoadingFailed fn e) = text "Loading" <+> text fn <+> text "failed:" <+> pprintErr' i e
222222pprintErr' i (ReflectionError parts orig) =
223− let parts' = map (hsep . map showPart) parts in
224− vsep parts' <>
223+ let parts' = map (fillSep . map showPart) parts in
224+ align (fillSep parts') <>
225225 if (opt_origerr (idris_options i))
226226 then line <> line <> text "Original error:" <$> indented (pprintErr' i orig)
227227 else empty
228228 where showPart :: ErrorReportPart -> Doc OutputAnnotation
229− showPart (TextPart str) = text str
229+ showPart (TextPart str) = fillSep . map text . words $ str
230230 showPart (NamePart n) = annName n
231231 showPart (TermPart tm) = pprintTerm i (delab i tm)
232232 showPart (SubReport rs) = indented . hsep . map showPart $ rs