From 506cf18885148251ada3e1fcfb0c96072e5c7c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Mon, 3 Nov 2014 00:30:53 +0100 Subject: [PATCH] Don't use fromJust --- Language/Haskell/GhcMod/Monad.hs | 7 ++++--- test/CabalApiSpec.hs | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Language/Haskell/GhcMod/Monad.hs b/Language/Haskell/GhcMod/Monad.hs index 2e0cb4b..b2f1d96 100644 --- a/Language/Haskell/GhcMod/Monad.hs +++ b/Language/Haskell/GhcMod/Monad.hs @@ -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 diff --git a/test/CabalApiSpec.hs b/test/CabalApiSpec.hs index 7f8e24f..a23c5f6 100644 --- a/test/CabalApiSpec.hs +++ b/test/CabalApiSpec.hs @@ -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