diff options
author | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-01-19 13:04:08 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-01-19 13:31:03 -0500 |
commit | c79473051a8e1647b14f351b72768b74301acc33 (patch) | |
tree | eb25ad044ab8e8b924b9fea02af4a264c998536e /Command | |
parent | 44df82dcbf72d01d2bbb6c0afacff329ca749854 (diff) |
Deal with the MonadFail proposal
base-4.9 split MonadFail from Monad. Strengthen some type signatures to
require MonadFail instead of just Monad, derive MonadFail in relevant
places, and change a partial pattern match inside STM to one that
explicitly calls error. (STM is not a MonadFail; the user must
explicitly specify the desired semantics if a pattern match doesn’t work
out. In this case, the failing branch of the pattern should never be
reached, so crashing is fine.)
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Expire.hs | 3 | ||||
-rw-r--r-- | Command/Init.hs | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/Command/Expire.hs b/Command/Expire.hs index 28f90dfb5..bb65d5cfe 100644 --- a/Command/Expire.hs +++ b/Command/Expire.hs @@ -1,6 +1,7 @@ {- git-annex command - - Copyright 2015 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - Licensed under the GNU GPL version 3 or higher. -} @@ -108,7 +109,7 @@ 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: " ++ unwords (map show [minBound..maxBound :: Activity]) diff --git a/Command/Init.hs b/Command/Init.hs index 8ce82a75e..e12c6700c 100644 --- a/Command/Init.hs +++ b/Command/Init.hs @@ -1,6 +1,7 @@ {- git-annex command - - Copyright 2010 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - Licensed under the GNU GPL version 3 or higher. -} @@ -30,7 +31,7 @@ optParser desc = InitOptions <> help "Override default annex.version" )) -parseVersion :: Monad m => String -> m Version +parseVersion :: MonadFail m => String -> m Version parseVersion v | v `elem` supportedVersions = return v | otherwise = fail $ v ++ " is not a currently supported repository version" |