Remove GMECabal, GMEGhc constructors from GhcModError for now
This commit is contained in:
parent
c4ae9bc589
commit
e0bbd91eba
@ -20,7 +20,7 @@ import MonadUtils (MonadIO, liftIO)
|
|||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
import qualified Control.Exception as E
|
import qualified Control.Exception as E
|
||||||
import Control.Monad (filterM)
|
import Control.Monad (filterM)
|
||||||
import Control.Monad.Error.Class (MonadError(..))
|
import Control.Monad.Error.Class (Error, MonadError(..))
|
||||||
import Data.Maybe (maybeToList)
|
import Data.Maybe (maybeToList)
|
||||||
import Data.Set (fromList, toList)
|
import Data.Set (fromList, toList)
|
||||||
import Distribution.Package (Dependency(Dependency)
|
import Distribution.Package (Dependency(Dependency)
|
||||||
@ -71,18 +71,17 @@ includeDirectories cdir wdir dirs = uniqueAndSort (extdirs ++ [cdir,wdir])
|
|||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
-- | Parsing a cabal file and returns 'PackageDescription'.
|
-- | Parse a cabal file and return a 'PackageDescription'.
|
||||||
-- 'IOException' is thrown if parsing fails.
|
parseCabalFile :: (MonadIO m, Error e, MonadError e m)
|
||||||
parseCabalFile :: (MonadIO m, MonadError GhcModError m)
|
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> m PackageDescription
|
-> m PackageDescription
|
||||||
parseCabalFile file = do
|
parseCabalFile file = do
|
||||||
cid <- liftIO $ getGHCId
|
cid <- liftIO $ getGHCId
|
||||||
epgd <- liftIO $ readPackageDescription silent file
|
epgd <- liftIO $ readPackageDescription silent file
|
||||||
case toPkgDesc cid epgd of
|
case toPkgDesc cid epgd of
|
||||||
Left deps -> throwError $ GMECabal $ show deps ++ " are not installed"
|
Left deps -> fail $ show deps ++ " are not installed"
|
||||||
Right (pd,_) -> if nullPkg pd
|
Right (pd,_) -> if nullPkg pd
|
||||||
then throwError $ GMECabal $ file ++ " is broken"
|
then fail $ file ++ " is broken"
|
||||||
else return pd
|
else return pd
|
||||||
where
|
where
|
||||||
toPkgDesc cid =
|
toPkgDesc cid =
|
||||||
|
@ -12,8 +12,6 @@ data GhcModError = GMENoMsg
|
|||||||
| GMEString String
|
| GMEString String
|
||||||
-- ^ Some Error with a message. These are produced mostly by
|
-- ^ Some Error with a message. These are produced mostly by
|
||||||
-- 'fail' calls on GhcModT.
|
-- 'fail' calls on GhcModT.
|
||||||
| GMECabal String
|
|
||||||
| GMEGhc
|
|
||||||
deriving (Eq,Show,Read)
|
deriving (Eq,Show,Read)
|
||||||
|
|
||||||
instance Error GhcModError where
|
instance Error GhcModError where
|
||||||
|
Loading…
Reference in New Issue
Block a user