@@ -18,6 +18,7 @@ module Language.PureScript.Sugar.Names (
1818
1919import Data.Data
2020import Data.Maybe (fromMaybe, isJust, mapMaybe)
21+import Data.Monoid ((<>))
2122import Data.Generics (extM, mkM, everywhereM)
2223import Data.Generics.Extras (mkS, extS, everywhereWithContextM')
2324
@@ -30,6 +31,7 @@ import Language.PureScript.Declarations
3031import Language.PureScript.Names
3132import Language.PureScript.Types
3233import Language.PureScript.Environment
34+import Language.PureScript.Errors
3335
3436-- |
3537-- The global export environment - every declaration exported from every module.
@@ -80,7 +82,7 @@ data ImportEnvironment = ImportEnvironment
8082-- Updates the exports for a module from the global environment. If the module was not previously
8183-- present in the global environment, it is created.
8284--
83−updateExportedModule :: ExportEnvironment -> ModuleName -> (Exports -> Either String Exports) -> Either String ExportEnvironment
85+updateExportedModule :: ExportEnvironment -> ModuleName -> (Exports -> Either ErrorStack Exports) -> Either ErrorStack ExportEnvironment
8486updateExportedModule env mn update = do
8587 let exports = fromMaybe (error "Module was undefined in updateExportedModule") $ mn `M.lookup` env
8688 exports' <- update exports
@@ -89,16 +91,16 @@ updateExportedModule env mn update = do
8991-- |
9092-- Adds an empty module to an ExportEnvironment.
9193--
92−addEmptyModule :: ExportEnvironment -> ModuleName -> Either String ExportEnvironment
94+addEmptyModule :: ExportEnvironment -> ModuleName -> Either ErrorStack ExportEnvironment
9395addEmptyModule env name =
9496 if name `M.member` env
95− then throwError $ "Module '" ++ show name ++ "' has been defined more than once"
97+ then throwError $ mkErrorStack ("Module '" ++ show name ++ "' has been defined more than once") Nothing
9698 else return $ M.insert name (Exports [] [] []) env
9799
98100-- |
99101-- Adds a type belonging to a module to the export environment.
100102--
101−addType :: ExportEnvironment -> ModuleName -> ProperName -> [ProperName] -> Either String ExportEnvironment
103+addType :: ExportEnvironment -> ModuleName -> ProperName -> [ProperName] -> Either ErrorStack ExportEnvironment
102104addType env mn name dctors = updateExportedModule env mn $ \m -> do
103105 types' <- addExport (exportedTypes m) (name, dctors)
104106 return $ m { exportedTypes = types' }
@@ -106,7 +108,7 @@ addType env mn name dctors = updateExportedModule env mn $ \m -> do
106108-- |
107109-- Adds a class to the export environment.
108110--
109−addTypeClass :: ExportEnvironment -> ModuleName -> ProperName -> Either String ExportEnvironment
111+addTypeClass :: ExportEnvironment -> ModuleName -> ProperName -> Either ErrorStack ExportEnvironment
110112addTypeClass env mn name = updateExportedModule env mn $ \m -> do
111113 classes <- addExport (exportedTypeClasses m) name
112114 return $ m { exportedTypeClasses = classes }
@@ -114,7 +116,7 @@ addTypeClass env mn name = updateExportedModule env mn $ \m -> do
114116-- |
115117-- Adds a class to the export environment.
116118--
117−addValue :: ExportEnvironment -> ModuleName -> Ident -> Either String ExportEnvironment
119+addValue :: ExportEnvironment -> ModuleName -> Ident -> Either ErrorStack ExportEnvironment
118120addValue env mn name = updateExportedModule env mn $ \m -> do
119121 values <- addExport (exportedValues m) name
120122 return $ m { exportedValues = values }
@@ -123,16 +125,16 @@ addValue env mn name = updateExportedModule env mn $ \m -> do
123125-- Adds an entry to a list of exports unless it is already present, in which case an error is
124126-- returned.
125127--
126−addExport :: (Eq a, Show a) => [a] -> a -> Either String [a]
128+addExport :: (Eq a, Show a) => [a] -> a -> Either ErrorStack [a]
127129addExport exports name =
128130 if name `elem` exports
129− then throwError $ "Multiple definitions for '" ++ show name ++ "'"
131+ then throwError $ mkErrorStack ("Multiple definitions for '" ++ show name ++ "'") Nothing
130132 else return $ name : exports
131133
132134-- |
133135-- Replaces all local names with qualified names within a set of modules.
134136--
135−desugarImports :: [Module] -> Either String [Module]
137+desugarImports :: [Module] -> Either ErrorStack [Module]
136138desugarImports modules = do
137139 unfilteredExports <- findExports modules
138140 exports <- foldM filterModuleExports unfilteredExports modules
@@ -142,30 +144,19 @@ desugarImports modules = do
142144 -- Filters the exports for a module in the global exports environment so that only explicitly
143145 -- exported members remain. If the module does not explicitly export anything, everything is
144146 -- exported.
145− filterModuleExports :: ExportEnvironment -> Module -> Either String ExportEnvironment
147+ filterModuleExports :: ExportEnvironment -> Module -> Either ErrorStack ExportEnvironment
146148 filterModuleExports env (Module mn _ (Just exps)) = filterExports mn exps env
147149 filterModuleExports env _ = return env
148150
149151 -- Rename and check all the names within a module. We tweak the global exports environment so
150152 -- the module has access to an unfiltered list of its own members.
151− renameInModule' :: ExportEnvironment -> ExportEnvironment -> Module -> Either String Module
152− renameInModule' unfilteredExports exports m@(Module mn _ _) = rethrowForModule m $ do
153− let env = M.update (\_ -> M.lookup mn unfilteredExports) mn exports
154− let exps = fromMaybe (error "Module is missing in renameInModule'") $ M.lookup mn exports
155− imports <- resolveImports env m
156− renameInModule imports env (elaborateExports exps m)
157−
158−-- |
159−-- Rethrow an error with an extra message line prepended
160−--
161−rethrow :: String -> Either String a -> Either String a
162−rethrow msg = flip catchError $ \e -> throwError (msg ++ ":\n" ++ e)
163−
164−-- |
165−-- Rethrow an error with details of the current module prepended to the message
166−--
167−rethrowForModule :: Module -> Either String a -> Either String a
168−rethrowForModule (Module mn _ _) = rethrow $ "Error in module '" ++ show mn ++ "'"
153+ renameInModule' :: ExportEnvironment -> ExportEnvironment -> Module -> Either ErrorStack Module
154+ renameInModule' unfilteredExports exports m@(Module mn _ _) =
155+ rethrow (strMsg ("Error in module " ++ show mn) <>) $ do
156+ let env = M.update (\_ -> M.lookup mn unfilteredExports) mn exports
157+ let exps = fromMaybe (error "Module is missing in renameInModule'") $ M.lookup mn exports
158+ imports <- resolveImports env m
159+ renameInModule imports env (elaborateExports exps m)
169160
170161-- |
171162-- Make all exports for a module explicit. This may still effect modules that have an exports list,
@@ -181,23 +172,27 @@ elaborateExports exps (Module mn decls _) = Module mn decls (Just $
181172-- Replaces all local names with qualified names within a module and checks that all existing
182173-- qualified names are valid.
183174--
184−renameInModule :: ImportEnvironment -> ExportEnvironment -> Module -> Either String Module
175+renameInModule :: ImportEnvironment -> ExportEnvironment -> Module -> Either ErrorStack Module
185176renameInModule imports exports (Module mn decls exps) =
186177 Module mn <$> mapM go decls <*> pure exps
187178 where
179+ go :: Declaration -> Either ErrorStack Declaration
188180 go (DataDeclaration name args dctors) =
189− rethrowFor "data declaration" name $ DataDeclaration <$> pure name <*> pure args <*> updateAll dctors
181+ rethrow (strMsg ("Error in data declaration " ++ show name) <>) $
182+ DataDeclaration <$> pure name <*> pure args <*> updateAll dctors
190183 go (DataBindingGroupDeclaration decls') =
191184 DataBindingGroupDeclaration <$> mapM go decls'
192185 go (TypeSynonymDeclaration name ps ty) =
193− rethrowFor "type synonym" name $ TypeSynonymDeclaration <$> pure name <*> pure ps <*> updateType' ty
186+ rethrow (strMsg ("Error in type synonym " ++ show name) <>) $
187+ TypeSynonymDeclaration <$> pure name <*> pure ps <*> updateType' ty
194188 go (TypeInstanceDeclaration name cs cn ts ds) =
195189 TypeInstanceDeclaration name <$> updateConstraints cs <*> updateClassName cn <*> updateType' ts <*> mapM go ds
196190 go (ExternInstanceDeclaration name cs cn ts) =
197191 ExternInstanceDeclaration name <$> updateConstraints cs <*> updateClassName cn <*> updateType' ts
198192 go (ValueDeclaration name nameKind [] Nothing val) = do
199193 val' <- everywhereWithContextM' [] (mkS bindFunctionArgs `extS` bindBinders) val
200− rethrowFor "declaration" name $ ValueDeclaration name nameKind [] Nothing <$> updateAll val'
194+ rethrow (strMsg ("Error in declaration " ++ show name) <>) $
195+ ValueDeclaration name nameKind [] Nothing <$> updateAll val'
201196 where
202197 bindFunctionArgs bound (Abs (Left arg) val') = return (arg : bound, Abs (Left arg) val')
203198 bindFunctionArgs bound (Let ds val') = let args = mapMaybe letBoundVariable ds in
@@ -211,7 +206,7 @@ renameInModule imports exports (Module mn decls exps) =
211206 bindFunctionArgs bound (BinaryNoParens name'@(Qualified (Just _) _) v1 v2) =
212207 (,) bound <$> (BinaryNoParens <$> updateValueName name' <*> pure v1 <*> pure v2)
213208 bindFunctionArgs bound other = return (bound, other)
214− bindBinders :: [Ident] -> CaseAlternative -> Either String ([Ident], CaseAlternative)
209+ bindBinders :: [Ident] -> CaseAlternative -> Either ErrorStack ([Ident], CaseAlternative)
215210 bindBinders bound c@(CaseAlternative bs _ _) = return (binderNames bs ++ bound, c)
216211
217212 letBoundVariable :: Declaration -> Maybe Ident
@@ -220,17 +215,18 @@ renameInModule imports exports (Module mn decls exps) =
220215 letBoundVariable _ = Nothing
221216 go (ValueDeclaration name _ _ _ _) = error $ "Binders should have been desugared in " ++ show name
222217 go (ExternDeclaration fit name js ty) =
223− rethrowFor "declaration" name $ ExternDeclaration <$> pure fit <*> pure name <*> pure js <*> updateType' ty
218+ rethrow (strMsg ("Error in declaration " ++ show name) <>) $
219+ ExternDeclaration <$> pure fit <*> pure name <*> pure js <*> updateType' ty
224220 go (BindingGroupDeclaration decls') = do
225221 BindingGroupDeclaration <$> mapM go' decls'
226− where go' = \(name, nk, value) -> rethrowFor "declaration" name $ (,,) <$> pure name <*> pure nk <*> updateAll value
222+ where
223+ go' = \(name, nk, value) ->
224+ rethrow (strMsg ("Error in declaration " ++ show name) <>) $
225+ (,,) <$> pure name <*> pure nk <*> updateAll value
227226 go (PositionedDeclaration pos d) = PositionedDeclaration pos <$> go d
228227 go d = updateAll d
229228
230− rethrowFor :: (Show a) => String -> a -> Either String b -> Either String b
231− rethrowFor what name = rethrow $ "Error in " ++ what ++ " '" ++ show name ++ "'"
232−
233− updateAll :: Data d => d -> Either String d
229+ updateAll :: Data d => d -> Either ErrorStack d
234230 updateAll = everywhereM (mkM updateType `extM` updateValue `extM` updateBinder)
235231
236232 updateValue (Constructor name) = Constructor <$> updateDataConstructorName name
@@ -243,7 +239,7 @@ renameInModule imports exports (Module mn decls exps) =
243239 updateType (SaturatedTypeSynonym name tys) = SaturatedTypeSynonym <$> updateTypeName name <*> mapM updateType tys
244240 updateType (ConstrainedType cs t) = ConstrainedType <$> updateConstraints cs <*> pure t
245241 updateType t = return t
246− updateType' :: Data d => d -> Either String d
242+ updateType' :: Data d => d -> Either ErrorStack d
247243 updateType' = everywhereM (mkM updateType)
248244
249245 updateConstraints = mapM (\(name, ts) -> (,) <$> updateClassName name <*> pure ts)
@@ -259,24 +255,24 @@ renameInModule imports exports (Module mn decls exps) =
259255 -> (ImportEnvironment -> M.Map (Qualified a) (Qualified a))
260256 -> (Exports -> a -> Bool)
261257 -> (Qualified a)
262− -> Either String (Qualified a)
258+ -> Either ErrorStack (Qualified a)
263259 update t getI checkE qname@(Qualified mn' name) = case (M.lookup qname (getI imports), mn') of
264260 (Just qname', _) -> return qname'
265261 (Nothing, Just mn'') -> do
266262 modExports <- getExports mn''
267263 if checkE modExports name
268264 then return qname
269− else throwError $ "Unknown " ++ t ++ " '" ++ show (qname) ++ "'"
270− _ -> throwError $ "Unknown " ++ t ++ " '" ++ show name ++ "'"
265+ else throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show (qname) ++ "'") Nothing
266+ _ -> throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show name ++ "'") Nothing
271267
272268 -- Gets the exports for a module, or an error message if the module doesn't exist
273− getExports :: ModuleName -> Either String Exports
274− getExports mn' = maybe (throwError $ "Unknown module '" ++ show mn' ++ "'") return $ M.lookup mn' exports
269+ getExports :: ModuleName -> Either ErrorStack Exports
270+ getExports mn' = maybe (throwError $ mkErrorStack ("Unknown module '" ++ show mn' ++ "'") Nothing) return $ M.lookup mn' exports
275271
276272-- |
277273-- Finds all exported declarations in a set of modules.
278274--
279−findExports :: [Module] -> Either String ExportEnvironment
275+findExports :: [Module] -> Either ErrorStack ExportEnvironment
280276findExports = foldM addModule $ M.singleton (ModuleName [ProperName "Prim"]) primExports
281277 where
282278
@@ -286,13 +282,13 @@ findExports = foldM addModule $ M.singleton (ModuleName [ProperName "Prim"]) pri
286282 mkTypeEntry (Qualified _ name) = (name, [])
287283
288284 -- Add all of the exported declarations from a module to the global export environment
289− addModule :: ExportEnvironment -> Module -> Either String ExportEnvironment
285+ addModule :: ExportEnvironment -> Module -> Either ErrorStack ExportEnvironment
290286 addModule env m@(Module mn ds _) = do
291287 env' <- addEmptyModule env mn
292− rethrowForModule m $ foldM (addDecl mn) env' ds
288+ rethrow (strMsg ("Error in module " ++ show mn) <>) $ foldM (addDecl mn) env' ds
293289
294290 -- Add a declaration from a module to the global export environment
295− addDecl :: ModuleName -> ExportEnvironment -> Declaration -> Either String ExportEnvironment
291+ addDecl :: ModuleName -> ExportEnvironment -> Declaration -> Either ErrorStack ExportEnvironment
296292 addDecl mn env (TypeClassDeclaration tcn _ ds) = do
297293 env' <- addTypeClass env mn tcn
298294 foldM (\env'' (TypeDeclaration name _) -> addValue env'' mn name) env' ds
@@ -308,7 +304,7 @@ findExports = foldM addModule $ M.singleton (ModuleName [ProperName "Prim"]) pri
308304-- Filters the exports for a module to ensure only explicit exports are kept in the global exports
309305-- environment.
310306--
311−filterExports :: ModuleName -> [DeclarationRef] -> ExportEnvironment -> Either String ExportEnvironment
307+filterExports :: ModuleName -> [DeclarationRef] -> ExportEnvironment -> Either ErrorStack ExportEnvironment
312308filterExports mn exps env = do
313309 let moduleExports = fromMaybe (error "Module is missing") (mn `M.lookup` env)
314310 moduleExports' <- filterModule moduleExports
@@ -316,7 +312,7 @@ filterExports mn exps env = do
316312 where
317313
318314 -- Filter the exports for the specific module
319− filterModule :: Exports -> Either String Exports
315+ filterModule :: Exports -> Either ErrorStack Exports
320316 filterModule exported = do
321317 types' <- foldM (filterTypes $ exportedTypes exported) [] exps
322318 values <- foldM (filterValues $ exportedValues exported) [] exps
@@ -325,34 +321,34 @@ filterExports mn exps env = do
325321
326322 -- Ensure the exported types and data constructors exist in the module and add them to the set of
327323 -- exports
328− filterTypes :: [(ProperName, [ProperName])] -> [(ProperName, [ProperName])] -> DeclarationRef -> Either String [(ProperName, [ProperName])]
324+ filterTypes :: [(ProperName, [ProperName])] -> [(ProperName, [ProperName])] -> DeclarationRef -> Either ErrorStack [(ProperName, [ProperName])]
329325 filterTypes expTys result (TypeRef name expDcons) = do
330− dcons <- maybe (throwError $ "Cannot export undefined type '" ++ show name ++ "'") return $ name `lookup` expTys
326+ dcons <- maybe (throwError $ mkErrorStack ("Cannot export undefined type '" ++ show name ++ "'") Nothing) return $ name `lookup` expTys
331327 dcons' <- maybe (return dcons) (foldM (filterDcons name dcons) []) expDcons
332328 return $ (name, dcons') : result
333329 filterTypes _ result _ = return result
334330
335331 -- Ensure the exported data constructors exists for a type and add them to the list of exports
336− filterDcons :: ProperName -> [ProperName] -> [ProperName] -> ProperName -> Either String [ProperName]
332+ filterDcons :: ProperName -> [ProperName] -> [ProperName] -> ProperName -> Either ErrorStack [ProperName]
337333 filterDcons tcon exps' result name =
338334 if name `elem` exps'
339335 then return $ name : result
340− else throwError $ "Cannot export undefined data constructor '" ++ show name ++ "' for type '" ++ show tcon ++ "'"
336+ else throwError $ mkErrorStack ("Cannot export undefined data constructor '" ++ show name ++ "' for type '" ++ show tcon ++ "'") Nothing
341337
342338 -- Ensure the exported classes exist in the module and add them to the set of exports
343− filterClasses :: [ProperName] -> [ProperName] -> DeclarationRef -> Either String [ProperName]
339+ filterClasses :: [ProperName] -> [ProperName] -> DeclarationRef -> Either ErrorStack [ProperName]
344340 filterClasses exps' result (TypeClassRef name) =
345341 if name `elem` exps'
346342 then return $ name : result
347− else throwError $ "Cannot export undefined type class '" ++ show name ++ "'"
343+ else throwError $ mkErrorStack ("Cannot export undefined type class '" ++ show name ++ "'") Nothing
348344 filterClasses _ result _ = return result
349345
350346 -- Ensure the exported values exist in the module and add them to the set of exports
351− filterValues :: [Ident] -> [Ident] -> DeclarationRef -> Either String [Ident]
347+ filterValues :: [Ident] -> [Ident] -> DeclarationRef -> Either ErrorStack [Ident]
352348 filterValues exps' result (ValueRef name) =
353349 if name `elem` exps'
354350 then return $ name : result
355− else throwError $ "Cannot export undefined value '" ++ show name ++ "'"
351+ else throwError $ mkErrorStack ("Cannot export undefined value '" ++ show name ++ "'") Nothing
356352 filterValues _ result _ = return result
357353
358354-- |
@@ -374,7 +370,7 @@ findImports = foldl findImports' M.empty
374370-- |
375371-- Constructs a local environment for a module.
376372--
377−resolveImports :: ExportEnvironment -> Module -> Either String ImportEnvironment
373+resolveImports :: ExportEnvironment -> Module -> Either ErrorStack ImportEnvironment
378374resolveImports env (Module currentModule decls _) =
379375 foldM resolveImport' (ImportEnvironment M.empty M.empty M.empty M.empty) (M.toList scope)
380376 where
@@ -382,25 +378,25 @@ resolveImports env (Module currentModule decls _) =
382378 scope :: M.Map ModuleName (Maybe ExplicitImports, Maybe ModuleName)
383379 scope = M.insert currentModule (Nothing, Nothing) (findImports decls)
384380 resolveImport' imp (mn, (explImports, impQual)) = do
385− modExports <- maybe (throwError $ "Cannot import unknown module '" ++ show mn ++ "'") return $ mn `M.lookup` env
381+ modExports <- maybe (throwError $ mkErrorStack ("Cannot import unknown module '" ++ show mn ++ "'") Nothing) return $ mn `M.lookup` env
386382 resolveImport currentModule mn modExports imp impQual explImports
387383
388384-- |
389385-- Extends the local environment for a module by resolving an import of another module.
390386--
391−resolveImport :: ModuleName -> ModuleName -> Exports -> ImportEnvironment -> Maybe ModuleName -> Maybe ExplicitImports-> Either String ImportEnvironment
387+resolveImport :: ModuleName -> ModuleName -> Exports -> ImportEnvironment -> Maybe ModuleName -> Maybe ExplicitImports-> Either ErrorStack ImportEnvironment
392388resolveImport currentModule importModule exps imps impQual = maybe importAll (foldM importExplicit imps)
393389 where
394390
395391 -- Import everything from a module
396− importAll :: Either String ImportEnvironment
392+ importAll :: Either ErrorStack ImportEnvironment
397393 importAll = do
398394 imp' <- foldM (\m (name, dctors) -> importExplicit m (TypeRef name (Just dctors))) imps (exportedTypes exps)
399395 imp'' <- foldM (\m name -> importExplicit m (ValueRef name)) imp' (exportedValues exps)
400396 foldM (\m name -> importExplicit m (TypeClassRef name)) imp'' (exportedTypeClasses exps)
401397
402398 -- Import something explicitly
403− importExplicit :: ImportEnvironment -> DeclarationRef -> Either String ImportEnvironment
399+ importExplicit :: ImportEnvironment -> DeclarationRef -> Either ErrorStack ImportEnvironment
404400 importExplicit imp (ValueRef name) = do
405401 _ <- checkImportExists "value" values name
406402 values' <- updateImports (importedValues imp) name
@@ -423,14 +419,15 @@ resolveImport currentModule importModule exps imps impQual = maybe importAll (fo
423419 allExportedDataConstructors name = fromMaybe [] $ name `lookup` exportedTypes exps
424420
425421 -- Add something to the ImportEnvironment if it does not already exist there
426− updateImports :: (Ord a, Show a) => M.Map (Qualified a) (Qualified a) -> a -> Either String (M.Map (Qualified a) (Qualified a))
422+ updateImports :: (Ord a, Show a) => M.Map (Qualified a) (Qualified a) -> a -> Either ErrorStack (M.Map (Qualified a) (Qualified a))
427423 updateImports m name = case M.lookup (Qualified impQual name) m of
428424 Nothing -> return $ M.insert (Qualified impQual name) (Qualified (Just importModule) name) m
429425 Just (Qualified Nothing _) -> error "Invalid state in updateImports"
430− Just x@(Qualified (Just mn) _) -> throwError $
431− if mn == currentModule || importModule == currentModule
432− then "Definition '" ++ show name ++ "' conflicts with import '" ++ show (Qualified (Just importModule) name) ++ "'"
433− else "Conflicting imports for '" ++ show name ++ "': '" ++ show x ++ "', '" ++ show (Qualified (Just importModule) name) ++ "'"
426+ Just x@(Qualified (Just mn) _) -> throwError $ mkErrorStack err Nothing
427+ where
428+ err = if mn == currentModule || importModule == currentModule
429+ then "Definition '" ++ show name ++ "' conflicts with import '" ++ show (Qualified (Just importModule) name) ++ "'"
430+ else "Conflicting imports for '" ++ show name ++ "': '" ++ show x ++ "', '" ++ show (Qualified (Just importModule) name) ++ "'"
434431
435432 -- The available values, types, and classes in the module being imported
436433 values = exportedValues exps
@@ -439,14 +436,14 @@ resolveImport currentModule importModule exps imps impQual = maybe importAll (fo
439436
440437 -- Ensure that an explicitly imported data constructor exists for the type it is being imported
441438 -- from
442− checkDctorExists :: [ProperName] -> ProperName -> Either String ProperName
439+ checkDctorExists :: [ProperName] -> ProperName -> Either ErrorStack ProperName
443440 checkDctorExists = checkImportExists "data constructor"
444441
445442 -- Check that an explicitly imported item exists in the module it is being imported from
446− checkImportExists :: (Eq a, Show a) => String -> [a] -> a -> Either String a
443+ checkImportExists :: (Eq a, Show a) => String -> [a] -> a -> Either ErrorStack a
447444 checkImportExists t exports item =
448445 if item `elem` exports
449446 then return item
450− else throwError $ "Unable to find " ++ t ++ " '" ++ show (Qualified (Just importModule) item) ++ "'"
447+ else throwError $ mkErrorStack ("Unable to find " ++ t ++ " '" ++ show (Qualified (Just importModule) item) ++ "'") Nothing
451448
452449