summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Utils/Backpack.hs
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-06-02 10:14:55 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-28 16:57:28 -0400
commit755cb2b0c161d306497b7581b984f62ca23bca15 (patch)
tree8fa9ab6364a9fd608b64a51a2f211353f0003314 /compiler/GHC/Tc/Utils/Backpack.hs
parentd4c43df13d428b1acee2149618f8503580303486 (diff)
downloadhaskell-755cb2b0c161d306497b7581b984f62ca23bca15.tar.gz
Try to simplify zoo of functions in `Tc.Utils.Monad`
This commit tries to untangle the zoo of diagnostic-related functions in `Tc.Utils.Monad` so that we can have the interfaces mentions only `TcRnMessage`s while we push the creation of these messages upstream. It also ports TcRnMessage diagnostics to use the new API, in particular this commit switch to use TcRnMessage in the external interfaces of the diagnostic functions, and port the old SDoc to be wrapped into TcRnUnknownMessage.
Diffstat (limited to 'compiler/GHC/Tc/Utils/Backpack.hs')
-rw-r--r--compiler/GHC/Tc/Utils/Backpack.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/GHC/Tc/Utils/Backpack.hs b/compiler/GHC/Tc/Utils/Backpack.hs
index a3b0068b3e..d433a46aed 100644
--- a/compiler/GHC/Tc/Utils/Backpack.hs
+++ b/compiler/GHC/Tc/Utils/Backpack.hs
@@ -47,6 +47,7 @@ import GHC.Unit.Module.ModDetails
import GHC.Unit.Module.Imported
import GHC.Unit.Module.Deps
+import GHC.Tc.Errors.Types
import GHC.Tc.Gen.Export
import GHC.Tc.Solver
import GHC.Tc.TyCl.Utils
@@ -89,8 +90,9 @@ import Data.List (find)
import {-# SOURCE #-} GHC.Tc.Module
-fixityMisMatch :: TyThing -> Fixity -> Fixity -> SDoc
+fixityMisMatch :: TyThing -> Fixity -> Fixity -> TcRnMessage
fixityMisMatch real_thing real_fixity sig_fixity =
+ TcRnUnknownMessage $ mkPlainError noHints $
vcat [ppr real_thing <+> text "has conflicting fixities in the module",
text "and its hsig file",
text "Main module:" <+> ppr_fix real_fixity,
@@ -167,7 +169,7 @@ checkHsigIface tcg_env gr sig_iface
-- tcg_env (TODO: but maybe this isn't relevant anymore).
r <- tcLookupImported_maybe name
case r of
- Failed err -> addErr err
+ Failed err -> addErr (TcRnUnknownMessage $ mkPlainError noHints err)
Succeeded real_thing -> checkHsigDeclM sig_iface sig_thing real_thing
-- The hsig did NOT define this function; that means it must
@@ -711,7 +713,7 @@ mergeSignatures
-- 3(d). Extend the name substitution (performing shaping)
mb_r <- extend_ns nsubst as2
case mb_r of
- Left err -> failWithTc err
+ Left err -> failWithTc (TcRnUnknownMessage $ mkPlainError noHints err)
Right nsubst' -> return (nsubst',oks',(imod, thinned_iface):ifaces)
nsubst0 = mkNameShape (moduleName inner_mod) (mi_exports lcl_iface0)
ok_to_use0 = mkOccSet (exportOccs (mi_exports lcl_iface0))
@@ -1021,7 +1023,7 @@ checkImplements impl_mod req_mod@(Module uid mod_name) = do
isig_mod sig_mod NotBoot
isig_iface <- case mb_isig_iface of
Succeeded (iface, _) -> return iface
- Failed err -> failWithTc $
+ Failed err -> failWithTc $ TcRnUnknownMessage $ mkPlainError noHints $
hang (text "Could not find hi interface for signature" <+>
quotes (ppr isig_mod) <> colon) 4 err
@@ -1029,7 +1031,8 @@ checkImplements impl_mod req_mod@(Module uid mod_name) = do
-- we need. (Notice we IGNORE the Modules in the AvailInfos.)
forM_ (exportOccs (mi_exports isig_iface)) $ \occ ->
case lookupGlobalRdrEnv impl_gr occ of
- [] -> addErr $ quotes (ppr occ)
+ [] -> addErr $ TcRnUnknownMessage $ mkPlainError noHints $
+ quotes (ppr occ)
<+> text "is exported by the hsig file, but not exported by the implementing module"
<+> quotes (pprWithUnitState unit_state $ ppr impl_mod)
_ -> return ()