ref: clean up Query definition

This commit is contained in:
Simon Michael 2022-04-14 11:33:19 -10:00
parent 161c911cb4
commit 4f26309328

View File

@ -95,27 +95,28 @@ import Hledger.Data.Transaction
-- | A query is a composition of search criteria, which can be used to -- | A query is a composition of search criteria, which can be used to
-- match postings, transactions, accounts and more. -- match postings, transactions, accounts and more.
data Query = Any -- ^ always match data Query =
| None -- ^ never match -- compound queries
| Not Query -- ^ negate this match Not Query -- ^ negate this match
| Or [Query] -- ^ match if any of these match | And [Query] -- ^ match if all of these match
| And [Query] -- ^ match if all of these match | Or [Query] -- ^ match if any of these match
| Code Regexp -- ^ match if code matches this regexp -- no-op queries
| Desc Regexp -- ^ match if description matches this regexp | Any -- ^ always match
| Acct Regexp -- ^ match postings whose account matches this regexp | None -- ^ never match
| Date DateSpan -- ^ match if primary date in this date span -- data queries (in "standard" order, roughly as they appear in a transaction)
| Date2 DateSpan -- ^ match if secondary date in this date span | Date DateSpan -- ^ match primary dates in this date span
| StatusQ Status -- ^ match txns/postings with this status | Date2 DateSpan -- ^ match secondary dates in this date span
| Real Bool -- ^ match if "realness" (involves a real non-virtual account ?) has this value | StatusQ Status -- ^ match this txn/posting status
| Amt OrdPlus Quantity -- ^ match if the amount's numeric quantity is less than/greater than/equal to/unsignedly equal to some value | Code Regexp -- ^ match txn codes infix-matched by this regexp
| Sym Regexp -- ^ match if the entire commodity symbol is matched by this regexp | Desc Regexp -- ^ match txn descriptions infix-matched by this regexp
| Depth Int -- ^ match if account depth is less than or equal to this value. | Tag Regexp (Maybe Regexp) -- ^ match if a tag's name, and optionally its value, is infix-matched by the respective regexps
-- Depth is sometimes used like a query (for filtering report data) | Acct Regexp -- ^ match account names infix-matched by this regexp
-- and sometimes like a query option (for controlling display) | Type [AccountType] -- ^ match accounts whose type is one of these (or with no types, any account)
| Tag Regexp (Maybe Regexp) -- ^ match if a tag's name, and optionally its value, is matched by these respective regexps | Depth Int -- ^ match if account depth is less than or equal to this value (or, sometimes used as a display option)
-- matching the regexp if provided, exists | Real Bool -- ^ match postings with this "realness" value
| Type [AccountType] -- ^ match accounts whose type is one of these (or with no types, any account) | Amt OrdPlus Quantity -- ^ match if the amount's numeric quantity is less than/greater than/equal to/unsignedly equal to some value
deriving (Eq,Show) | Sym Regexp -- ^ match if the commodity symbol is fully-matched by this regexp
deriving (Eq,Show)
instance Default Query where def = Any instance Default Query where def = Any