@@ -223,8 +223,9 @@ resolveImports env (Module currentModule decls) =
223223 values' <- updateImports mn (importedValues imp) name
224224 return $ imp { importedValues = values' }
225225 importExplicit mn imp (TypeImport name dctors) = do
226+ allDctors <- allExportedDataConstructors env mn name
226227 types' <- updateImports mn (importedTypes imp) name
227− dctors' <- foldM (updateImports mn) (importedDataConstructors imp) (fromMaybe (allExportedDataConstructors env mn name) dctors)
228+ dctors' <- foldM (updateImports mn) (importedDataConstructors imp) (fromMaybe allDctors dctors)
228229 return $ imp { importedTypes = types', importedDataConstructors = dctors' }
229230 importExplicit mn imp (TypeClassImport name) = do
230231 typeClasses' <- updateImports mn (importedTypeClasses imp) name
@@ -241,8 +242,8 @@ resolveImports env (Module currentModule decls) =
241242 (S.toList . fromMaybe S.empty $ mn `M.lookup` exportedTypeClasses env)
242243
243244 -- Find all exported data constructors for a given type
244− allExportedDataConstructors :: ExportEnvironment -> ModuleName -> ProperName -> [ProperName]
245− allExportedDataConstructors env mn name = fromMaybe (error $ "Unable to find exported data constructors for type " ++ show name) $ do
245+ allExportedDataConstructors :: ExportEnvironment -> ModuleName -> ProperName -> Either String [ProperName]
246+ allExportedDataConstructors env mn name = maybe (throwError $ "Unable to find exported data constructors for type " ++ show name) return $ do
246247 s <- mn `M.lookup` exportedTypes env
247248 name `lookup` S.toList s
248249