Don't use fromJust

This commit is contained in:
Daniel Gröber 2014-11-03 00:30:53 +01:00
parent 56cc237e26
commit 506cf18885
2 changed files with 6 additions and 4 deletions

View File

@ -99,7 +99,7 @@ import Control.Monad.Error (Error(..))
#endif
import Control.Monad.Journal.Class
import Data.Maybe (fromJust, isJust)
import Data.Maybe (isJust)
import Data.IORef (IORef, readIORef, writeIORef, newIORef)
import System.Directory (getCurrentDirectory)
@ -166,7 +166,7 @@ instance MonadIO m => MonadIO (GhcModT m) where
where
fromEx :: Exception e => SomeException -> e
fromEx = fromJust . fromException
fromEx se = let Just e = fromException se in e
isIOError se =
case fromException se of
Just (_ :: IOError) -> True
@ -221,7 +221,8 @@ initializeFlagsWithCradle opt c
cabal = isJust mCabalFile
ghcopts = ghcUserOptions opt
withCabal = do
pkgDesc <- parseCabalFile c $ fromJust mCabalFile
let Just cabalFile = mCabalFile
pkgDesc <- parseCabalFile c cabalFile
compOpts <- getCompilerOptions ghcopts c pkgDesc
initSession CabalPkg opt compOpts
withSandbox = initSession SingleFile opt compOpts

View File

@ -35,7 +35,8 @@ spec = do
cwd <- getCurrentDirectory
withDirectory "test/data/subdir1/subdir2" $ \dir -> do
crdl <- findCradle
pkgDesc <- runD $ parseCabalFile crdl $ fromJust $ cradleCabalFile crdl
let cabalFile = cradleCabalFile crdl
pkgDesc <- runD $ parseCabalFile crdl cabalFile
res <- runD $ getCompilerOptions [] crdl pkgDesc
let res' = res {
ghcOptions = ghcOptions res