@@ -14,7 +14,7 @@ module Idris.Output (clearHighlights, emit, idemodePutSExp, iPrintError, iPrintF
1414 iRender, iRenderError, iRenderOutput, iRenderResult, iWarn,
1515 prettyDocumentedIst, printUndefinedNames, pshow, renderExternal,
1616 sendHighlighting, sendParserHighlighting, warnTotality,
17− writeHighlights, OutputDoc(..), Warning(..)) where
17+ writeHighlights, OutputDoc(..), Message(..)) where
1818
1919import Idris.AbsSyntax
2020import Idris.Colours (hEndColourise, hStartColourise)
@@ -53,30 +53,30 @@ pshow ist err = displayDecorated (consoleDecorate ist) .
5353
5454type OutputDoc = Doc OutputAnnotation
5555
56−class Warning a where
57− warningExtent :: a -> FC
58− warningMessage :: a -> OutputDoc
59− warningSource :: a -> Maybe String
56+class Message a where
57+ messageExtent :: a -> FC
58+ messageText :: a -> OutputDoc
59+ messageSource :: a -> Maybe String
6060
6161data Ann = AText String | ATagged OutputAnnotation Ann | ASplit Ann Ann
6262
6363data Hack = Hack FC OutputDoc
64−instance Warning Hack where
65− warningExtent (Hack extent _) = extent
66− warningMessage (Hack _ msg) = msg
67− warningSource _ = Nothing
64+instance Message Hack where
65+ messageExtent (Hack extent _) = extent
66+ messageText (Hack _ msg) = msg
67+ messageSource _ = Nothing
6868
69−formatWarning :: Warning w => w -> Idris OutputDoc
70−formatWarning w = do
69+formatMessage :: Message w => w -> Idris OutputDoc
70+formatMessage w = do
7171 i <- getIState
72− maybeSource <- case warningSource w of
72+ maybeSource <- case messageSource w of
7373 Just src -> pure (Just src)
7474 Nothing -> readSource fc
7575 let maybeFormattedSource = maybeSource >>= layoutSource fc (idris_highlightedRegions i)
76− return $ layoutWarning (layoutFC fc) maybeFormattedSource (warningMessage w)
76+ return $ layoutMessage (layoutFC fc) maybeFormattedSource (messageText w)
7777 where
7878 fc :: FC
79− fc = warningExtent w
79+ fc = messageExtent w
8080
8181 layoutFC :: FC -> OutputDoc
8282 layoutFC fc@(FC fn _ _) | fn /= "" = text (show $ fc) <> colon
@@ -168,24 +168,24 @@ formatWarning w = do
168168 source = line1 <$$> line2 <$$> line3
169169 layoutSource _ _ _ = Nothing
170170
171− layoutWarning :: OutputDoc -> Maybe OutputDoc -> OutputDoc -> OutputDoc
172− layoutWarning loc (Just src) err = loc <$$> src <$$> err <$$> empty
173− layoutWarning loc Nothing err = loc </> err
171+ layoutMessage :: OutputDoc -> Maybe OutputDoc -> OutputDoc -> OutputDoc
172+ layoutMessage loc (Just src) err = loc <$$> src <$$> err <$$> empty
173+ layoutMessage loc Nothing err = loc </> err
174174
175175iWarn :: FC -> OutputDoc -> Idris ()
176176iWarn fc err = emit $ Hack fc err
177177
178−emit :: Warning w => w -> Idris ()
178+emit :: Message w => w -> Idris ()
179179emit w =
180180 do i <- getIState
181181 case idris_outputmode i of
182182 RawOutput h ->
183− do formattedErr <- formatWarning w
183+ do formattedErr <- formatMessage w
184184 err' <- iRender . fmap (fancifyAnnots i True) $ formattedErr
185185 hWriteDoc h i err'
186186 IdeMode n h ->
187− do err' <- iRender . fmap (fancifyAnnots i True) $ warningMessage w
188− let fc = warningExtent w
187+ do err' <- iRender . fmap (fancifyAnnots i True) $ messageText w
188+ let fc = messageExtent w
189189 let (str, spans) = displaySpans err'
190190 runIO . hPutStrLn h $
191191 convSExp "warning" (fc_fname fc, fc_start fc, fc_end fc, str, spans) n