Commit fe7eac51 authored by dterei's avatar dterei

SafeHaskell: Try to be consistent in naming.

parent e2ce80dc
......@@ -533,9 +533,7 @@ addFingerprints hsc_env mb_old_fingerprint iface0 new_decls
-- dep_pkgs: see "Package Version Changes" on
-- wiki/Commentary/Compiler/RecompilationAvoidance
mi_trust iface0)
-- TODO: Can probably make more fine grained. Only
-- really need to have recompilation for overlapping
-- instances.
-- Make sure change of Safe Haskell mode causes recomp.
-- put the declarations in a canonical order, sorted by OccName
let sorted_decls = Map.elems $ Map.fromList $
......@@ -924,7 +922,7 @@ mk_usage_info pit hsc_env this_mod direct_imports used_names
Just _ -> pprPanic "mkUsage: empty direct import" empty
Nothing -> (False, safeImplicitImpsReq dflags)
-- Nothing case is for implicit imports like 'System.IO' when 'putStrLn'
-- is used in the source code. We require them to be safe in SafeHaskell
-- is used in the source code. We require them to be safe in Safe Haskell
used_occs = lookupModuleEnv ent_map mod `orElse` []
......
......@@ -34,11 +34,11 @@ import Data.List
data Flag m = Flag
{ flagName :: String, -- Flag, without the leading "-"
flagSafety :: FlagSafety, -- Flag safety level (SafeHaskell)
flagSafety :: FlagSafety, -- Flag safety level (Safe Haskell)
flagOptKind :: OptKind m -- What to do if we see it
}
-- | This determines how a flag should behave when SafeHaskell
-- | This determines how a flag should behave when Safe Haskell
-- mode is on.
data FlagSafety
= EnablesSafe -- ^ This flag is a little bit of a hack. We give
......@@ -107,7 +107,7 @@ setArg l s (EwM f) = EwM (\_ _ c es ws ->
| otherwise = err l es ws
err (L loc ('-' : arg)) es ws =
let msg = "Warning: " ++ arg ++ " is not allowed in "
++ "SafeHaskell; ignoring " ++ arg
++ "Safe Haskell; ignoring " ++ arg
in return (es, ws `snocBag` L loc msg, ())
err _ _ _ = error "Bad pattern match in setArg"
in check)
......
......@@ -32,11 +32,12 @@ module DynFlags (
DPHBackend(..), dphPackageMaybe,
wayNames,
-- ** SafeHaskell
-- ** Safe Haskell
SafeHaskellMode(..),
safeHaskellOn, safeLanguageOn,
safeDirectImpsReq, safeImplicitImpsReq,
-- ** System tool settings and locations
Settings(..),
ghcUsagePath, ghciUsagePath, topDir, tmpDir, rawSettings,
extraGccViaCFlags, systemPackageConfig,
......@@ -325,7 +326,7 @@ data DynFlag
data Language = Haskell98 | Haskell2010
-- | The various SafeHaskell modes
-- | The various Safe Haskell modes
data SafeHaskellMode
= Sf_None
| Sf_SafeImports
......@@ -979,17 +980,18 @@ setLanguage l = upd f
extensionFlags = flattenExtensionFlags mLang oneoffs
}
-- | Is the Safe Haskell safe language in use
safeLanguageOn :: DynFlags -> Bool
safeLanguageOn dflags = s == Sf_SafeLanguage
|| s == Sf_TrustworthyWithSafeLanguage
|| s == Sf_Safe
where s = safeHaskell dflags
-- | Test if SafeHaskell is on in some form
-- | Test if Safe Haskell is on in some form
safeHaskellOn :: DynFlags -> Bool
safeHaskellOn dflags = safeHaskell dflags /= Sf_None
-- | Set a 'SafeHaskell' flag
-- | Set a 'Safe Haskell' flag
setSafeHaskell :: SafeHaskellMode -> DynP ()
setSafeHaskell s = updM f
where f dfs = do
......@@ -997,18 +999,18 @@ setSafeHaskell s = updM f
safeM <- combineSafeFlags sf s
return $ dfs { safeHaskell = safeM }
-- | Are all direct imports required to be safe for this SafeHaskell mode?
-- | Are all direct imports required to be safe for this Safe Haskell mode?
-- Direct imports are when the code explicitly imports a module
safeDirectImpsReq :: DynFlags -> Bool
safeDirectImpsReq = safeLanguageOn
-- | Are all implicit imports required to be safe for this SafeHaskell mode?
-- | Are all implicit imports required to be safe for this Safe Haskell mode?
-- Implicit imports are things in the prelude. e.g System.IO when print is used.
safeImplicitImpsReq :: DynFlags -> Bool
safeImplicitImpsReq = safeLanguageOn
-- | Combine two SafeHaskell modes correctly. Used for dealing with multiple flags.
-- This makes SafeHaskell very much a monoid but for now I prefer this as I don't
-- | Combine two Safe Haskell modes correctly. Used for dealing with multiple flags.
-- This makes Safe Haskell very much a monoid but for now I prefer this as I don't
-- want to export this functionality from the module but do want to export the
-- type constructors.
combineSafeFlags :: SafeHaskellMode -> SafeHaskellMode -> DynP SafeHaskellMode
......@@ -1038,7 +1040,7 @@ combineSafeFlags a b =
| otherwise -> err
where err = do
let s = "Incompatible SafeHaskell flags! (" ++ showPpr a ++ ", " ++ showPpr b ++ ")"
let s = "Incompatible Safe Haskell flags! (" ++ showPpr a ++ ", " ++ showPpr b ++ ")"
addErr s
return $ panic s -- Just for saftey instead of returning say, a
......@@ -1271,7 +1273,7 @@ shFlagsDisallowed dflags = foldl check_method (dflags, []) bad_flags
flip xopt_unset Opt_TemplateHaskell)]
safeFailure str = [L noSrcSpan $ "Warning: " ++ str ++ " is not allowed in"
++ " SafeHaskell; ignoring " ++ str]
++ " Safe Haskell; ignoring " ++ str]
{- **********************************************************************
......
......@@ -778,7 +778,7 @@ hscFileFrontEnd mod_summary = do
ioMsgMaybe $
tcRnModule hsc_env (ms_hsc_src mod_summary) False rdr_module
dflags <- getDynFlags
-- XXX: See Note [SafeHaskell API]
-- XXX: See Note [Safe Haskell API]
if safeHaskellOn dflags
then do
tcg_env1 <- checkSafeImports dflags hsc_env tcg_env
......
......@@ -113,7 +113,7 @@ requirements from B? Should A now also require that a package p is trusted since
B required it?
We currently say no but I saying yes also makes sense. The difference is, if a
module M that doesn't use SafeHaskell imports a module N that does, should all
module M that doesn't use Safe Haskell imports a module N that does, should all
the trusted package requirements be dropped since M didn't declare that it cares
about Safe Haskell (so -XSafe is more strongly associated with the module doing
the importing) or should it be done still since the author of the module N that
......@@ -121,8 +121,8 @@ uses Safe Haskell said they cared (so -XSafe is more strongly associated with
the module that was compiled that used it).
Going with yes is a simpler semantics we think and harder for the user to stuff
up but it does mean that SafeHaskell will affect users who don't care about
SafeHaskell as they might grab a package from Cabal which uses safe haskell (say
up but it does mean that Safe Haskell will affect users who don't care about
Safe Haskell as they might grab a package from Cabal which uses safe haskell (say
network) and that packages imports -XTrustworthy modules from another package
(say bytestring), so requires that package is trusted. The user may now get
compilation errors in code that doesn't do anything with Safe Haskell simply
......
......@@ -621,7 +621,7 @@ reportOverlap ctxt inst_envs orig pred@(ClassP clas tys)
any ev_var_matches (immSuperClasses clas' tys')
ev_var_matches _ = False
-- Overlap error because of SafeHaskell (first match should be the most
-- Overlap error because of Safe Haskell (first match should be the most
-- specific match)
mk_overlap_msg (matches, _unifiers, True)
= ASSERT( length matches > 1 )
......
......@@ -432,7 +432,7 @@ lookupInstEnv :: (InstEnv, InstEnv) -- External and home package inst-env
-> ([InstMatch], -- Successful matches
[Instance], -- These don't match but do unify
Bool) -- True if error condition caused by
-- SafeHaskell condition.
-- Safe Haskell condition.
-- The second component of the result pair happens when we look up
-- Foo [a]
......@@ -462,7 +462,7 @@ lookupInstEnv (pkg_ie, home_ie) cls tys
-- misleading (complaining of multiple matches when some should be
-- overlapped away)
-- SafeHaskell: We restrict code compiled in 'Safe' mode from
-- 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
......
......@@ -1322,7 +1322,7 @@ runScript filename = do
else return ()
-----------------------------------------------------------------------------
-- Displaying SafeHaskell properties of a module
-- Displaying Safe Haskell properties of a module
isSafeCmd :: String -> InputT GHCi ()
isSafeCmd m =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment