From 70986769efa1a3c277d8cb5c0f05bef04fb07d70 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 1 Aug 2019 18:23:31 +0200 Subject: [PATCH] ;lib: derive NFData for MultiBalanceReport, PriceGraph for criterion Allow these to be timed with criterion at ghci prompt. --- hledger-lib/Hledger/Data/Types.hs | 4 +++- hledger-lib/Hledger/Reports/MultiBalanceReport.hs | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index 224355c21..19e4d4e07 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -464,7 +464,9 @@ data PriceGraph = PriceGraph { -- but those have to be Real for shortest path finding, -- so we'd have to transform them all first. } - deriving (Show) + deriving (Show,Generic) + +instance NFData PriceGraph -- | What kind of value conversion should be done on amounts ? -- UI: --value=cost|end|now|DATE[,COMM] diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs index 432fa69ce..06e55502f 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE FlexibleInstances, RecordWildCards, ScopedTypeVariables, OverloadedStrings #-} +{-# LANGUAGE FlexibleInstances, RecordWildCards, ScopedTypeVariables, OverloadedStrings, DeriveGeneric #-} {-| Multi-column balance reports, used by the balance command. @@ -20,6 +20,8 @@ module Hledger.Reports.MultiBalanceReport ( ) where +import GHC.Generics (Generic) +import Control.DeepSeq (NFData) import Data.List import Data.Maybe import Data.Ord @@ -69,9 +71,13 @@ newtype MultiBalanceReport = ,[MultiBalanceReportRow] ,MultiBalanceReportTotals ) + deriving (Generic) + type MultiBalanceReportRow = (AccountName, AccountName, Int, [MixedAmount], MixedAmount, MixedAmount) type MultiBalanceReportTotals = ([MixedAmount], MixedAmount, MixedAmount) -- (Totals list, sum of totals, average of totals) +instance NFData MultiBalanceReport + instance Show MultiBalanceReport where -- use pshow (pretty-show's ppShow) to break long lists onto multiple lines -- we add some bogus extra shows here to help it parse the output