dev: lib: Add NFData instances for Journal and subcomponents.
This commit is contained in:
parent
468a3da1b7
commit
eda4c8dd62
@ -34,6 +34,7 @@ module Hledger.Data.Types (
|
|||||||
where
|
where
|
||||||
|
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
|
import Control.DeepSeq (NFData(..))
|
||||||
import Data.Bifunctor (first)
|
import Data.Bifunctor (first)
|
||||||
import Data.Decimal (Decimal, DecimalRaw(..))
|
import Data.Decimal (Decimal, DecimalRaw(..))
|
||||||
import Data.Default (Default(..))
|
import Data.Default (Default(..))
|
||||||
@ -762,3 +763,39 @@ data Ledger = Ledger {
|
|||||||
ljournal :: Journal
|
ljournal :: Journal
|
||||||
,laccounts :: [Account]
|
,laccounts :: [Account]
|
||||||
} deriving (Generic)
|
} deriving (Generic)
|
||||||
|
|
||||||
|
instance NFData AccountAlias
|
||||||
|
instance NFData AccountDeclarationInfo
|
||||||
|
instance NFData AccountType
|
||||||
|
instance NFData Amount
|
||||||
|
instance NFData AmountCost
|
||||||
|
instance NFData AmountPrecision
|
||||||
|
instance NFData AmountStyle
|
||||||
|
instance NFData BalanceAssertion
|
||||||
|
instance NFData Commodity
|
||||||
|
instance NFData DateSpan
|
||||||
|
instance NFData DigitGroupStyle
|
||||||
|
instance NFData EFDay
|
||||||
|
instance NFData Interval
|
||||||
|
instance NFData Journal
|
||||||
|
instance NFData MarketPrice
|
||||||
|
instance NFData MixedAmount
|
||||||
|
instance NFData MixedAmountKey
|
||||||
|
instance NFData Rounding
|
||||||
|
instance NFData PayeeDeclarationInfo
|
||||||
|
instance NFData PeriodicTransaction
|
||||||
|
instance NFData PostingType
|
||||||
|
instance NFData PriceDirective
|
||||||
|
instance NFData Side
|
||||||
|
instance NFData Status
|
||||||
|
instance NFData TagDeclarationInfo
|
||||||
|
instance NFData TimeclockCode
|
||||||
|
instance NFData TimeclockEntry
|
||||||
|
instance NFData TMPostingRule
|
||||||
|
instance NFData Transaction
|
||||||
|
instance NFData TransactionModifier
|
||||||
|
|
||||||
|
instance NFData Posting where
|
||||||
|
-- Do not call rnf on the parent transaction to avoid recursive loops
|
||||||
|
rnf (Posting d d2 s n a c t ta b mt op) =
|
||||||
|
rnf d `seq` rnf d2 `seq` rnf s `seq` rnf n `seq` rnf a `seq` rnf c `seq` rnf t `seq` rnf ta `seq` rnf b `seq` mt `seq` rnf op `seq` ()
|
||||||
|
|||||||
@ -64,6 +64,7 @@ module Hledger.Utils.Regex (
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
import Control.DeepSeq (NFData(..), rwhnf)
|
||||||
import Control.Monad (foldM)
|
import Control.Monad (foldM)
|
||||||
import Data.Aeson (ToJSON(..), Value(String))
|
import Data.Aeson (ToJSON(..), Value(String))
|
||||||
import Data.Array ((!), elems, indices)
|
import Data.Array ((!), elems, indices)
|
||||||
@ -129,6 +130,8 @@ instance RegexContext Regexp String String where
|
|||||||
match = match . reCompiled
|
match = match . reCompiled
|
||||||
matchM = matchM . reCompiled
|
matchM = matchM . reCompiled
|
||||||
|
|
||||||
|
instance NFData Regexp where rnf = rwhnf
|
||||||
|
|
||||||
-- Convert a Regexp string to a compiled Regex, or return an error message.
|
-- Convert a Regexp string to a compiled Regex, or return an error message.
|
||||||
toRegex :: Text -> Either RegexError Regexp
|
toRegex :: Text -> Either RegexError Regexp
|
||||||
toRegex = memo $ \s -> mkRegexErr s (Regexp s <$> makeRegexM (T.unpack s)) -- Have to unpack here because Text instance in regex-tdfa only appears in 1.3.1
|
toRegex = memo $ \s -> mkRegexErr s (Regexp s <$> makeRegexM (T.unpack s)) -- Have to unpack here because Text instance in regex-tdfa only appears in 1.3.1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user