@@ -9,12 +9,12 @@ Maintainer : The Idris Community.
99{-# LANGUAGE FlexibleInstances #-}
1010{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
1111
12−module Idris.Output (clearHighlights, idemodePutSExp, iPrintError, iPrintFunTypes,
12+module Idris.Output (clearHighlights, emit, idemodePutSExp, iPrintError, iPrintFunTypes,
1313 iPrintResult, iPrintTermWithType, iputGoal, iputStr, iputStrLn,
1414 iRender, iRenderError, iRenderOutput, iRenderResult, iWarn,
1515 prettyDocumentedIst, printUndefinedNames, pshow, renderExternal,
1616 sendHighlighting, sendParserHighlighting, warnTotality,
17− writeHighlights) where
17+ writeHighlights, OutputDoc(..), Warning(..)) where
1818
1919import Idris.AbsSyntax
2020import Idris.Colours (hEndColourise, hStartColourise)
@@ -53,6 +53,10 @@ 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+
5660data Ann = AText String | ATagged OutputAnnotation Ann | ASplit Ann Ann
5761
5862iWarn :: FC -> OutputDoc -> Idris ()
@@ -165,6 +169,8 @@ iWarn fc err =
165169 layoutWarning loc (Just src) err = loc <$$> src <$$> err <$$> empty
166170 layoutWarning loc Nothing err = loc </> err
167171
172+emit :: Warning w => w -> Idris ()
173+emit w = iWarn (warningExtent w) (warningMessage w)
168174
169175iRender :: Doc a -> Idris (SimpleDoc a)
170176iRender d = do w <- getWidth