export Regexp types, disambiguate CsvReader's

This commit is contained in:
Simon Michael 2014-10-24 14:30:49 -07:00
parent f064ecf138
commit bfedf367c4
2 changed files with 8 additions and 6 deletions

View File

@ -286,10 +286,10 @@ type CsvFieldIndex = Int
type JournalFieldName = String
type FieldTemplate = String
type ConditionalBlock = ([RecordMatcher], [(JournalFieldName, FieldTemplate)]) -- block matches if all RecordMatchers match
type RecordMatcher = [Regexp] -- match if any regexps match any of the csv fields
-- type FieldMatcher = (CsvFieldName, [Regexp]) -- match if any regexps match this csv field
type RecordMatcher = [RegexpPattern] -- match if any regexps match any of the csv fields
-- type FieldMatcher = (CsvFieldName, [RegexpPattern]) -- match if any regexps match this csv field
type DateFormat = String
type Regexp = String
type RegexpPattern = String
rules = CsvRules {
rdirectives=[],
@ -657,7 +657,7 @@ getEffectiveAssignment rules record f = lastMay $ assignmentsFor f
-- matcherMatches pats = any patternMatches pats
matcherMatches pats = patternMatches $ "(" ++ intercalate "|" pats ++ ")"
where
patternMatches :: Regexp -> Bool
patternMatches :: RegexpPattern -> Bool
patternMatches pat = regexMatchesCI pat csvline
where
csvline = intercalate "," record

View File

@ -22,9 +22,11 @@ Easy regular expression helpers, based on regex-tdfa and regexpr. These should
-}
module Hledger.Utils.Regex (
-- regexMatch
Regexp
,Replacement
-- ,regexMatch
-- ,regexMatchCI
regexMatches
,regexMatches
,regexMatchesCI
,containsRegex
,regexReplace