simplify parseLedgerAndDo
This commit is contained in:
		
							parent
							
								
									b8b3de0719
								
							
						
					
					
						commit
						59f0a2fabe
					
				
							
								
								
									
										19
									
								
								hledger.hs
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								hledger.hs
									
									
									
									
									
								
							| @ -84,16 +84,15 @@ balance opts args = parseLedgerAndDo opts args printbalance | |||||||
| -- | parse the user's specified ledger file and do some action with it | -- | parse the user's specified ledger file and do some action with it | ||||||
| -- (or report a parse error). This function makes the whole thing go. | -- (or report a parse error). This function makes the whole thing go. | ||||||
| parseLedgerAndDo :: [Opt] -> [String] -> (Ledger -> IO ()) -> IO () | parseLedgerAndDo :: [Opt] -> [String] -> (Ledger -> IO ()) -> IO () | ||||||
| parseLedgerAndDo opts args cmd = do | parseLedgerAndDo opts args cmd =  | ||||||
|   parsed <- ledgerFilePathFromOpts opts >>= parseLedgerFile |     ledgerFilePathFromOpts opts >>= parseLedgerFile >>= either parseError runthecommand | ||||||
|   case parsed of Left err -> parseError err |     where | ||||||
|                  Right l -> cmd $ cacheLedger $ filterLedger begin end aregex dregex l |       runthecommand = cmd . cacheLedger . filterLedger begin end aregex dregex | ||||||
|   where |       begin = beginDateFromOpts opts | ||||||
|     (apats,dpats) = parsePatternArgs args |       end = endDateFromOpts opts | ||||||
|     aregex = regexFor apats |       aregex = regexFor apats | ||||||
|     dregex = regexFor dpats |       dregex = regexFor dpats | ||||||
|     begin = beginDateFromOpts opts |       (acctpats,descpats) = parsePatternArgs args | ||||||
|     end = endDateFromOpts opts |  | ||||||
| 
 | 
 | ||||||
| -- ghci helpers | -- ghci helpers | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user