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 /Utility | |
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 'Utility')
-rw-r--r-- | Utility/HumanTime.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Utility/HumanTime.hs b/Utility/HumanTime.hs index fe7cf22a9..77d846d97 100644 --- a/Utility/HumanTime.hs +++ b/Utility/HumanTime.hs @@ -1,8 +1,9 @@ {- Time for humans. - - Copyright 2012-2013 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - - License: BSD-2-clause + - License: Apache-2.0 -} module Utility.HumanTime ( @@ -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 |