diff options
Diffstat (limited to 'Utility/HumanTime.hs')
-rw-r--r-- | Utility/HumanTime.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Utility/HumanTime.hs b/Utility/HumanTime.hs index e8fdb7c6e..fe7cf22a9 100644 --- a/Utility/HumanTime.hs +++ b/Utility/HumanTime.hs @@ -17,7 +17,6 @@ module Utility.HumanTime ( ) where import Utility.PartialPrelude -import Utility.Applicative import Utility.QuickCheck import qualified Data.Map as M @@ -45,8 +44,8 @@ daysToDuration :: Integer -> Duration daysToDuration i = Duration $ i * dsecs {- Parses a human-input time duration, of the form "5h", "1m", "5h1m", etc -} -parseDuration :: String -> Maybe Duration -parseDuration = Duration <$$> go 0 +parseDuration :: Monad m => String -> m Duration +parseDuration = maybe parsefail (return . Duration) . go 0 where go n [] = return n go n s = do @@ -56,6 +55,7 @@ parseDuration = 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\"" fromDuration :: Duration -> String fromDuration Duration { durationSeconds = d } |