summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-09-22 09:05:41 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-05 14:34:04 -0400
commitf52df067d288a023c52c4387841fe12a37bd1263 (patch)
treedf064b1a5b13277747c0c135a1a2966e839f4aa3 /compiler/GHC/Tc
parent5282eaa17f976edc5bb2e43127fa40ab413a1441 (diff)
downloadhaskell-f52df067d288a023c52c4387841fe12a37bd1263.tar.gz
Make GHC.Utils.Error.Validity type polymorphic
This commit makes the `Validity` type polymorphic: ``` data Validity' a = IsValid -- ^ Everything is fine | NotValid a -- ^ A problem, and some indication of why -- | Monomorphic version of @Validity'@ specialised for 'SDoc's. type Validity = Validity' SDoc ``` The type has been (provisionally) renamed to Validity' to not break existing code, as the monomorphic `Validity` type is quite pervasive in a lot of signatures in GHC. Why having a polymorphic Validity? Because it carries the evidence of "what went wrong", but the old type carried an `SDoc`, which clashed with the new GHC diagnostic infrastructure (#18516). Having it polymorphic it means we can carry an arbitrary, richer diagnostic type, and this is very important for things like the `checkOriginativeSideConditions` function, which needs to report the actual diagnostic error back to `GHC.Tc.Deriv`. It also generalises Validity-related functions to be polymorphic in @a@.
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r--compiler/GHC/Tc/Deriv/Generics.hs2
-rw-r--r--compiler/GHC/Tc/Instance/FunDeps.hs2
-rw-r--r--compiler/GHC/Tc/Utils/TcType.hs2
3 files changed, 3 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Deriv/Generics.hs b/compiler/GHC/Tc/Deriv/Generics.hs
index 4aeac0ceae..4ad9c8b849 100644
--- a/compiler/GHC/Tc/Deriv/Generics.hs
+++ b/compiler/GHC/Tc/Deriv/Generics.hs
@@ -47,7 +47,7 @@ import GHC.Builtin.Names
import GHC.Tc.Utils.Env
import GHC.Tc.Utils.Monad
import GHC.Driver.Session
-import GHC.Utils.Error( Validity(..), andValid )
+import GHC.Utils.Error( Validity'(..), Validity, andValid )
import GHC.Types.SrcLoc
import GHC.Data.Bag
import GHC.Types.Var.Env
diff --git a/compiler/GHC/Tc/Instance/FunDeps.hs b/compiler/GHC/Tc/Instance/FunDeps.hs
index 8a54e03b7e..9abfc31f0b 100644
--- a/compiler/GHC/Tc/Instance/FunDeps.hs
+++ b/compiler/GHC/Tc/Instance/FunDeps.hs
@@ -40,7 +40,7 @@ import GHC.Types.SrcLoc
import GHC.Utils.Outputable
import GHC.Utils.FV
-import GHC.Utils.Error( Validity(..), allValid )
+import GHC.Utils.Error( Validity'(..), Validity, allValid )
import GHC.Utils.Misc
import GHC.Utils.Panic
diff --git a/compiler/GHC/Tc/Utils/TcType.hs b/compiler/GHC/Tc/Utils/TcType.hs
index d878ccc75a..5313ef39d4 100644
--- a/compiler/GHC/Tc/Utils/TcType.hs
+++ b/compiler/GHC/Tc/Utils/TcType.hs
@@ -228,7 +228,7 @@ import GHC.Data.List.SetOps ( getNth, findDupsEq )
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
-import GHC.Utils.Error( Validity(..), isValid )
+import GHC.Utils.Error( Validity'(..), Validity, isValid )
import qualified GHC.LanguageExtensions as LangExt
import Data.List ( mapAccumL )