| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Hledger.Data.PeriodData
Contents
Description
Data values for zero or more report periods, and for the pre-report period. Report periods are assumed to be contiguous, and represented only by start dates (as keys of an IntMap).
Synopsis
- periodDataFromList :: a -> [(Day, a)] -> PeriodData a
- periodDataToList :: PeriodData a -> (a, [(Day, a)])
- lookupPeriodData :: Day -> PeriodData a -> Maybe (Day, a)
- lookupPeriodDataOrHistorical :: Day -> PeriodData a -> (Maybe Day, a)
- insertPeriodData :: Semigroup a => Maybe Day -> a -> PeriodData a -> PeriodData a
- opPeriodData :: (a -> b -> c) -> PeriodData a -> PeriodData b -> PeriodData c
- mergePeriodData :: (a -> c) -> (b -> c) -> (a -> b -> c) -> PeriodData a -> PeriodData b -> PeriodData c
- padPeriodData :: a -> PeriodData b -> PeriodData a -> PeriodData a
- tests_PeriodData :: TestTree
Documentation
periodDataFromList :: a -> [(Day, a)] -> PeriodData a Source #
Construct a PeriodData from a historical data value and a list of (period start, period data) pairs.
periodDataToList :: PeriodData a -> (a, [(Day, a)]) Source #
Convert PeriodData to a historical data value and a list of (period start, period data) pairs.
lookupPeriodData :: Day -> PeriodData a -> Maybe (Day, a) Source #
Get the data for the period containing the given Day, and that period's start date.
If the day is after the end of the last period, it is assumed to be within the last period.
If the day is before the start of the first period (ie, in the historical period), return Nothing.
lookupPeriodDataOrHistorical :: Day -> PeriodData a -> (Maybe Day, a) Source #
Get the data for the period containing the given Day, and that period's start date.
If the day is after the end of the last period, it is assumed to be within the last period.
If the day is before the start of the first period (ie, in the historical period),
return the data for the historical period and no start date.
insertPeriodData :: Semigroup a => Maybe Day -> a -> PeriodData a -> PeriodData a Source #
Set historical or period data in the appropriate location in a PeriodData.
opPeriodData :: (a -> b -> c) -> PeriodData a -> PeriodData b -> PeriodData c Source #
Merge two PeriodData, using the given operation to combine their data values.
This will drop keys if they are not present in both PeriodData.
mergePeriodData :: (a -> c) -> (b -> c) -> (a -> b -> c) -> PeriodData a -> PeriodData b -> PeriodData c Source #
Merge two PeriodData, using the given operations for combining data
that's only in the first, only in the second, or in both, respectively.
padPeriodData :: a -> PeriodData b -> PeriodData a -> PeriodData a Source #
Pad out the date map of a PeriodData so that every key from another PeriodData is present.
Orphan instances
| Foldable PeriodData Source # | |
Methods fold :: Monoid m => PeriodData m -> m # foldMap :: Monoid m => (a -> m) -> PeriodData a -> m # foldMap' :: Monoid m => (a -> m) -> PeriodData a -> m # foldr :: (a -> b -> b) -> b -> PeriodData a -> b # foldr' :: (a -> b -> b) -> b -> PeriodData a -> b # foldl :: (b -> a -> b) -> b -> PeriodData a -> b # foldl' :: (b -> a -> b) -> b -> PeriodData a -> b # foldr1 :: (a -> a -> a) -> PeriodData a -> a # foldl1 :: (a -> a -> a) -> PeriodData a -> a # toList :: PeriodData a -> [a] # null :: PeriodData a -> Bool # length :: PeriodData a -> Int # elem :: Eq a => a -> PeriodData a -> Bool # maximum :: Ord a => PeriodData a -> a # minimum :: Ord a => PeriodData a -> a # sum :: Num a => PeriodData a -> a # product :: Num a => PeriodData a -> a # | |
| Foldable1 PeriodData Source # | |
Methods fold1 :: Semigroup m => PeriodData m -> m # foldMap1 :: Semigroup m => (a -> m) -> PeriodData a -> m # foldMap1' :: Semigroup m => (a -> m) -> PeriodData a -> m # toNonEmpty :: PeriodData a -> NonEmpty a # maximum :: Ord a => PeriodData a -> a # minimum :: Ord a => PeriodData a -> a # head :: PeriodData a -> a # last :: PeriodData a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> PeriodData a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> PeriodData a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> PeriodData a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> PeriodData a -> b # | |
| Traversable PeriodData Source # | |
Methods traverse :: Applicative f => (a -> f b) -> PeriodData a -> f (PeriodData b) # sequenceA :: Applicative f => PeriodData (f a) -> f (PeriodData a) # mapM :: Monad m => (a -> m b) -> PeriodData a -> m (PeriodData b) # sequence :: Monad m => PeriodData (m a) -> m (PeriodData a) # | |
| Monoid a => Monoid (PeriodData a) Source # | |
Methods mempty :: PeriodData a # mappend :: PeriodData a -> PeriodData a -> PeriodData a # mconcat :: [PeriodData a] -> PeriodData a # | |
| Semigroup a => Semigroup (PeriodData a) Source # | The Semigroup instance for |
Methods (<>) :: PeriodData a -> PeriodData a -> PeriodData a # sconcat :: NonEmpty (PeriodData a) -> PeriodData a # stimes :: Integral b => b -> PeriodData a -> PeriodData a # | |
| Show a => Show (PeriodData a) Source # | |
Methods showsPrec :: Int -> PeriodData a -> ShowS # show :: PeriodData a -> String # showList :: [PeriodData a] -> ShowS # | |