diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-11-10 17:25:48 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-11-10 17:25:48 +0100 |
commit | f1b113b7de5b19647b0137cdd824bc0a37379ca8 (patch) | |
tree | b4055378fe48e8f443b02745f74b74ed75b32fce | |
parent | d1e956c1c3a12b3ca201d434e1d834f5ccf91fb9 (diff) |
export new listErrors & listWarnings API functions
-rw-r--r-- | src/LambdaCube/Compiler.hs | 2 | ||||
-rw-r--r-- | src/LambdaCube/Compiler/InferMonad.hs | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/LambdaCube/Compiler.hs b/src/LambdaCube/Compiler.hs index bc34a088..a61686ff 100644 --- a/src/LambdaCube/Compiler.hs +++ b/src/LambdaCube/Compiler.hs | |||
@@ -50,7 +50,7 @@ import LambdaCube.Compiler.CoreToIR | |||
50 | import LambdaCube.Compiler.Utils | 50 | import LambdaCube.Compiler.Utils |
51 | import LambdaCube.Compiler.DesugaredSource as Exported (FileInfo(..), Range(..), SPos(..), pattern SPos, SIName(..), pattern SIName, sName, SI(..)) | 51 | import LambdaCube.Compiler.DesugaredSource as Exported (FileInfo(..), Range(..), SPos(..), pattern SPos, SIName(..), pattern SIName, sName, SI(..)) |
52 | import LambdaCube.Compiler.Core as Exported (mkDoc, Exp, ExpType(..), pattern ET, outputType, boolType, trueExp, hnf) | 52 | import LambdaCube.Compiler.Core as Exported (mkDoc, Exp, ExpType(..), pattern ET, outputType, boolType, trueExp, hnf) |
53 | import LambdaCube.Compiler.InferMonad as Exported (errorRange, listAllInfos, listAllInfos', listTypeInfos, listTraceInfos, Infos, Info(..)) | 53 | import LambdaCube.Compiler.InferMonad as Exported (errorRange, listAllInfos, listAllInfos', listTypeInfos, listErrors, listWarnings, listTraceInfos, Infos, Info(..)) |
54 | --import LambdaCube.Compiler.Infer as Exported () | 54 | --import LambdaCube.Compiler.Infer as Exported () |
55 | 55 | ||
56 | -- inlcude path for: Builtins, Internals and Prelude | 56 | -- inlcude path for: Builtins, Internals and Prelude |
diff --git a/src/LambdaCube/Compiler/InferMonad.hs b/src/LambdaCube/Compiler/InferMonad.hs index 8d46f7c7..1905c839 100644 --- a/src/LambdaCube/Compiler/InferMonad.hs +++ b/src/LambdaCube/Compiler/InferMonad.hs | |||
@@ -30,7 +30,7 @@ import Control.Arrow hiding ((<+>)) | |||
30 | import LambdaCube.Compiler.DeBruijn | 30 | import LambdaCube.Compiler.DeBruijn |
31 | import LambdaCube.Compiler.Pretty hiding (braces, parens) | 31 | import LambdaCube.Compiler.Pretty hiding (braces, parens) |
32 | import LambdaCube.Compiler.DesugaredSource hiding (getList) | 32 | import LambdaCube.Compiler.DesugaredSource hiding (getList) |
33 | import LambdaCube.Compiler.Parser (ParseWarning) -- TODO: remove | 33 | import LambdaCube.Compiler.Parser (ParseWarning (..)) |
34 | import LambdaCube.Compiler.Core | 34 | import LambdaCube.Compiler.Core |
35 | 35 | ||
36 | -------------------------------------------------------------------------------- error messages | 36 | -------------------------------------------------------------------------------- error messages |
@@ -97,6 +97,13 @@ listAllInfos' f m | |||
97 | 97 | ||
98 | listTraceInfos m = [DResetFreshNames $ pShow i | i <- m, case i of Info{} -> False; ParseWarning{} -> False; _ -> True] | 98 | listTraceInfos m = [DResetFreshNames $ pShow i | i <- m, case i of Info{} -> False; ParseWarning{} -> False; _ -> True] |
99 | listTypeInfos m = Map.toList $ Map.unionsWith (<>) [Map.singleton r [DResetFreshNames i] | Info r i <- m] | 99 | listTypeInfos m = Map.toList $ Map.unionsWith (<>) [Map.singleton r [DResetFreshNames i] | Info r i <- m] |
100 | listErrors m = Map.toList $ Map.unionsWith (<>) [Map.singleton r [DResetFreshNames (pShow e)] | IError e <- m, RangeSI r <- errorRange_ e] | ||
101 | listWarnings m = Map.toList $ Map.unionsWith (<>) [Map.singleton r [DResetFreshNames msg] | ParseWarning (getRangeAndMsg -> Just (r, msg)) <- m] | ||
102 | where | ||
103 | getRangeAndMsg = \case | ||
104 | Unreachable r -> Just (r, "Unreachable") | ||
105 | w@(Uncovered (getRange . sourceInfo -> Just r) _) -> Just (r, pShow w) | ||
106 | _ -> Nothing | ||
100 | 107 | ||
101 | tellType si t = tell $ mkInfoItem (sourceInfo si) $ DTypeNamespace True $ pShow t | 108 | tellType si t = tell $ mkInfoItem (sourceInfo si) $ DTypeNamespace True $ pShow t |
102 | 109 | ||