Replace couple of fromJust with expectJust
authorClemens Fruhwirth <clemens@endorphin.org>
Fri, 7 Nov 2008 16:07:35 +0000 (16:07 +0000)
committerClemens Fruhwirth <clemens@endorphin.org>
Fri, 7 Nov 2008 16:07:35 +0000 (16:07 +0000)
compiler/ghci/InteractiveUI.hs
compiler/ghci/Linker.lhs
compiler/main/PackageConfig.hs
compiler/typecheck/FamInst.lhs

index 4fdf949..933a98e 100644 (file)
@@ -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
 
index 8ad2be8..0de30af 100644 (file)
@@ -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...
index 1602429..a3fd027 100644 (file)
@@ -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
index 67c526d..5f4b2a3 100644 (file)
@@ -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