import Monad ( when )
import List ( insert )
import Maybes ( orElse, mapCatMaybes, isNothing, isJust,
- fromJust, expectJust, MaybeErr(..) )
+ expectJust, MaybeErr(..) )
\end{code}
-- Debug printing
; when (isJust pp_orphs && dopt Opt_WarnOrphans dflags)
- (printDump (fromJust pp_orphs))
+ (printDump (expectJust "mkIface" pp_orphs))
; when (dopt Opt_D_dump_hi_diffs dflags) (printDump pp_diffs)
; dumpIfSet_dyn dflags Opt_D_dump_hi "FINAL INTERFACE"
(pprModIface new_iface)
-- CHECK EXPORT LIST
if checkExportList maybe_old_export_vers new_export_vers then
out_of_date_vers (ptext SLIT(" Export list changed"))
- (fromJust maybe_old_export_vers)
+ (expectJust "checkModUsage" maybe_old_export_vers)
new_export_vers
else
import Control.Concurrent
import System.Directory ( getModificationTime, doesFileExist )
-import Data.Maybe ( isJust, isNothing, fromJust )
+import Data.Maybe ( isJust, isNothing )
import Data.List ( partition, nub )
import qualified Data.List as List
import Control.Monad ( unless, when )
-- ml_hspp_file field, say
let dflags0 = hsc_dflags hsc_env
hspp_buf = expectJust "GHC.checkModule" (ms_hspp_buf ms)
- filename = fromJust (ml_hs_file (ms_location ms))
+ filename = expectJust "checkModule" (ml_hs_file (ms_location ms))
opts = getOptionsFromStringBuffer hspp_buf filename
(dflags1,leftovers) <- parseDynamicFlags dflags0 (map snd opts)
if (not (null leftovers))
findSummaryBySourceFile :: [ModSummary] -> FilePath -> Maybe ModSummary
findSummaryBySourceFile summaries file
= case [ ms | ms <- summaries, HsSrcFile <- [ms_hsc_src ms],
- fromJust (ml_hs_file (ms_location ms)) == file ] of
+ expectJust "findSummaryBySourceFile" (ml_hs_file (ms_location ms)) == file ] of
[] -> Nothing
(x:xs) -> Just x
Nothing -> panic "missing linkable"
Just mod_info -> return (showModMsg obj_linkable mod_summary)
where
- obj_linkable = isObjectLinkable (fromJust (hm_linkable mod_info))
+ obj_linkable = isObjectLinkable (expectJust "showModule" (hm_linkable mod_info))
#endif /* GHCI */
import FiniteMap ( FiniteMap )
import CoreSyn ( CoreRule )
-import Maybes ( orElse, fromJust, expectJust )
+import Maybes ( orElse, expectJust, expectJust )
import Outputable
import SrcLoc ( SrcSpan, Located )
import UniqSupply ( UniqSupply )
-- Look it up in the HPT
, let mod_info = ASSERT( mod `elemModuleEnv` hpt )
- fromJust (lookupModuleEnv hpt mod)
+ expectJust "hptRules" (lookupModuleEnv hpt mod)
-- And get its dfuns
, rule <- md_rules (hm_details mod_info) ]
import List ( nub )
import Util ( isSingleton )
import ListSetOps ( removeDups )
-import Maybes ( fromJust )
+import Maybes ( expectJust )
import Outputable
import SrcLoc ( Located(..), unLoc, getLoc, cmpLocated )
import FastString
{ -- Find the Names that are bound by stmts
lcl_env <- getLocalRdrEnv
; let { rdr_bndrs = collectLStmtsBinders stmts
- ; bndrs = map ( fromJust
+ ; bndrs = map ( expectJust "rnStmt"
. lookupLocalRdrEnv lcl_env
. unLoc) rdr_bndrs
; new_bndrs = nub bndrs ++ bndrs_so_far
import Bag
import ErrUtils ( Message )
import Digraph ( SCC(..), stronglyConnComp )
-import Maybes ( fromJust, isJust, isNothing, orElse )
+import Maybes ( expectJust, isJust, isNothing, orElse )
import Util ( singleton )
import BasicTypes ( TopLevelFlag(..), isTopLevel, isNotTopLevel,
RecFlag(..), isNonRec, InlineSpec, defaultInlineSpec )
type BKey = Int -- Just number off the bindings
mkEdges sig_fn binds
- = [ (bind, key, [fromJust mb_key | n <- nameSetToList (bind_fvs (unLoc bind)),
- let mb_key = lookupNameEnv key_map n,
- isJust mb_key,
- no_sig n ])
+ = [ (bind, key, [key | n <- nameSetToList (bind_fvs (unLoc bind)),
+ Just key <- [lookupNameEnv key_map n], no_sig n ])
| (bind, key) <- keyd_binds
]
where
mkPragFun :: [LSig Name] -> TcPragFun
mkPragFun sigs = \n -> lookupNameEnv env n `orElse` []
where
- prs = [(fromJust (sigName sig), sig) | sig <- sigs, isPragLSig sig]
+ prs = [(expectJust "mkPragFun" (sigName sig), sig)
+ | sig <- sigs, isPragLSig sig]
env = foldl add emptyNameEnv prs
add env (n,p) = extendNameEnv_Acc (:) singleton env n p
-- Precondition: no duplicates
mkSigFun sigs = lookupNameEnv env
where
- env = mkNameEnv [(fromJust (sigName sig), sig) | sig <- sigs]
+ env = mkNameEnv [(expectJust "mkSigFun" (sigName sig), sig) | sig <- sigs]
---------------
data TcSigInfo
import VarSet ( elemVarSet, mkVarSet )
import Name ( Name, getSrcLoc )
import Outputable
-import Maybe ( isJust, fromJust )
+import Maybe ( isJust )
+import Maybes ( expectJust )
import Unify ( tcMatchTys, tcMatchTyX )
import Util ( zipLazy, isSingleton, notNull, sortLe )
import List ( partition )
; checkTc (isJust mb_subst2) (fieldTypeMisMatch fld con1 con2) }
where
mb_subst1 = tcMatchTys tvs1 res1 res2
- mb_subst2 = tcMatchTyX tvs1 (fromJust mb_subst1) fty1 fty2
+ mb_subst2 = tcMatchTyX tvs1 (expectJust "checkFieldCompat" mb_subst1) fty1 fty2
-------------------------------
checkValidDataCon :: TyCon -> DataCon -> TcM ()
import VarEnv
import Name ( Name, isSystemName )
import ErrUtils ( Message )
-import Maybes ( fromJust, isNothing )
+import Maybes ( expectJust, isNothing )
import BasicTypes ( Arity )
import UniqSupply ( uniqsFromSupply )
import Util ( notNull, equalLength )
; case mb_tys' of
Just tys' -> return (TyConApp tc tys')
-- Retain the synonym (the common case)
- Nothing -> go (fromJust (tcView (TyConApp tc tys)))
+ Nothing -> go (expectJust "checkTauTvUpdate"
+ (tcView (TyConApp tc tys)))
-- Try again, expanding the synonym
}
\end{code}