git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Module & decl error sources
4326d49Gary Burgess
src/Language/PureScript/Errors.hs+15−3
@@ -22,6 +22,7 @@ import Data.Monoid
22import Control.Monad.Error
22import Control.Monad.Error
23
23
24import Language.PureScript.Declarations
24import Language.PureScript.Declarations
25+import Language.PureScript.Names
25import Language.PureScript.Pretty
26import Language.PureScript.Pretty
26import Language.PureScript.Types
27import Language.PureScript.Types
27
28
@@ -29,10 +30,18 @@ import Language.PureScript.Types
29-- Type for sources of type checking errors
30-- Type for sources of type checking errors
30--
31--
31data ErrorSource
32data ErrorSource
33+ -- |
34+ -- An error which originated in a module
35+ --
36+ = ModuleError ModuleName
37+ -- |
38+ -- An error which originated at a Declaration
39+ --
40+ | DeclarationError (Either ProperName Ident)
32 -- |
41 -- |
33 -- An error which originated at a Value
42 -- An error which originated at a Value
34 --
43 --
35− = ValueError Value
44+ | ValueError Value
36 -- |
45 -- |
37 -- An error which originated at a Type
46 -- An error which originated at a Type
38 --
47 --
@@ -86,8 +95,11 @@ isErrorNonEmpty = not . null . compileErrorMessage
86
95
87showError :: CompileError -> String
96showError :: CompileError -> String
88showError (CompileError msg Nothing _) = msg
97showError (CompileError msg Nothing _) = msg
98+showError (CompileError msg (Just (ModuleError mn)) _) = "Error in module " ++ runModuleName mn ++ ":\n" ++ msg
99+showError (CompileError msg (Just (DeclarationError (Left pn))) _) = "Error in declaration " ++ show pn ++ ":\n" ++ msg
100+showError (CompileError msg (Just (DeclarationError (Right i))) _) = "Error in declaration " ++ show i ++ ":\n" ++ msg
89−showError (CompileError msg (Just (ValueError val)) _) = "Error in value " ++ prettyPrintValue val ++ "\n" ++ msg
101+showError (CompileError msg (Just (ValueError val)) _) = "Error in value " ++ prettyPrintValue val ++ ":\n" ++ msg
90−showError (CompileError msg (Just (TypeError ty)) _) = "Error in type " ++ prettyPrintType ty ++ "\n" ++ msg
102+showError (CompileError msg (Just (TypeError ty)) _) = "Error in type " ++ prettyPrintType ty ++ ":\n" ++ msg
91
103
92mkUnifyErrorStack :: String -> Maybe ErrorSource -> ErrorStack
104mkUnifyErrorStack :: String -> Maybe ErrorSource -> ErrorStack
93mkUnifyErrorStack msg t = ErrorStack [CompileError msg t Nothing]
105mkUnifyErrorStack msg t = ErrorStack [CompileError msg t Nothing]