{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
module Hledger.Reports.ReportTypes
( PeriodicReport(..)
, PeriodicReportRow(..)
, Percentage
, Change
, Balance
, Total
, Average
, periodicReportSpan
, prMapName
, prMapMaybeName
, CompoundPeriodicReport(..)
, CBCSubreportSpec(..)
, DisplayName(..)
, flatDisplayName
, treeDisplayName
, prrFullName
, prrDisplayName
, prrDepth
) where
import Data.Aeson (ToJSON(..))
import Data.Decimal (Decimal)
import Data.Maybe (mapMaybe)
import Data.Text (Text)
#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup (Semigroup(..))
#endif
import GHC.Generics (Generic)
import Hledger.Data
import Hledger.Query (Query)
import Hledger.Reports.ReportOptions (ReportOpts)
type Percentage = Decimal
type Change = MixedAmount
type Balance = MixedAmount
type Total = MixedAmount
type Average = MixedAmount
data PeriodicReport a b =
PeriodicReport
{ PeriodicReport a b -> [DateSpan]
prDates :: [DateSpan]
, PeriodicReport a b -> [PeriodicReportRow a b]
prRows :: [PeriodicReportRow a b]
, PeriodicReport a b -> PeriodicReportRow () b
prTotals :: PeriodicReportRow () b
} deriving (Int -> PeriodicReport a b -> ShowS
[PeriodicReport a b] -> ShowS
PeriodicReport a b -> String
(Int -> PeriodicReport a b -> ShowS)
-> (PeriodicReport a b -> String)
-> ([PeriodicReport a b] -> ShowS)
-> Show (PeriodicReport a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> PeriodicReport a b -> ShowS
forall a b. (Show a, Show b) => [PeriodicReport a b] -> ShowS
forall a b. (Show a, Show b) => PeriodicReport a b -> String
showList :: [PeriodicReport a b] -> ShowS
$cshowList :: forall a b. (Show a, Show b) => [PeriodicReport a b] -> ShowS
show :: PeriodicReport a b -> String
$cshow :: forall a b. (Show a, Show b) => PeriodicReport a b -> String
showsPrec :: Int -> PeriodicReport a b -> ShowS
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> PeriodicReport a b -> ShowS
Show, a -> PeriodicReport a b -> PeriodicReport a a
(a -> b) -> PeriodicReport a a -> PeriodicReport a b
(forall a b. (a -> b) -> PeriodicReport a a -> PeriodicReport a b)
-> (forall a b. a -> PeriodicReport a b -> PeriodicReport a a)
-> Functor (PeriodicReport a)
forall a b. a -> PeriodicReport a b -> PeriodicReport a a
forall a b. (a -> b) -> PeriodicReport a a -> PeriodicReport a b
forall a a b. a -> PeriodicReport a b -> PeriodicReport a a
forall a a b. (a -> b) -> PeriodicReport a a -> PeriodicReport a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> PeriodicReport a b -> PeriodicReport a a
$c<$ :: forall a a b. a -> PeriodicReport a b -> PeriodicReport a a
fmap :: (a -> b) -> PeriodicReport a a -> PeriodicReport a b
$cfmap :: forall a a b. (a -> b) -> PeriodicReport a a -> PeriodicReport a b
Functor, (forall x. PeriodicReport a b -> Rep (PeriodicReport a b) x)
-> (forall x. Rep (PeriodicReport a b) x -> PeriodicReport a b)
-> Generic (PeriodicReport a b)
forall x. Rep (PeriodicReport a b) x -> PeriodicReport a b
forall x. PeriodicReport a b -> Rep (PeriodicReport a b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b x. Rep (PeriodicReport a b) x -> PeriodicReport a b
forall a b x. PeriodicReport a b -> Rep (PeriodicReport a b) x
$cto :: forall a b x. Rep (PeriodicReport a b) x -> PeriodicReport a b
$cfrom :: forall a b x. PeriodicReport a b -> Rep (PeriodicReport a b) x
Generic, [PeriodicReport a b] -> Encoding
[PeriodicReport a b] -> Value
PeriodicReport a b -> Encoding
PeriodicReport a b -> Value
(PeriodicReport a b -> Value)
-> (PeriodicReport a b -> Encoding)
-> ([PeriodicReport a b] -> Value)
-> ([PeriodicReport a b] -> Encoding)
-> ToJSON (PeriodicReport a b)
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
forall a b.
(ToJSON a, ToJSON b) =>
[PeriodicReport a b] -> Encoding
forall a b. (ToJSON a, ToJSON b) => [PeriodicReport a b] -> Value
forall a b. (ToJSON a, ToJSON b) => PeriodicReport a b -> Encoding
forall a b. (ToJSON a, ToJSON b) => PeriodicReport a b -> Value
toEncodingList :: [PeriodicReport a b] -> Encoding
$ctoEncodingList :: forall a b.
(ToJSON a, ToJSON b) =>
[PeriodicReport a b] -> Encoding
toJSONList :: [PeriodicReport a b] -> Value
$ctoJSONList :: forall a b. (ToJSON a, ToJSON b) => [PeriodicReport a b] -> Value
toEncoding :: PeriodicReport a b -> Encoding
$ctoEncoding :: forall a b. (ToJSON a, ToJSON b) => PeriodicReport a b -> Encoding
toJSON :: PeriodicReport a b -> Value
$ctoJSON :: forall a b. (ToJSON a, ToJSON b) => PeriodicReport a b -> Value
ToJSON)
data PeriodicReportRow a b =
PeriodicReportRow
{ PeriodicReportRow a b -> a
prrName :: a
, PeriodicReportRow a b -> [b]
prrAmounts :: [b]
, PeriodicReportRow a b -> b
prrTotal :: b
, PeriodicReportRow a b -> b
prrAverage :: b
} deriving (Int -> PeriodicReportRow a b -> ShowS
[PeriodicReportRow a b] -> ShowS
PeriodicReportRow a b -> String
(Int -> PeriodicReportRow a b -> ShowS)
-> (PeriodicReportRow a b -> String)
-> ([PeriodicReportRow a b] -> ShowS)
-> Show (PeriodicReportRow a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b.
(Show a, Show b) =>
Int -> PeriodicReportRow a b -> ShowS
forall a b. (Show a, Show b) => [PeriodicReportRow a b] -> ShowS
forall a b. (Show a, Show b) => PeriodicReportRow a b -> String
showList :: [PeriodicReportRow a b] -> ShowS
$cshowList :: forall a b. (Show a, Show b) => [PeriodicReportRow a b] -> ShowS
show :: PeriodicReportRow a b -> String
$cshow :: forall a b. (Show a, Show b) => PeriodicReportRow a b -> String
showsPrec :: Int -> PeriodicReportRow a b -> ShowS
$cshowsPrec :: forall a b.
(Show a, Show b) =>
Int -> PeriodicReportRow a b -> ShowS
Show, a -> PeriodicReportRow a b -> PeriodicReportRow a a
(a -> b) -> PeriodicReportRow a a -> PeriodicReportRow a b
(forall a b.
(a -> b) -> PeriodicReportRow a a -> PeriodicReportRow a b)
-> (forall a b.
a -> PeriodicReportRow a b -> PeriodicReportRow a a)
-> Functor (PeriodicReportRow a)
forall a b. a -> PeriodicReportRow a b -> PeriodicReportRow a a
forall a b.
(a -> b) -> PeriodicReportRow a a -> PeriodicReportRow a b
forall a a b. a -> PeriodicReportRow a b -> PeriodicReportRow a a
forall a a b.
(a -> b) -> PeriodicReportRow a a -> PeriodicReportRow a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> PeriodicReportRow a b -> PeriodicReportRow a a
$c<$ :: forall a a b. a -> PeriodicReportRow a b -> PeriodicReportRow a a
fmap :: (a -> b) -> PeriodicReportRow a a -> PeriodicReportRow a b
$cfmap :: forall a a b.
(a -> b) -> PeriodicReportRow a a -> PeriodicReportRow a b
Functor, (forall x. PeriodicReportRow a b -> Rep (PeriodicReportRow a b) x)
-> (forall x.
Rep (PeriodicReportRow a b) x -> PeriodicReportRow a b)
-> Generic (PeriodicReportRow a b)
forall x. Rep (PeriodicReportRow a b) x -> PeriodicReportRow a b
forall x. PeriodicReportRow a b -> Rep (PeriodicReportRow a b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b x.
Rep (PeriodicReportRow a b) x -> PeriodicReportRow a b
forall a b x.
PeriodicReportRow a b -> Rep (PeriodicReportRow a b) x
$cto :: forall a b x.
Rep (PeriodicReportRow a b) x -> PeriodicReportRow a b
$cfrom :: forall a b x.
PeriodicReportRow a b -> Rep (PeriodicReportRow a b) x
Generic, [PeriodicReportRow a b] -> Encoding
[PeriodicReportRow a b] -> Value
PeriodicReportRow a b -> Encoding
PeriodicReportRow a b -> Value
(PeriodicReportRow a b -> Value)
-> (PeriodicReportRow a b -> Encoding)
-> ([PeriodicReportRow a b] -> Value)
-> ([PeriodicReportRow a b] -> Encoding)
-> ToJSON (PeriodicReportRow a b)
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
forall a b.
(ToJSON b, ToJSON a) =>
[PeriodicReportRow a b] -> Encoding
forall a b.
(ToJSON b, ToJSON a) =>
[PeriodicReportRow a b] -> Value
forall a b.
(ToJSON b, ToJSON a) =>
PeriodicReportRow a b -> Encoding
forall a b. (ToJSON b, ToJSON a) => PeriodicReportRow a b -> Value
toEncodingList :: [PeriodicReportRow a b] -> Encoding
$ctoEncodingList :: forall a b.
(ToJSON b, ToJSON a) =>
[PeriodicReportRow a b] -> Encoding
toJSONList :: [PeriodicReportRow a b] -> Value
$ctoJSONList :: forall a b.
(ToJSON b, ToJSON a) =>
[PeriodicReportRow a b] -> Value
toEncoding :: PeriodicReportRow a b -> Encoding
$ctoEncoding :: forall a b.
(ToJSON b, ToJSON a) =>
PeriodicReportRow a b -> Encoding
toJSON :: PeriodicReportRow a b -> Value
$ctoJSON :: forall a b. (ToJSON b, ToJSON a) => PeriodicReportRow a b -> Value
ToJSON)
instance Num b => Semigroup (PeriodicReportRow a b) where
(PeriodicReportRow a
_ [b]
amts1 b
t1 b
a1) <> :: PeriodicReportRow a b
-> PeriodicReportRow a b -> PeriodicReportRow a b
<> (PeriodicReportRow a
n2 [b]
amts2 b
t2 b
a2) =
a -> [b] -> b -> b -> PeriodicReportRow a b
forall a b. a -> [b] -> b -> b -> PeriodicReportRow a b
PeriodicReportRow a
n2 ([b] -> [b] -> [b]
forall a. Num a => [a] -> [a] -> [a]
sumPadded [b]
amts1 [b]
amts2) (b
t1 b -> b -> b
forall a. Num a => a -> a -> a
+ b
t2) (b
a1 b -> b -> b
forall a. Num a => a -> a -> a
+ b
a2)
where
sumPadded :: [a] -> [a] -> [a]
sumPadded (a
a:[a]
as) (a
b:[a]
bs) = (a
a a -> a -> a
forall a. Num a => a -> a -> a
+ a
b) a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a] -> [a] -> [a]
sumPadded [a]
as [a]
bs
sumPadded [a]
as [] = [a]
as
sumPadded [] [a]
bs = [a]
bs
periodicReportSpan :: PeriodicReport a b -> DateSpan
periodicReportSpan :: PeriodicReport a b -> DateSpan
periodicReportSpan (PeriodicReport [] [PeriodicReportRow a b]
_ PeriodicReportRow () b
_) = Maybe Day -> Maybe Day -> DateSpan
DateSpan Maybe Day
forall a. Maybe a
Nothing Maybe Day
forall a. Maybe a
Nothing
periodicReportSpan (PeriodicReport [DateSpan]
colspans [PeriodicReportRow a b]
_ PeriodicReportRow () b
_) = Maybe Day -> Maybe Day -> DateSpan
DateSpan (DateSpan -> Maybe Day
spanStart (DateSpan -> Maybe Day) -> DateSpan -> Maybe Day
forall a b. (a -> b) -> a -> b
$ [DateSpan] -> DateSpan
forall a. [a] -> a
head [DateSpan]
colspans) (DateSpan -> Maybe Day
spanEnd (DateSpan -> Maybe Day) -> DateSpan -> Maybe Day
forall a b. (a -> b) -> a -> b
$ [DateSpan] -> DateSpan
forall a. [a] -> a
last [DateSpan]
colspans)
prMapName :: (a -> b) -> PeriodicReport a c -> PeriodicReport b c
prMapName :: (a -> b) -> PeriodicReport a c -> PeriodicReport b c
prMapName a -> b
f PeriodicReport a c
report = PeriodicReport a c
report{prRows :: [PeriodicReportRow b c]
prRows = (PeriodicReportRow a c -> PeriodicReportRow b c)
-> [PeriodicReportRow a c] -> [PeriodicReportRow b c]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> b) -> PeriodicReportRow a c -> PeriodicReportRow b c
forall a b c.
(a -> b) -> PeriodicReportRow a c -> PeriodicReportRow b c
prrMapName a -> b
f) ([PeriodicReportRow a c] -> [PeriodicReportRow b c])
-> [PeriodicReportRow a c] -> [PeriodicReportRow b c]
forall a b. (a -> b) -> a -> b
$ PeriodicReport a c -> [PeriodicReportRow a c]
forall a b. PeriodicReport a b -> [PeriodicReportRow a b]
prRows PeriodicReport a c
report}
prMapMaybeName :: (a -> Maybe b) -> PeriodicReport a c -> PeriodicReport b c
prMapMaybeName :: (a -> Maybe b) -> PeriodicReport a c -> PeriodicReport b c
prMapMaybeName a -> Maybe b
f PeriodicReport a c
report = PeriodicReport a c
report{prRows :: [PeriodicReportRow b c]
prRows = (PeriodicReportRow a c -> Maybe (PeriodicReportRow b c))
-> [PeriodicReportRow a c] -> [PeriodicReportRow b c]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe ((a -> Maybe b)
-> PeriodicReportRow a c -> Maybe (PeriodicReportRow b c)
forall a b c.
(a -> Maybe b)
-> PeriodicReportRow a c -> Maybe (PeriodicReportRow b c)
prrMapMaybeName a -> Maybe b
f) ([PeriodicReportRow a c] -> [PeriodicReportRow b c])
-> [PeriodicReportRow a c] -> [PeriodicReportRow b c]
forall a b. (a -> b) -> a -> b
$ PeriodicReport a c -> [PeriodicReportRow a c]
forall a b. PeriodicReport a b -> [PeriodicReportRow a b]
prRows PeriodicReport a c
report}
prrMapName :: (a -> b) -> PeriodicReportRow a c -> PeriodicReportRow b c
prrMapName :: (a -> b) -> PeriodicReportRow a c -> PeriodicReportRow b c
prrMapName a -> b
f PeriodicReportRow a c
row = PeriodicReportRow a c
row{prrName :: b
prrName = a -> b
f (a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
$ PeriodicReportRow a c -> a
forall a b. PeriodicReportRow a b -> a
prrName PeriodicReportRow a c
row}
prrMapMaybeName :: (a -> Maybe b) -> PeriodicReportRow a c -> Maybe (PeriodicReportRow b c)
prrMapMaybeName :: (a -> Maybe b)
-> PeriodicReportRow a c -> Maybe (PeriodicReportRow b c)
prrMapMaybeName a -> Maybe b
f PeriodicReportRow a c
row = case a -> Maybe b
f (a -> Maybe b) -> a -> Maybe b
forall a b. (a -> b) -> a -> b
$ PeriodicReportRow a c -> a
forall a b. PeriodicReportRow a b -> a
prrName PeriodicReportRow a c
row of
Maybe b
Nothing -> Maybe (PeriodicReportRow b c)
forall a. Maybe a
Nothing
Just b
a -> PeriodicReportRow b c -> Maybe (PeriodicReportRow b c)
forall a. a -> Maybe a
Just PeriodicReportRow a c
row{prrName :: b
prrName = b
a}
data CompoundPeriodicReport a b = CompoundPeriodicReport
{ CompoundPeriodicReport a b -> Text
cbrTitle :: Text
, CompoundPeriodicReport a b -> [DateSpan]
cbrDates :: [DateSpan]
, CompoundPeriodicReport a b -> [(Text, PeriodicReport a b, Bool)]
cbrSubreports :: [(Text, PeriodicReport a b, Bool)]
, CompoundPeriodicReport a b -> PeriodicReportRow () b
cbrTotals :: PeriodicReportRow () b
} deriving (Int -> CompoundPeriodicReport a b -> ShowS
[CompoundPeriodicReport a b] -> ShowS
CompoundPeriodicReport a b -> String
(Int -> CompoundPeriodicReport a b -> ShowS)
-> (CompoundPeriodicReport a b -> String)
-> ([CompoundPeriodicReport a b] -> ShowS)
-> Show (CompoundPeriodicReport a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b.
(Show a, Show b) =>
Int -> CompoundPeriodicReport a b -> ShowS
forall a b.
(Show a, Show b) =>
[CompoundPeriodicReport a b] -> ShowS
forall a b.
(Show a, Show b) =>
CompoundPeriodicReport a b -> String
showList :: [CompoundPeriodicReport a b] -> ShowS
$cshowList :: forall a b.
(Show a, Show b) =>
[CompoundPeriodicReport a b] -> ShowS
show :: CompoundPeriodicReport a b -> String
$cshow :: forall a b.
(Show a, Show b) =>
CompoundPeriodicReport a b -> String
showsPrec :: Int -> CompoundPeriodicReport a b -> ShowS
$cshowsPrec :: forall a b.
(Show a, Show b) =>
Int -> CompoundPeriodicReport a b -> ShowS
Show, a -> CompoundPeriodicReport a b -> CompoundPeriodicReport a a
(a -> b)
-> CompoundPeriodicReport a a -> CompoundPeriodicReport a b
(forall a b.
(a -> b)
-> CompoundPeriodicReport a a -> CompoundPeriodicReport a b)
-> (forall a b.
a -> CompoundPeriodicReport a b -> CompoundPeriodicReport a a)
-> Functor (CompoundPeriodicReport a)
forall a b.
a -> CompoundPeriodicReport a b -> CompoundPeriodicReport a a
forall a b.
(a -> b)
-> CompoundPeriodicReport a a -> CompoundPeriodicReport a b
forall a a b.
a -> CompoundPeriodicReport a b -> CompoundPeriodicReport a a
forall a a b.
(a -> b)
-> CompoundPeriodicReport a a -> CompoundPeriodicReport a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> CompoundPeriodicReport a b -> CompoundPeriodicReport a a
$c<$ :: forall a a b.
a -> CompoundPeriodicReport a b -> CompoundPeriodicReport a a
fmap :: (a -> b)
-> CompoundPeriodicReport a a -> CompoundPeriodicReport a b
$cfmap :: forall a a b.
(a -> b)
-> CompoundPeriodicReport a a -> CompoundPeriodicReport a b
Functor, (forall x.
CompoundPeriodicReport a b -> Rep (CompoundPeriodicReport a b) x)
-> (forall x.
Rep (CompoundPeriodicReport a b) x -> CompoundPeriodicReport a b)
-> Generic (CompoundPeriodicReport a b)
forall x.
Rep (CompoundPeriodicReport a b) x -> CompoundPeriodicReport a b
forall x.
CompoundPeriodicReport a b -> Rep (CompoundPeriodicReport a b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b x.
Rep (CompoundPeriodicReport a b) x -> CompoundPeriodicReport a b
forall a b x.
CompoundPeriodicReport a b -> Rep (CompoundPeriodicReport a b) x
$cto :: forall a b x.
Rep (CompoundPeriodicReport a b) x -> CompoundPeriodicReport a b
$cfrom :: forall a b x.
CompoundPeriodicReport a b -> Rep (CompoundPeriodicReport a b) x
Generic, [CompoundPeriodicReport a b] -> Encoding
[CompoundPeriodicReport a b] -> Value
CompoundPeriodicReport a b -> Encoding
CompoundPeriodicReport a b -> Value
(CompoundPeriodicReport a b -> Value)
-> (CompoundPeriodicReport a b -> Encoding)
-> ([CompoundPeriodicReport a b] -> Value)
-> ([CompoundPeriodicReport a b] -> Encoding)
-> ToJSON (CompoundPeriodicReport a b)
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
forall a b.
(ToJSON b, ToJSON a) =>
[CompoundPeriodicReport a b] -> Encoding
forall a b.
(ToJSON b, ToJSON a) =>
[CompoundPeriodicReport a b] -> Value
forall a b.
(ToJSON b, ToJSON a) =>
CompoundPeriodicReport a b -> Encoding
forall a b.
(ToJSON b, ToJSON a) =>
CompoundPeriodicReport a b -> Value
toEncodingList :: [CompoundPeriodicReport a b] -> Encoding
$ctoEncodingList :: forall a b.
(ToJSON b, ToJSON a) =>
[CompoundPeriodicReport a b] -> Encoding
toJSONList :: [CompoundPeriodicReport a b] -> Value
$ctoJSONList :: forall a b.
(ToJSON b, ToJSON a) =>
[CompoundPeriodicReport a b] -> Value
toEncoding :: CompoundPeriodicReport a b -> Encoding
$ctoEncoding :: forall a b.
(ToJSON b, ToJSON a) =>
CompoundPeriodicReport a b -> Encoding
toJSON :: CompoundPeriodicReport a b -> Value
$ctoJSON :: forall a b.
(ToJSON b, ToJSON a) =>
CompoundPeriodicReport a b -> Value
ToJSON)
data CBCSubreportSpec a = CBCSubreportSpec
{ CBCSubreportSpec a -> Text
cbcsubreporttitle :: Text
, CBCSubreportSpec a -> Journal -> Query
cbcsubreportquery :: Journal -> Query
, CBCSubreportSpec a -> ReportOpts -> ReportOpts
cbcsubreportoptions :: ReportOpts -> ReportOpts
, CBCSubreportSpec a
-> PeriodicReport DisplayName MixedAmount
-> PeriodicReport a MixedAmount
cbcsubreporttransform :: PeriodicReport DisplayName MixedAmount -> PeriodicReport a MixedAmount
, CBCSubreportSpec a -> Bool
cbcsubreportincreasestotal :: Bool
}
data DisplayName = DisplayName
{ DisplayName -> Text
displayFull :: AccountName
, DisplayName -> Text
displayName :: AccountName
, DisplayName -> Int
displayDepth :: Int
} deriving (Int -> DisplayName -> ShowS
[DisplayName] -> ShowS
DisplayName -> String
(Int -> DisplayName -> ShowS)
-> (DisplayName -> String)
-> ([DisplayName] -> ShowS)
-> Show DisplayName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisplayName] -> ShowS
$cshowList :: [DisplayName] -> ShowS
show :: DisplayName -> String
$cshow :: DisplayName -> String
showsPrec :: Int -> DisplayName -> ShowS
$cshowsPrec :: Int -> DisplayName -> ShowS
Show, DisplayName -> DisplayName -> Bool
(DisplayName -> DisplayName -> Bool)
-> (DisplayName -> DisplayName -> Bool) -> Eq DisplayName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisplayName -> DisplayName -> Bool
$c/= :: DisplayName -> DisplayName -> Bool
== :: DisplayName -> DisplayName -> Bool
$c== :: DisplayName -> DisplayName -> Bool
Eq, Eq DisplayName
Eq DisplayName
-> (DisplayName -> DisplayName -> Ordering)
-> (DisplayName -> DisplayName -> Bool)
-> (DisplayName -> DisplayName -> Bool)
-> (DisplayName -> DisplayName -> Bool)
-> (DisplayName -> DisplayName -> Bool)
-> (DisplayName -> DisplayName -> DisplayName)
-> (DisplayName -> DisplayName -> DisplayName)
-> Ord DisplayName
DisplayName -> DisplayName -> Bool
DisplayName -> DisplayName -> Ordering
DisplayName -> DisplayName -> DisplayName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DisplayName -> DisplayName -> DisplayName
$cmin :: DisplayName -> DisplayName -> DisplayName
max :: DisplayName -> DisplayName -> DisplayName
$cmax :: DisplayName -> DisplayName -> DisplayName
>= :: DisplayName -> DisplayName -> Bool
$c>= :: DisplayName -> DisplayName -> Bool
> :: DisplayName -> DisplayName -> Bool
$c> :: DisplayName -> DisplayName -> Bool
<= :: DisplayName -> DisplayName -> Bool
$c<= :: DisplayName -> DisplayName -> Bool
< :: DisplayName -> DisplayName -> Bool
$c< :: DisplayName -> DisplayName -> Bool
compare :: DisplayName -> DisplayName -> Ordering
$ccompare :: DisplayName -> DisplayName -> Ordering
$cp1Ord :: Eq DisplayName
Ord)
instance ToJSON DisplayName where
toJSON :: DisplayName -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (DisplayName -> Text) -> DisplayName -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DisplayName -> Text
displayFull
toEncoding :: DisplayName -> Encoding
toEncoding = Text -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Text -> Encoding)
-> (DisplayName -> Text) -> DisplayName -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DisplayName -> Text
displayFull
flatDisplayName :: AccountName -> DisplayName
flatDisplayName :: Text -> DisplayName
flatDisplayName Text
a = Text -> Text -> Int -> DisplayName
DisplayName Text
a Text
a Int
1
treeDisplayName :: AccountName -> DisplayName
treeDisplayName :: Text -> DisplayName
treeDisplayName Text
a = Text -> Text -> Int -> DisplayName
DisplayName Text
a (Text -> Text
accountLeafName Text
a) (Text -> Int
accountNameLevel Text
a)
prrFullName :: PeriodicReportRow DisplayName a -> AccountName
prrFullName :: PeriodicReportRow DisplayName a -> Text
prrFullName = DisplayName -> Text
displayFull (DisplayName -> Text)
-> (PeriodicReportRow DisplayName a -> DisplayName)
-> PeriodicReportRow DisplayName a
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PeriodicReportRow DisplayName a -> DisplayName
forall a b. PeriodicReportRow a b -> a
prrName
prrDisplayName :: PeriodicReportRow DisplayName a -> AccountName
prrDisplayName :: PeriodicReportRow DisplayName a -> Text
prrDisplayName = DisplayName -> Text
displayName (DisplayName -> Text)
-> (PeriodicReportRow DisplayName a -> DisplayName)
-> PeriodicReportRow DisplayName a
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PeriodicReportRow DisplayName a -> DisplayName
forall a b. PeriodicReportRow a b -> a
prrName
prrDepth :: PeriodicReportRow DisplayName a -> Int
prrDepth :: PeriodicReportRow DisplayName a -> Int
prrDepth = DisplayName -> Int
displayDepth (DisplayName -> Int)
-> (PeriodicReportRow DisplayName a -> DisplayName)
-> PeriodicReportRow DisplayName a
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PeriodicReportRow DisplayName a -> DisplayName
forall a b. PeriodicReportRow a b -> a
prrName