diff --git a/dhall/Types.dhall b/dhall/Types.dhall index fd6a45a..e3bdd2a 100644 --- a/dhall/Types.dhall +++ b/dhall/Types.dhall @@ -280,49 +280,50 @@ let DatePat = let TxOpts = {- Additional metadata to use when parsing a statement -} - { Type = - { toDate : - {- - Column title for date - -} - Text - , toAmount : - {- - Column title for amount - -} - Text - , toDesc : - {- - Column title for description - -} - Text - , toOther : - {- - Titles of other columns to include; these will be available in - a map for use in downstream processing (see 'Field') - -} - List Text - , toDateFmt : - {- - Format of the date field as specified in the - Data.Time.Format.formattime Haskell function. - -} - Text - , toAmountFmt : - {- Format of the amount field. Must include three fields for the - sign, numerator, and denominator of the amount. - -} - Text + \(re : Type) -> + { Type = + { toDate : + {- + Column title for date + -} + Text + , toAmount : + {- + Column title for amount + -} + Text + , toDesc : + {- + Column title for description + -} + Text + , toOther : + {- + Titles of other columns to include; these will be available in + a map for use in downstream processing (see 'Field') + -} + List Text + , toDateFmt : + {- + Format of the date field as specified in the + Data.Time.Format.formattime Haskell function. + -} + Text + , toAmountFmt : + {- Format of the amount field. Must include three fields for the + sign, numerator, and denominator of the amount. + -} + re + } + , default = + { toDate = "Date" + , toAmount = "Amount" + , toDesc = "Description" + , toOther = [] : List Text + , toDateFmt = "%0m/%0d/%Y" + , toAmountFmt = "([-+])?([0-9]+)\\.?([0-9]+)?" } - , default = - { toDate = "Date" - , toAmount = "Amount" - , toDesc = "Description" - , toOther = [] : List Text - , toDateFmt = "%0m/%0d/%Y" - , toAmountFmt = "([-+])?([0-9]+)\\.?([0-9]+)?" } - } let Field = {- @@ -679,7 +680,10 @@ let Amount = -} \(w : Type) -> \(v : Type) -> - { amtWhen : w, amtValue : v, amtDesc : Text, amtPriority : Integer } + { Type = + { amtWhen : w, amtValue : v, amtDesc : Text, amtPriority : Integer } + , default.amtPriority = +0 + } let TransferType = {- @@ -711,7 +715,7 @@ let Transfer = { transFrom : a , transTo : a , transCurrency : c - , transAmounts : List (Amount w v) + , transAmounts : List (Amount w v).Type } let TaggedAcnt = @@ -748,7 +752,7 @@ let Statement = file delimiter as a numeric char, usually either tab (9) or comma (44) -} : Natural - , stmtTxOpts : TxOpts.Type + , stmtTxOpts : (TxOpts Text).Type , stmtSkipLines {- how many lines to skip before parsing statement @@ -771,7 +775,7 @@ let Allocation = \(w : Type) -> \(v : Type) -> { alloTo : TaggedAcnt.Type - , alloAmts : List (Amount w v) + , alloAmts : List (Amount w v).Type , alloCur : {-TODO allow exchanges here-} CurID diff --git a/dhall/common.dhall b/dhall/common.dhall index 0283bb6..e38136a 100644 --- a/dhall/common.dhall +++ b/dhall/common.dhall @@ -9,7 +9,7 @@ let nullEntry = \(v : T.EntryNumGetter) -> T.FromEntryGetter::{ eAcnt = a, eValue = v } -let nullOpts = T.TxOpts::{=} +let nullOpts = (T.TxOpts Text)::{=} let nullVal = T.ValMatcher::{=} diff --git a/lib/Internal/Types/Dhall.hs b/lib/Internal/Types/Dhall.hs index 08d63a1..10b0bce 100644 --- a/lib/Internal/Types/Dhall.hs +++ b/lib/Internal/Types/Dhall.hs @@ -19,7 +19,6 @@ import Language.Haskell.TH.Syntax (Lift) import RIO import qualified RIO.Map as M import qualified RIO.Text as T --- import RIO.Time import Text.Regex.TDFA makeHaskellTypesWith @@ -49,12 +48,18 @@ makeHaskellTypesWith , SingleConstructor "ModPat" "ModPat" "(./dhall/Types.dhall).ModPat.Type" , SingleConstructor "CronPat" "CronPat" "(./dhall/Types.dhall).CronPat.Type" , SingleConstructor "ValMatcher" "ValMatcher" "(./dhall/Types.dhall).ValMatcher.Type" - , SingleConstructor "Amount" "Amount" "(./dhall/Types.dhall).Amount" + , SingleConstructor + "Amount" + "Amount" + "\\(w : Type) -> \\(v : Type) -> ((./dhall/Types.dhall).Amount w v).Type" + , SingleConstructor + "TxOpts" + "TxOpts" + "\\(re : Type) -> ((./dhall/Types.dhall).TxOpts re).Type" , SingleConstructor "AcntSet" "AcntSet" "(./dhall/Types.dhall).AcntSet.Type" , SingleConstructor "TransferMatcher" "TransferMatcher" "(./dhall/Types.dhall).TransferMatcher.Type" , SingleConstructor "ShadowTransfer" "ShadowTransfer" "(./dhall/Types.dhall).ShadowTransfer" - , -- , SingleConstructor "Income" "Income" "(./dhall/Types.dhall).Income.Type" - SingleConstructor "Field" "Field" "(./dhall/Types.dhall).Field" + , SingleConstructor "Field" "Field" "(./dhall/Types.dhall).Field" , SingleConstructor "Entry" "Entry" "(./dhall/Types.dhall).Entry" , SingleConstructor "PretaxValue" "PretaxValue" "(./dhall/Types.dhall).PretaxValue" , SingleConstructor "TaxBracket" "TaxBracket" "(./dhall/Types.dhall).TaxBracket" @@ -64,11 +69,6 @@ makeHaskellTypesWith , SingleConstructor "TransferValue" "TransferValue" "(./dhall/Types.dhall).TransferValue.Type" , SingleConstructor "Period" "Period" "(./dhall/Types.dhall).Period" , SingleConstructor "HourlyPeriod" "HourlyPeriod" "(./dhall/Types.dhall).HourlyPeriod" - -- , SingleConstructor "ToTx" "ToTx" "(./dhall/Types.dhall).ToTx" - -- , SingleConstructor "FieldMatcher" "FieldMatcher" "(./dhall/Types.dhall).FieldMatcher_" - -- , SingleConstructor "Match" "Match" "(./dhall/Types.dhall).Match_" - -- , SingleConstructor "Budget" "Budget" "(./dhall/Types.dhall).Budget" - -- SingleConstructor "Transfer" "Transfer" "(./dhall/Types.dhall).Transfer" ] deriveProduct @@ -443,15 +443,15 @@ deriving instance (Hashable a, Hashable v, Hashable t) => Hashable (Entry a v t) deriving instance (Eq a, Eq v, Eq t) => Eq (Entry a v t) -data TxOpts re = TxOpts - { toDate :: !T.Text - , toAmount :: !T.Text - , toDesc :: !T.Text - , toOther :: ![T.Text] - , toDateFmt :: !T.Text - , toAmountFmt :: !re - } - deriving (Eq, Generic, Hashable, Show, FromDhall) +deriving instance Eq a => Eq (TxOpts a) + +deriving instance Generic (TxOpts a) + +deriving instance Hashable a => Hashable (TxOpts a) + +deriving instance FromDhall a => FromDhall (TxOpts a) + +deriving instance Show a => Show (TxOpts a) data Statement = Statement { stmtPaths :: ![FilePath]