[Git][ghc/ghc][wip/T22717] Accept an orphan declaration (sadly)
sheaf (@sheaf)
gitlab at gitlab.haskell.org
Thu Jan 26 14:03:37 UTC 2023
sheaf pushed to branch wip/T22717 at Glasgow Haskell Compiler / GHC
Commits:
81f69897 by Simon Peyton Jones at 2023-01-26T15:03:37+01:00
Accept an orphan declaration (sadly)
This accepts the orphan type family instance
type instance DsForeignHook = ...
in GHC.HsToCore.Types.
See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks
- - - - -
7 changed files:
- compiler/GHC/Driver/Hooks.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
Changes:
=====================================
compiler/GHC/Driver/Hooks.hs
=====================================
@@ -121,6 +121,9 @@ In doing so, the Hooks module (which is an hs-boot dependency of DynFlags) can
be decoupled from its use of the DsM definition in GHC.HsToCore.Types. Since
both DsM and the definition of @ForeignsHook@ live in the same module, there is
virtually no difference for plugin authors that want to write a foreign hook.
+
+An awkward consequences is that the `type instance DsForeignsHook`, in
+GHC.HsToCore.Types is an orphan instance.
-}
-- See Note [The Decoupling Abstract Data Hack]
=====================================
compiler/GHC/HsToCore/Types.hs
=====================================
@@ -1,5 +1,10 @@
{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
+{-# OPTIONS_GHC -Wno-orphans #-}
+ -- Don't warn that `type instance DsForeignsHooks = ...`
+ -- is an orphan; see Note [The Decoupling Abstract Data Hack]
+ -- in GHC.Driver.Hooks
+
-- | Various types used during desugaring.
module GHC.HsToCore.Types (
DsM, DsLclEnv(..), DsGblEnv(..),
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -418,11 +418,11 @@ instance Diagnostic TcRnMessage where
sep [ text "The Monomorphism Restriction applies to the binding"
<> plural bindings
, text "for" <+> pp_bndrs ]
- TcRnOrphanInst (Left cls_inst)
+ TcRnOrphanInstance (Left cls_inst)
-> mkSimpleDecorated $
hang (text "Orphan class instance:")
2 (pprInstanceHdr cls_inst)
- TcRnOrphanInst (Right fam_inst)
+ TcRnOrphanInstance (Right fam_inst)
-> mkSimpleDecorated $
hang (text "Orphan family instance:")
2 (pprFamInst fam_inst)
@@ -1370,7 +1370,7 @@ instance Diagnostic TcRnMessage where
-> ErrorWithoutFlag
TcRnMonomorphicBindings{}
-> WarningWithFlag Opt_WarnMonomorphism
- TcRnOrphanInst{}
+ TcRnOrphanInstance{}
-> WarningWithFlag Opt_WarnOrphans
TcRnFunDepConflict{}
-> ErrorWithoutFlag
@@ -1786,7 +1786,7 @@ instance Diagnostic TcRnMessage where
-> case bindings of
[] -> noHints
(x:xs) -> [SuggestAddTypeSignatures $ NamedBindings (x NE.:| xs)]
- TcRnOrphanInst clsOrFamInst
+ TcRnOrphanInstance clsOrFamInst
-> [SuggestFixOrphanInst { isFamilyInstance = isFam }]
where
isFam = case clsOrFamInst :: Either ClsInst FamInst of
=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -1079,7 +1079,7 @@ data TcRnMessage where
-}
TcRnMonomorphicBindings :: [Name] -> TcRnMessage
- {-| TcRnOrphanInst is a warning (controlled by -Worphans) that arises when
+ {-| TcRnOrphanInstance is a warning (controlled by -Worphans) that arises when
a typeclass instance or family instance is an \"orphan\", i.e. if it
appears in a module in which neither the class/family nor the type being
instanced are declared in the same module.
@@ -1089,7 +1089,7 @@ data TcRnMessage where
Test cases: warnings/should_compile/T9178
typecheck/should_compile/T4912
-}
- TcRnOrphanInst :: Either ClsInst FamInst -> TcRnMessage
+ TcRnOrphanInstance :: Either ClsInst FamInst -> TcRnMessage
{-| TcRnFunDepConflict is an error that occurs when there are functional dependencies
conflicts between instance declarations.
=====================================
compiler/GHC/Tc/Utils/Instantiate.hs
=====================================
@@ -854,7 +854,7 @@ newClsInst overlap_mode dfun_name tvs theta clas tys
; let cls_inst = mkLocalClsInst dfun oflag tvs' clas tys'
; when (isOrphan (is_orphan cls_inst)) $
- addDiagnostic (TcRnOrphanInst $ Left cls_inst)
+ addDiagnostic (TcRnOrphanInstance $ Left cls_inst)
; return cls_inst }
@@ -992,7 +992,7 @@ newFamInst flavor axiom
; let fam_inst = mkLocalFamInst flavor axiom tvs' cvs' lhs' rhs'
; when (isOrphan (fi_orphan fam_inst)) $
- addDiagnostic (TcRnOrphanInst $ Right fam_inst)
+ addDiagnostic (TcRnOrphanInstance $ Right fam_inst)
; return fam_inst }
=====================================
compiler/GHC/Types/Error/Codes.hs
=====================================
@@ -381,7 +381,7 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnBadAssociatedType" = 38351
GhcDiagnosticCode "TcRnForAllRankErr" = 91510
GhcDiagnosticCode "TcRnMonomorphicBindings" = 55524
- GhcDiagnosticCode "TcRnOrphanInst" = 90177
+ GhcDiagnosticCode "TcRnOrphanInstance" = 90177
GhcDiagnosticCode "TcRnFunDepConflict" = 46208
GhcDiagnosticCode "TcRnDupInstanceDecls" = 59692
GhcDiagnosticCode "TcRnConflictingFamInstDecls" = 34447
=====================================
compiler/GHC/Types/Hint.hs
=====================================
@@ -306,7 +306,7 @@ data GhcHint
{-| Suggests to move an orphan instance (for a typeclass or a type or data
family), or to newtype-wrap it.
- Triggered by: 'GHC.Tc.Errors.Types.TcRnOrphanInst'
+ Triggered by: 'GHC.Tc.Errors.Types.TcRnOrphanInstance'
Test cases(s): warnings/should_compile/T9178
typecheck/should_compile/T4912
indexed-types/should_compile/T22717_fam_orph
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81f69897c7ac70d072782c1a4d9890838969f835
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/81f69897c7ac70d072782c1a4d9890838969f835
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230126/90f15cef/attachment-0001.html>
More information about the ghc-commits
mailing list