summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2013-08-19 16:00:55 -0700
committerDavid Terei <davidterei@gmail.com>2013-08-19 16:00:55 -0700
commit6cc7d3f120d62d15ad6a2cc3393c3f744c93ff18 (patch)
treeec059df0947c965bc70a24cec9f352a23c747197
parent4eeccc1ce80df7cc96bf72a5cd8a2397b03e2b35 (diff)
downloadhaskell-6cc7d3f120d62d15ad6a2cc3393c3f744c93ff18.tar.gz
Add note on isSafeOverlap field.
-rw-r--r--compiler/basicTypes/BasicTypes.lhs3
-rw-r--r--compiler/types/InstEnv.lhs18
2 files changed, 13 insertions, 8 deletions
diff --git a/compiler/basicTypes/BasicTypes.lhs b/compiler/basicTypes/BasicTypes.lhs
index 35b0ac5b3d..838e368ea6 100644
--- a/compiler/basicTypes/BasicTypes.lhs
+++ b/compiler/basicTypes/BasicTypes.lhs
@@ -362,6 +362,9 @@ instance Outputable RecFlag where
%************************************************************************
\begin{code}
+-- | The semantics allowed for overlapping instances for a particular
+-- instance. See Note [Safe Haskell isSafeOverlap] (in `InstEnv.lhs`) for a
+-- explanation of the `isSafeOverlap` field.
data OverlapFlag
-- | This instance must not overlap another
= NoOverlap { isSafeOverlap :: Bool }
diff --git a/compiler/types/InstEnv.lhs b/compiler/types/InstEnv.lhs
index 18d67d8053..6b6ddcdbb3 100644
--- a/compiler/types/InstEnv.lhs
+++ b/compiler/types/InstEnv.lhs
@@ -582,14 +582,16 @@ lookupInstEnv (pkg_ie, home_ie) cls tys
-- misleading (complaining of multiple matches when some should be
-- overlapped away)
- -- Safe Haskell: We restrict code compiled in 'Safe' mode from
- -- overriding code compiled in any other mode. The rational is
- -- that code compiled in 'Safe' mode is code that is untrusted
- -- by the ghc user. So we shouldn't let that code change the
- -- behaviour of code the user didn't compile in 'Safe' mode
- -- since that's the code they trust. So 'Safe' instances can only
- -- overlap instances from the same module. A same instance origin
- -- policy for safe compiled instances.
+ -- NOTE [Safe Haskell isSafeOverlap]
+ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -- We restrict code compiled in 'Safe' mode from overriding code
+ -- compiled in any other mode. The rational is that code compiled
+ -- in 'Safe' mode is code that is untrusted by the ghc user. So
+ -- we shouldn't let that code change the behaviour of code the
+ -- user didn't compile in 'Safe' mode since that's the code they
+ -- trust. So 'Safe' instances can only overlap instances from the
+ -- same module. A same instance origin policy for safe compiled
+ -- instances.
check_safe match@(inst,_) others
= case isSafeOverlap (is_flag inst) of
-- most specific isn't from a Safe module so OK