avoid parseDuration succeeding on empty string
This commit is contained in:
parent
b9cfd15e90
commit
794fc72afb
1 changed files with 3 additions and 1 deletions
|
@ -45,7 +45,9 @@ 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 :: String -> Either String Duration
|
parseDuration :: String -> Either String Duration
|
||||||
parseDuration d = maybe parsefail (Right . Duration) $ go 0 d
|
parseDuration d
|
||||||
|
| null d = parsefail
|
||||||
|
| otherwise = maybe parsefail (Right . Duration) $ go 0 d
|
||||||
where
|
where
|
||||||
go n [] = return n
|
go n [] = return n
|
||||||
go n s = do
|
go n s = do
|
||||||
|
|
Loading…
Reference in a new issue