Fix build with ghc-8.8.x.
The 'fail' method has been moved to the 'MonadFail' class. I made the changes so that the code still compiles with previous versions of 'base' that don't have the new MonadFail class exported by Prelude yet.
This commit is contained in:
parent
c257951b85
commit
73cf523a4b
4 changed files with 13 additions and 9 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
module CmdLine.GitAnnex.Options where
|
module CmdLine.GitAnnex.Options where
|
||||||
|
|
||||||
|
import Control.Monad.Fail as Fail ( MonadFail(..) )
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
|
@ -215,8 +216,8 @@ parseAllOption = flag' WantAllKeys
|
||||||
<> help "operate on all versions of all files"
|
<> help "operate on all versions of all files"
|
||||||
)
|
)
|
||||||
|
|
||||||
parseKey :: Monad m => String -> m Key
|
parseKey :: MonadFail m => String -> m Key
|
||||||
parseKey = maybe (fail "invalid key") return . deserializeKey
|
parseKey = maybe (Fail.fail "invalid key") return . deserializeKey
|
||||||
|
|
||||||
-- Options to match properties of annexed files.
|
-- Options to match properties of annexed files.
|
||||||
annexedMatchingOptions :: [GlobalOption]
|
annexedMatchingOptions :: [GlobalOption]
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Annex.VectorClock
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import Utility.HumanTime
|
import Utility.HumanTime
|
||||||
|
|
||||||
|
import Control.Monad.Fail as Fail ( MonadFail(..) )
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
|
@ -105,9 +106,9 @@ parseExpire ps = do
|
||||||
Nothing -> giveup $ "bad expire time: " ++ s
|
Nothing -> giveup $ "bad expire time: " ++ s
|
||||||
Just d -> Just (now - durationToPOSIXTime d)
|
Just d -> Just (now - durationToPOSIXTime d)
|
||||||
|
|
||||||
parseActivity :: Monad m => String -> m Activity
|
parseActivity :: MonadFail m => String -> m Activity
|
||||||
parseActivity s = case readish s of
|
parseActivity s = case readish s of
|
||||||
Nothing -> fail $ "Unknown activity. Choose from: " ++
|
Nothing -> Fail.fail $ "Unknown activity. Choose from: " ++
|
||||||
unwords (map show [minBound..maxBound :: Activity])
|
unwords (map show [minBound..maxBound :: Activity])
|
||||||
Just v -> return v
|
Just v -> return v
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import Annex.Version
|
||||||
import Types.RepoVersion
|
import Types.RepoVersion
|
||||||
import qualified Annex.SpecialRemote
|
import qualified Annex.SpecialRemote
|
||||||
|
|
||||||
|
import Control.Monad.Fail as Fail ( MonadFail(..) )
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
|
@ -33,14 +34,14 @@ optParser desc = InitOptions
|
||||||
<> help "Override default annex.version"
|
<> help "Override default annex.version"
|
||||||
))
|
))
|
||||||
|
|
||||||
parseRepoVersion :: Monad m => String -> m RepoVersion
|
parseRepoVersion :: MonadFail m => String -> m RepoVersion
|
||||||
parseRepoVersion s = case RepoVersion <$> readish s of
|
parseRepoVersion s = case RepoVersion <$> readish s of
|
||||||
Nothing -> fail $ "version parse error"
|
Nothing -> Fail.fail $ "version parse error"
|
||||||
Just v
|
Just v
|
||||||
| v `elem` supportedVersions -> return v
|
| v `elem` supportedVersions -> return v
|
||||||
| otherwise -> case M.lookup v autoUpgradeableVersions of
|
| otherwise -> case M.lookup v autoUpgradeableVersions of
|
||||||
Just v' -> return v'
|
Just v' -> return v'
|
||||||
Nothing -> fail $ s ++ " is not a currently supported repository version"
|
Nothing -> Fail.fail $ s ++ " is not a currently supported repository version"
|
||||||
|
|
||||||
seek :: InitOptions -> CommandSeek
|
seek :: InitOptions -> CommandSeek
|
||||||
seek = commandAction . start
|
seek = commandAction . start
|
||||||
|
|
|
@ -19,6 +19,7 @@ module Utility.HumanTime (
|
||||||
import Utility.PartialPrelude
|
import Utility.PartialPrelude
|
||||||
import Utility.QuickCheck
|
import Utility.QuickCheck
|
||||||
|
|
||||||
|
import Control.Monad.Fail as Fail ( MonadFail(..) )
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Data.Time.Clock.POSIX (POSIXTime)
|
import Data.Time.Clock.POSIX (POSIXTime)
|
||||||
|
@ -44,7 +45,7 @@ daysToDuration :: Integer -> Duration
|
||||||
daysToDuration i = Duration $ i * dsecs
|
daysToDuration i = Duration $ i * dsecs
|
||||||
|
|
||||||
{- Parses a human-input time duration, of the form "5h", "1m", "5h1m", etc -}
|
{- Parses a human-input time duration, of the form "5h", "1m", "5h1m", etc -}
|
||||||
parseDuration :: Monad m => String -> m Duration
|
parseDuration :: MonadFail m => String -> m Duration
|
||||||
parseDuration = maybe parsefail (return . Duration) . go 0
|
parseDuration = maybe parsefail (return . Duration) . go 0
|
||||||
where
|
where
|
||||||
go n [] = return n
|
go n [] = return n
|
||||||
|
@ -55,7 +56,7 @@ parseDuration = maybe parsefail (return . Duration) . go 0
|
||||||
u <- M.lookup c unitmap
|
u <- M.lookup c unitmap
|
||||||
go (n + num * u) rest
|
go (n + num * u) rest
|
||||||
_ -> return $ n + num
|
_ -> return $ n + num
|
||||||
parsefail = fail "duration parse error; expected eg \"5m\" or \"1h5m\""
|
parsefail = Fail.fail "duration parse error; expected eg \"5m\" or \"1h5m\""
|
||||||
|
|
||||||
fromDuration :: Duration -> String
|
fromDuration :: Duration -> String
|
||||||
fromDuration Duration { durationSeconds = d }
|
fromDuration Duration { durationSeconds = d }
|
||||||
|
|
Loading…
Reference in a new issue