From 0f66260b5afc88accb6af6a09b20c3a4de51c39a Mon Sep 17 00:00:00 2001 From: Clemens Fruhwirth Date: Fri, 7 Nov 2008 16:07:35 +0000 Subject: [PATCH] Replace couple of fromJust with expectJust --- compiler/ghci/InteractiveUI.hs | 4 ++-- compiler/ghci/Linker.lhs | 4 +--- compiler/main/PackageConfig.hs | 4 ++-- compiler/typecheck/FamInst.lhs | 6 +++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 4fdf949..933a98e 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -52,7 +52,7 @@ import StaticFlags import Linker import Util import NameSet -import Maybes ( orElse ) +import Maybes ( orElse, expectJust ) import FastString import Encoding import MonadUtils ( liftIO ) @@ -2247,7 +2247,7 @@ listModuleLine modl line = do case this of [] -> panic "listModuleLine" summ:_ -> do - let filename = fromJust (ml_hs_file (GHC.ms_location summ)) + let filename = expectJust "listModuleLine" (ml_hs_file (GHC.ms_location summ)) loc = GHC.mkSrcLoc (mkFastString (filename)) line 0 io $ listAround (GHC.srcLocSpan loc) False diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs index 8ad2be8..0de30af 100644 --- a/compiler/ghci/Linker.lhs +++ b/compiler/ghci/Linker.lhs @@ -78,7 +78,6 @@ import System.Directory import Distribution.Package hiding (depends, PackageId) import Exception -import Data.Maybe \end{code} @@ -638,8 +637,7 @@ getLinkDeps hsc_env hpt _ maybe_normal_osuf span mods get_linkable maybe_normal_osuf mod_name -- A home-package module | Just mod_info <- lookupUFM hpt mod_name - = ASSERT(isJust (hm_linkable mod_info)) - adjust_linkable (fromJust (hm_linkable mod_info)) + = adjust_linkable (Maybes.expectJust "getLinkDeps" (hm_linkable mod_info)) | otherwise = do -- It's not in the HPT because we are in one shot mode, -- so use the Finder to get a ModLocation... diff --git a/compiler/main/PackageConfig.hs b/compiler/main/PackageConfig.hs index 1602429..a3fd027 100644 --- a/compiler/main/PackageConfig.hs +++ b/compiler/main/PackageConfig.hs @@ -21,7 +21,7 @@ module PackageConfig ( #include "HsVersions.h" -import Data.Maybe +import Maybes import Module import Distribution.InstalledPackageInfo import Distribution.ModuleName @@ -80,7 +80,7 @@ packageConfigToInstalledPackageInfo pkgconf{ exposedModules = map convert e, hiddenModules = map convert h } where convert :: Module.ModuleName -> Distribution.ModuleName.ModuleName - convert = fromJust . simpleParse . moduleNameString + convert = (expectJust "packageConfigToInstalledPackageInfo") . simpleParse . moduleNameString -- | Turn an 'InstalledPackageInfo', which contains Cabal 'Distribution.ModuleName.ModuleName's -- into a GHC specific 'PackageConfig' which contains GHC 'Module.ModuleName's diff --git a/compiler/typecheck/FamInst.lhs b/compiler/typecheck/FamInst.lhs index 67c526d..5f4b2a3 100644 --- a/compiler/typecheck/FamInst.lhs +++ b/compiler/typecheck/FamInst.lhs @@ -20,7 +20,7 @@ import LazyUniqFM import FiniteMap import FastString -import Maybe +import Maybes import Monad \end{code} @@ -117,8 +117,8 @@ checkFamInstConsistency famInstMods directlyImpMods -- already loaded in the EPS or they are in the HPT. -- check modInstsEnv (ModulePair m1 m2) - = let { instEnv1 = fromJust . lookupModuleEnv modInstsEnv $ m1 - ; instEnv2 = fromJust . lookupModuleEnv modInstsEnv $ m2 + = let { instEnv1 = (expectJust "checkFamInstConsistency") . lookupModuleEnv modInstsEnv $ m1 + ; instEnv2 = (expectJust "checkFamInstConsistency") . lookupModuleEnv modInstsEnv $ m2 ; insts1 = famInstEnvElts instEnv1 } in -- 1.7.10.4