git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Module & decl error sources
commit4326d49a9d778f525f1a4b353c0407d6ce3915ca authorGary Burgess <gary.burgess@gmail.com> dateSat 29 Mar 2014, 17:31 (13 years ago) parentf568d7d
1 file changed+15−3
src/Language/PureScript/Errors.hs+15−3
src/Language/PureScript/Errors.hs+15−3
@@ -22,6 +22,7 @@ import Data.Monoid
2222import Control.Monad.Error
2323
2424import Language.PureScript.Declarations
25+import Language.PureScript.Names
2526import Language.PureScript.Pretty
2627import Language.PureScript.Types
2728
@@ -29,10 +30,18 @@ import Language.PureScript.Types
2930-- Type for sources of type checking errors
3031--
3132data 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)
3241 -- |
3342 -- An error which originated at a Value
3443 --
35− = ValueError Value
44+ | ValueError Value
3645 -- |
3746 -- An error which originated at a Type
3847 --
@@ -86,8 +95,11 @@ isErrorNonEmpty = not . null . compileErrorMessage
8695
8796showError :: CompileError -> String
8897showError (CompileError msg Nothing _) = msg
89−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
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
101+showError (CompileError msg (Just (ValueError val)) _) = "Error in value " ++ prettyPrintValue val ++ ":\n" ++ msg
102+showError (CompileError msg (Just (TypeError ty)) _) = "Error in type " ++ prettyPrintType ty ++ ":\n" ++ msg
91103
92104mkUnifyErrorStack :: String -> Maybe ErrorSource -> ErrorStack
93105mkUnifyErrorStack msg t = ErrorStack [CompileError msg t Nothing]