@@ -1,9 +1,48 @@
1module Reporting.Warning where
1module Reporting.Warning where
3+import qualified Text.PrettyPrint as P
4+import Text.PrettyPrint ((<+>))
3import qualified AST.Module as Module
6import qualified AST.Module as Module
4import qualified AST.Type as Type
7import qualified AST.Type as Type
8+import qualified Reporting.Annotation as A
9+import qualified Reporting.PrettyPrint as P
10+import qualified Reporting.Report as Report
13+-- ALL POSSIBLE WARNINGS
7data Warning
15data Warning
8 = UnusedImport Module.Name
16 = UnusedImport Module.Name
9 | MissingTypeAnnotation String Type.Canonical
17 | MissingTypeAnnotation String Type.Canonical
22+toString :: String -> String -> A.Located Warning -> String
23+toString location source (A.A region warning) =
24+ Report.toString location region (toReport warning) source
27+toReport :: Warning -> Report.Report
30+ UnusedImport moduleName ->
33+ ("Module '" ++ Module.nameToString moduleName ++ "' is unused.")
36+ MissingTypeAnnotation name inferredType ->
39+ ("Top-level value '" ++ name ++ "' does not have a type annotation.")
40+ ( "The type annotation you want looks something like this:\n\n"
41+ ++ P.render (P.nest 4 typeDoc)
46+ (P.text name <+> P.colon)
48+ (P.pretty False inferredType)