1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Warning where
5import Data.Aeson ((.=))
6import qualified Data.Aeson as Json
7import qualified Text.PrettyPrint as P
8import Text.PrettyPrint ((<+>))
10import qualified AST.Module as Module
11import qualified AST.Type as Type
12import qualified Reporting.Annotation as A
13import qualified Reporting.PrettyPrint as P
14import qualified Reporting.Report as Report
17-- ALL POSSIBLE WARNINGS
20 = UnusedImport Module.Name
21 | MissingTypeAnnotation String Type.Canonical
26toString :: P.Dealiaser -> String -> String -> A.Located Warning -> String
27toString dealiaser location source (A.A region warning) =
28 Report.toString location region (toReport dealiaser warning) source
31print :: P.Dealiaser -> String -> String -> A.Located Warning -> IO ()
32print dealiaser location source (A.A region warning) =
33 Report.printWarning location region (toReport dealiaser warning) source
36toReport :: P.Dealiaser -> Warning -> Report.Report
37toReport dealiaser warning =
39 UnusedImport moduleName ->
42 ("Module `" ++ Module.nameToString moduleName ++ "` is unused.")
45 MissingTypeAnnotation name inferredType ->
47 "missing type annotation"
48 ("Top-level value `" ++ name ++ "` does not have a type annotation.")
49 ( "The type annotation you want looks something like this:\n\n"
50 ++ P.render (P.nest 4 typeDoc)
55 (P.text name <+> P.colon)
57 (P.pretty dealiaser False inferredType)
62toJson :: P.Dealiaser -> FilePath -> A.Located Warning -> Json.Value
63toJson dealiaser filePath (A.A region warning) =
65 (maybeRegion, additionalFields) =
66 Report.toJson [] (toReport dealiaser warning)
70 , "region" .= maybe region id maybeRegion
71 , "type" .= ("warning" :: String)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list