]> dgit.raspbian.org Git - git-annex.git/commitdiff
Fix build with ghc-8.8.x.
authorPeter Simons <simons@cryp.to>
Fri, 28 Feb 2020 10:56:48 +0000 (11:56 +0100)
committerJoey Hess <joeyh@joeyh.name>
Fri, 28 Feb 2020 16:54:20 +0000 (12:54 -0400)
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.

CmdLine/GitAnnex/Options.hs
Command/Expire.hs
Command/Init.hs
Utility/HumanTime.hs

index 030c83dd5e44475b49704c4c071bcc5af8d6a1f3..a9a36d76f1f578dacbb3e6fdfab9debea52b87d9 100644 (file)
@@ -9,6 +9,7 @@
 
 module CmdLine.GitAnnex.Options where
 
+import Control.Monad.Fail as Fail ( MonadFail(..) )
 import Options.Applicative
 import qualified Data.Map as M
 
@@ -215,8 +216,8 @@ parseAllOption = flag' WantAllKeys
        <> help "operate on all versions of all files"
        )
 
-parseKey :: Monad m => String -> m Key
-parseKey = maybe (fail "invalid key") return . deserializeKey
+parseKey :: MonadFail m => String -> m Key
+parseKey = maybe (Fail.fail "invalid key") return . deserializeKey
 
 -- Options to match properties of annexed files.
 annexedMatchingOptions :: [GlobalOption]
index 83c38e5698f0c063795ba93e6af5ede3f7843e1e..37dc33883b5a7dc8a75ea30fa8df821328b202a1 100644 (file)
@@ -17,6 +17,7 @@ import Annex.VectorClock
 import qualified Remote
 import Utility.HumanTime
 
+import Control.Monad.Fail as Fail ( MonadFail(..) )
 import Data.Time.Clock.POSIX
 import qualified Data.Map as M
 
@@ -105,9 +106,9 @@ parseExpire ps = do
                Nothing -> giveup $ "bad expire time: " ++ s
                Just d -> Just (now - durationToPOSIXTime d)
 
-parseActivity :: Monad m => String -> m Activity
+parseActivity :: MonadFail m => String -> m Activity
 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])
        Just v -> return v
 
index db6cb14fb97a8cbf699818adc08d1b7b5a021cb0..879a1110f231f3d26661a29307ec9648a570491d 100644 (file)
@@ -13,6 +13,7 @@ import Annex.Version
 import Types.RepoVersion
 import qualified Annex.SpecialRemote
 
+import Control.Monad.Fail as Fail ( MonadFail(..) )
 import qualified Data.Map as M
        
 cmd :: Command
@@ -33,14 +34,14 @@ optParser desc = InitOptions
                <> help "Override default annex.version"
                ))
 
-parseRepoVersion :: Monad m => String -> m RepoVersion
+parseRepoVersion :: MonadFail m => String -> m RepoVersion
 parseRepoVersion s = case RepoVersion <$> readish s of
-       Nothing -> fail $ "version parse error"
+       Nothing -> Fail.fail $ "version parse error"
        Just v
                | v `elem` supportedVersions -> return v
                | otherwise -> case M.lookup v autoUpgradeableVersions of
                        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 = commandAction . start
index 01fbeacfb6ee62a6648be6fc19b44cdac40fa564..d2e70f332fb09e74e280bbde6bc2b60514c9f913 100644 (file)
@@ -19,6 +19,7 @@ module Utility.HumanTime (
 import Utility.PartialPrelude
 import Utility.QuickCheck
 
+import Control.Monad.Fail as Fail ( MonadFail(..) )
 import qualified Data.Map as M
 import Data.Time.Clock
 import Data.Time.Clock.POSIX (POSIXTime)
@@ -44,7 +45,7 @@ daysToDuration :: Integer -> Duration
 daysToDuration i = Duration $ i * dsecs
 
 {- 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
   where
        go n [] = return n
@@ -55,7 +56,7 @@ parseDuration = maybe parsefail (return . Duration) . go 0
                                u <- M.lookup c unitmap
                                go (n + num * u) rest
                        _ -> 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 { durationSeconds = d }