refactor: cleanup

This commit is contained in:
Simon Michael 2010-04-14 21:37:03 +00:00
parent b19b02962a
commit 331ed6b407
3 changed files with 4 additions and 5 deletions

View File

@ -590,7 +590,7 @@ tests = TestList [
["2009/01/01 медвежья шкура расходы:покупки 100 100"
," актив:наличные -100 0"]
,"smart dates" ~: do
,"fixSmartDateStr" ~: do
let gives = is . fixSmartDateStr (parsedate "2008/11/26")
"1999-12-02" `gives` "1999/12/02"
"1999.12.02" `gives` "1999/12/02"

View File

@ -246,10 +246,7 @@ Assumes any text in the parse stream has been lowercased.
-}
smartdate :: GenParser Char st SmartDate
smartdate = do
let dateparsers = [yyyymmdd, ymd, ym, md, y, d, month, mon, today, yesterday, tomorrow,
lastthisnextthing
]
(y,m,d) <- choice $ map try dateparsers
(y,m,d) <- choice' [yyyymmdd, ymd, ym, md, y, d, month, mon, today, yesterday, tomorrow, lastthisnextthing]
return (y,m,d)
-- | Like smartdate, but there must be nothing other than whitespace after the date.

View File

@ -241,6 +241,8 @@ tracewith f e = trace (f e) e
-- parsing
choice' = choice . map Text.ParserCombinators.Parsec.try
parsewith :: Parser a -> String -> Either ParseError a
parsewith p = parse p ""