hledger-lib-1.51.1: A library providing the core functionality of hledger
Safe HaskellNone
LanguageGHC2021

Hledger.Data.PeriodData

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

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

Semigroup a => Semigroup (PeriodData a) Source #

The Semigroup instance for PeriodData simply takes the union of keys in the date map section. This may not be the result you want if the keys are not identical.

Instance details

Show a => Show (PeriodData a) Source # 
Instance details