@@ -8,6 +8,7 @@ module Idris.Delaborate where
8import Idris.AbsSyntax
8import Idris.AbsSyntax
9import Idris.Core.TT
9import Idris.Core.TT
10import Idris.Core.Evaluate
10import Idris.Core.Evaluate
11+import Idris.ErrReverse
12import Data.List (intersperse)
13import Data.List (intersperse)
@@ -121,11 +122,13 @@ indented text = boxIt '\n' $ unlines $ map ('\t':) $ lines text where
123pshow :: IState -> Err -> String
124pshow :: IState -> Err -> String
125+pshow i err = pshow' i (fmap (errReverse i) err)
124−pshow i (Msg s) = s
127+pshow' i (Msg s) = s
125−pshow i (InternalMsg s) = "INTERNAL ERROR: " ++ show s ++
128+pshow' i (InternalMsg s) = "INTERNAL ERROR: " ++ show s ++
126 "\nThis is probably a bug, or a missing error message.\n" ++
129 "\nThis is probably a bug, or a missing error message.\n" ++
127 "Please consider reporting at " ++ bugaddr
130 "Please consider reporting at " ++ bugaddr
128−pshow i (CantUnify _ x y e sc s)
131+pshow' i (CantUnify _ x y e sc s)
129 = let imps = opt_showimp (idris_options i) in
132 = let imps = opt_showimp (idris_options i) in
130 let colour = idris_colourRepl i in
133 let colour = idris_colourRepl i in
131 "Can't unify" ++ indented (showImp (Just i) imps colour (delab i x))
134 "Can't unify" ++ indented (showImp (Just i) imps colour (delab i x))
@@ -134,72 +137,72 @@ pshow i (CantUnify _ x y e sc s)
134 case e of
137 case e of
135 Msg "" -> ""
138 Msg "" -> ""
136 _ -> "\nSpecifically:" ++
139 _ -> "\nSpecifically:" ++
137− indented (pshow i e) ++
140+ indented (pshow' i e) ++
138 if (opt_errContext (idris_options i)) then showSc i sc else ""
141 if (opt_errContext (idris_options i)) then showSc i sc else ""
139−pshow i (CantConvert x y env)
142+pshow' i (CantConvert x y env)
140 = let imps = opt_showimp (idris_options i) in
143 = let imps = opt_showimp (idris_options i) in
141 let colour = idris_colourRepl i in
144 let colour = idris_colourRepl i in
142 "Can't convert" ++ indented (showImp (Just i) imps colour (delab i x)) ++ "with"
145 "Can't convert" ++ indented (showImp (Just i) imps colour (delab i x)) ++ "with"
143 ++ indented (showImp (Just i) imps colour (delab i y)) ++
146 ++ indented (showImp (Just i) imps colour (delab i y)) ++
144 if (opt_errContext (idris_options i)) then showSc i env else ""
147 if (opt_errContext (idris_options i)) then showSc i env else ""
145−pshow i (CantSolveGoal x env)
148+pshow' i (CantSolveGoal x env)
146 = let imps = opt_showimp (idris_options i) in
149 = let imps = opt_showimp (idris_options i) in
147 let colour = idris_colourRepl i in
150 let colour = idris_colourRepl i in
148 "Can't solve goal " ++ indented (showImp (Just i) imps colour (delab i x)) ++
151 "Can't solve goal " ++ indented (showImp (Just i) imps colour (delab i x)) ++
149 if (opt_errContext (idris_options i)) then showSc i env else ""
152 if (opt_errContext (idris_options i)) then showSc i env else ""
150−pshow i (UnifyScope n out tm env)
153+pshow' i (UnifyScope n out tm env)
151 = let imps = opt_showimp (idris_options i) in
154 = let imps = opt_showimp (idris_options i) in
152 let colour = idris_colourRepl i in
155 let colour = idris_colourRepl i in
153 "Can't unify" ++ indented (show n) ++ "with"
156 "Can't unify" ++ indented (show n) ++ "with"
154 ++ indented (showImp (Just i) imps colour (delab i tm)) ++ "as" ++
157 ++ indented (showImp (Just i) imps colour (delab i tm)) ++ "as" ++
155 indented (show out) ++ "is not in scope" ++
158 indented (show out) ++ "is not in scope" ++
156 if (opt_errContext (idris_options i)) then showSc i env else ""
159 if (opt_errContext (idris_options i)) then showSc i env else ""
157−pshow i (CantInferType t)
160+pshow' i (CantInferType t)
158 = "Can't infer type for " ++ t
161 = "Can't infer type for " ++ t
159−pshow i (NonFunctionType f ty)
162+pshow' i (NonFunctionType f ty)
160 = let imps = opt_showimp (idris_options i) in
163 = let imps = opt_showimp (idris_options i) in
161 let colour = idris_colourRepl i in
164 let colour = idris_colourRepl i in
162 showImp (Just i) imps colour (delab i f) ++ " does not have a function type ("
165 showImp (Just i) imps colour (delab i f) ++ " does not have a function type ("
163 ++ showImp (Just i) imps colour (delab i ty) ++ ")"
166 ++ showImp (Just i) imps colour (delab i ty) ++ ")"
164−pshow i (NotEquality tm ty)
167+pshow' i (NotEquality tm ty)
165 = let imps = opt_showimp (idris_options i) in
168 = let imps = opt_showimp (idris_options i) in
166 let colour = idris_colourRepl i in
169 let colour = idris_colourRepl i in
167 showImp (Just i) imps colour (delab i tm) ++ " does not have an equality type ("
170 showImp (Just i) imps colour (delab i tm) ++ " does not have an equality type ("
168 ++ showImp (Just i) imps colour (delab i ty) ++ ")"
171 ++ showImp (Just i) imps colour (delab i ty) ++ ")"
169−pshow i (TooManyArguments f)
172+pshow' i (TooManyArguments f)
170 = "Too many arguments for " ++ show f
173 = "Too many arguments for " ++ show f
171−pshow i (CantIntroduce ty)
174+pshow' i (CantIntroduce ty)
172 = let imps = opt_showimp (idris_options i) in
175 = let imps = opt_showimp (idris_options i) in
173 let colour = idris_colourRepl i in
176 let colour = idris_colourRepl i in
174 "Can't use lambda here: type is " ++ showImp (Just i) imps colour (delab i ty)
177 "Can't use lambda here: type is " ++ showImp (Just i) imps colour (delab i ty)
175−pshow i (InfiniteUnify x tm env)
178+pshow' i (InfiniteUnify x tm env)
176 = "Unifying " ++ showbasic x ++ " and " ++ show (delab i tm) ++
179 = "Unifying " ++ showbasic x ++ " and " ++ show (delab i tm) ++
177 " would lead to infinite value" ++
180 " would lead to infinite value" ++
178 if (opt_errContext (idris_options i)) then showSc i env else ""
181 if (opt_errContext (idris_options i)) then showSc i env else ""
179−pshow i (NotInjective p x y) = "Can't verify injectivity of " ++ show (delab i p) ++
182+pshow' i (NotInjective p x y) = "Can't verify injectivity of " ++ show (delab i p) ++
180− " when unifying " ++ show (delab i x) ++ " and " ++
183+ " when unifying " ++ show (delab i x) ++ " and " ++
181− show (delab i y)
184+ show (delab i y)
182−pshow i (CantResolve c) = "Can't resolve type class " ++ show (delab i c)
185+pshow' i (CantResolve c) = "Can't resolve type class " ++ show (delab i c)
183−pshow i (CantResolveAlts as) = "Can't disambiguate name: " ++ showSep ", " as
186+pshow' i (CantResolveAlts as) = "Can't disambiguate name: " ++ showSep ", " as
184−pshow i (NoTypeDecl n) = "No type declaration for " ++ show n
187+pshow' i (NoTypeDecl n) = "No type declaration for " ++ show n
185−pshow i (NoSuchVariable n) = "No such variable " ++ show n
188+pshow' i (NoSuchVariable n) = "No such variable " ++ show n
186−pshow i (IncompleteTerm t) = "Incomplete term " ++ showImp Nothing True False (delab i t)
189+pshow' i (IncompleteTerm t) = "Incomplete term " ++ showImp Nothing True False (delab i t)
187−pshow i UniverseError = "Universe inconsistency"
190+pshow' i UniverseError = "Universe inconsistency"
188−pshow i ProgramLineComment = "Program line next to comment"
191+pshow' i ProgramLineComment = "Program line next to comment"
189−pshow i (Inaccessible n) = show n ++ " is not an accessible pattern variable"
192+pshow' i (Inaccessible n) = show n ++ " is not an accessible pattern variable"
190−pshow i (NonCollapsiblePostulate n)
193+pshow' i (NonCollapsiblePostulate n)
191 = "The return type of postulate " ++ show n ++ " is not collapsible"
194 = "The return type of postulate " ++ show n ++ " is not collapsible"
192−pshow i (AlreadyDefined n) = show n ++ " is already defined"
195+pshow' i (AlreadyDefined n) = show n ++ " is already defined"
193−pshow i (ProofSearchFail e) = pshow i e
196+pshow' i (ProofSearchFail e) = pshow' i e
194−pshow i (NoRewriting tm) = "rewrite did not change type " ++ show (delab i tm)
197+pshow' i (NoRewriting tm) = "rewrite did not change type " ++ show (delab i tm)
195−pshow i (At f e) = show f ++ ":" ++ pshow i e
198+pshow' i (At f e) = show f ++ ":" ++ pshow' i e
196−pshow i (Elaborating s n e) = "When elaborating " ++ s ++
199+pshow' i (Elaborating s n e) = "When elaborating " ++ s ++
197− showqual i n ++ ":\n" ++ pshow i e
200+ showqual i n ++ ":\n" ++ pshow' i e
198−pshow i (ProviderError msg) = "Type provider error: " ++ msg
201+pshow' i (ProviderError msg) = "Type provider error: " ++ msg
199−pshow i (LoadingFailed fn e) = "Loading " ++ fn ++ " failed: " ++ pshow i e
202+pshow' i (LoadingFailed fn e) = "Loading " ++ fn ++ " failed: " ++ pshow' i e
200−pshow i (ReflectionError parts orig) = let parts' = map (concat . intersperse " " . map showPart) parts in
203+pshow' i (ReflectionError parts orig) = let parts' = map (concat . intersperse " " . map showPart) parts in
201 concat (intersperse "\n" parts') ++
204 concat (intersperse "\n" parts') ++
202− "\nOriginal error:\n" ++ indented (pshow i orig)
205+ "\nOriginal error:\n" ++ indented (pshow' i orig)
203 where showPart :: ErrorReportPart -> String
206 where showPart :: ErrorReportPart -> String
204 showPart (TextPart str) = str
207 showPart (TextPart str) = str
205 showPart (NamePart n) = let colour = idris_colourRepl i in
208 showPart (NamePart n) = let colour = idris_colourRepl i in
@@ -207,8 +210,8 @@ pshow i (ReflectionError parts orig) = let parts' = map (concat . intersperse "
207 showPart (TermPart tm) = let colour = idris_colourRepl i
210 showPart (TermPart tm) = let colour = idris_colourRepl i
208 in showImp (Just i) False colour (delab i tm)
211 in showImp (Just i) False colour (delab i tm)
209 showPart (SubReport rs) = indented . concat . intersperse " " . map showPart $ rs
212 showPart (SubReport rs) = indented . concat . intersperse " " . map showPart $ rs
210−pshow i (ReflectionFailed msg err) = "When attempting to perform error reflection, the following internal error occurred:\n" ++
213+pshow' i (ReflectionFailed msg err) = "When attempting to perform error reflection, the following internal error occurred:\n" ++
211− indented (pshow i err) ++
214+ indented (pshow' i err) ++
212 "\nThis is probably a bug. Please consider reporting it at " ++ bugaddr
215 "\nThis is probably a bug. Please consider reporting it at " ++ bugaddr