210 lines
4.7 KiB
Plaintext
210 lines
4.7 KiB
Plaintext
|
let List/map =
|
||
|
https://prelude.dhall-lang.org/v21.1.0/List/map
|
||
|
sha256:dd845ffb4568d40327f2a817eb42d1c6138b929ca758d50bc33112ef3c885680
|
||
|
|
||
|
let nullSplit =
|
||
|
\(a : SplitAcnt) ->
|
||
|
\(c : SplitCur) ->
|
||
|
{ sAcnt = a, sCurrency = c, sValue = None SplitNum, sComment = "" }
|
||
|
|
||
|
let nullOpts =
|
||
|
{ toDate = "Date"
|
||
|
, toAmount = "Amount"
|
||
|
, toDesc = "Description"
|
||
|
, toOther = [] : List Text
|
||
|
, toDateFmt = "%0m/%0d/%Y"
|
||
|
, toAmountFmt = "([-+])?([0-9]+)\\.?([0-9]+)?"
|
||
|
}
|
||
|
|
||
|
let nullVal =
|
||
|
{ mvSign = None Bool
|
||
|
, mvNum = None Natural
|
||
|
, mvDen = None Natural
|
||
|
, mvPrec = 2
|
||
|
}
|
||
|
|
||
|
let nullMatch =
|
||
|
{ mDate = None MatchDate
|
||
|
, mVal = nullVal
|
||
|
, mDesc = None MatchDesc
|
||
|
, mOther = [] : List MatchOther
|
||
|
, mTx = None ToTx
|
||
|
, mTimes = None Natural
|
||
|
, mPriority = +0
|
||
|
}
|
||
|
|
||
|
let nullCron =
|
||
|
{ cronWeekly = None WeekdayPat
|
||
|
, cronYear = None MDYPat
|
||
|
, cronMonth = None MDYPat
|
||
|
, cronDay = None MDYPat
|
||
|
}
|
||
|
|
||
|
let nullMod =
|
||
|
\(by : Natural) ->
|
||
|
\(u : TimeUnit) ->
|
||
|
{ mpStart = None Gregorian
|
||
|
, mpBy = by
|
||
|
, mpUnit = u
|
||
|
, mpRepeats = None Natural
|
||
|
}
|
||
|
|
||
|
let cron1 =
|
||
|
\(y : Natural) ->
|
||
|
\(m : Natural) ->
|
||
|
\(d : Natural) ->
|
||
|
DatePat.Cron
|
||
|
( nullCron
|
||
|
// { cronYear = Some (MDYPat.Single y)
|
||
|
, cronMonth = Some (MDYPat.Single m)
|
||
|
, cronDay = Some (MDYPat.Single d)
|
||
|
}
|
||
|
)
|
||
|
|
||
|
let matchInf_ = nullMatch
|
||
|
|
||
|
let matchInf = \(x : ToTx) -> nullMatch // { mTx = Some x }
|
||
|
|
||
|
let matchN_ = \(n : Natural) -> nullMatch // { mTimes = Some n }
|
||
|
|
||
|
let matchN = \(n : Natural) -> \(x : ToTx) -> matchInf x // { mTimes = Some n }
|
||
|
|
||
|
let match1_ = matchN_ 1
|
||
|
|
||
|
let match1 = matchN 1
|
||
|
|
||
|
let gregM = \(y : Natural) -> \(m : Natural) -> { gmYear = y, gmMonth = m }
|
||
|
|
||
|
let greg =
|
||
|
\(y : Natural) ->
|
||
|
\(m : Natural) ->
|
||
|
\(d : Natural) ->
|
||
|
{ gYear = y, gMonth = m, gDay = d }
|
||
|
|
||
|
let mY = \(y : Natural) -> MatchDate.On (MatchYMD.Y y)
|
||
|
|
||
|
let mYM =
|
||
|
\(y : Natural) -> \(m : Natural) -> MatchDate.On (MatchYMD.YM (gregM y m))
|
||
|
|
||
|
let mYMD =
|
||
|
\(y : Natural) ->
|
||
|
\(m : Natural) ->
|
||
|
\(d : Natural) ->
|
||
|
MatchDate.On (MatchYMD.YMD (greg y m d))
|
||
|
|
||
|
let mRngY =
|
||
|
\(y : Natural) ->
|
||
|
\(r : Natural) ->
|
||
|
MatchDate.In { rStart = MatchYMD.Y y, rLen = r }
|
||
|
|
||
|
let mRngYM =
|
||
|
\(y : Natural) ->
|
||
|
\(m : Natural) ->
|
||
|
\(r : Natural) ->
|
||
|
MatchDate.In { rStart = MatchYMD.YM (gregM y m), rLen = r }
|
||
|
|
||
|
let mRngYMD =
|
||
|
\(y : Natural) ->
|
||
|
\(m : Natural) ->
|
||
|
\(d : Natural) ->
|
||
|
\(r : Natural) ->
|
||
|
MatchDate.In { rStart = MatchYMD.YMD (greg y m d), rLen = r }
|
||
|
|
||
|
let PartSplit = { _1 : AcntID, _2 : Decimal, _3 : Text }
|
||
|
|
||
|
let partN =
|
||
|
\(c : SplitCur) ->
|
||
|
\(a : SplitAcnt) ->
|
||
|
\(comment : Text) ->
|
||
|
\(ss : List PartSplit) ->
|
||
|
let toSplit =
|
||
|
\(x : PartSplit) ->
|
||
|
nullSplit (SplitAcnt.ConstT x._1) c
|
||
|
// { sValue = Some (SplitNum.ConstN x._2), sComment = x._3 }
|
||
|
|
||
|
in [ nullSplit a c // { sComment = comment } ]
|
||
|
# List/map PartSplit ExpSplit toSplit ss
|
||
|
|
||
|
let part1 =
|
||
|
\(c : SplitCur) ->
|
||
|
\(a : SplitAcnt) ->
|
||
|
\(comment : Text) ->
|
||
|
partN c a comment ([] : List PartSplit)
|
||
|
|
||
|
let part1_ =
|
||
|
\(c : SplitCur) -> \(a : SplitAcnt) -> partN c a "" ([] : List PartSplit)
|
||
|
|
||
|
let dec =
|
||
|
\(s : Bool) ->
|
||
|
\(w : Natural) ->
|
||
|
\(d : Natural) ->
|
||
|
\(p : Natural) ->
|
||
|
{ whole = w, decimal = d, precision = p, sign = s } : Decimal
|
||
|
|
||
|
let dec2 = \(s : Bool) -> \(w : Natural) -> \(d : Natural) -> dec s w d 2
|
||
|
|
||
|
let d = dec2 True
|
||
|
|
||
|
let d_ = dec2 False
|
||
|
|
||
|
let addDay =
|
||
|
\(x : GregorianM) ->
|
||
|
\(d : Natural) ->
|
||
|
{ gYear = x.gmYear, gMonth = x.gmMonth, gDay = d }
|
||
|
|
||
|
let mvP = nullVal // { mvSign = Some True }
|
||
|
|
||
|
let mvN = nullVal // { mvSign = Some False }
|
||
|
|
||
|
let mvNum = \(x : Natural) -> nullVal // { mvNum = Some x }
|
||
|
|
||
|
let mvDen = \(x : Natural) -> nullVal // { mvDen = Some x }
|
||
|
|
||
|
let mvNumP = \(x : Natural) -> mvP // { mvNum = Some x }
|
||
|
|
||
|
let mvNumN = \(x : Natural) -> mvN // { mvNum = Some x }
|
||
|
|
||
|
let mvDenP = \(x : Natural) -> mvP // { mvDen = Some x }
|
||
|
|
||
|
let mvDenN = \(x : Natural) -> mvN // { mvDen = Some x }
|
||
|
|
||
|
in { nullSplit
|
||
|
, nullMatch
|
||
|
, nullVal
|
||
|
, nullOpts
|
||
|
, nullCron
|
||
|
, nullMod
|
||
|
, cron1
|
||
|
, mY
|
||
|
, mYM
|
||
|
, mYMD
|
||
|
, mRngY
|
||
|
, mRngYM
|
||
|
, mRngYMD
|
||
|
, matchInf_
|
||
|
, matchInf
|
||
|
, matchN_
|
||
|
, matchN
|
||
|
, match1_
|
||
|
, match1
|
||
|
, greg
|
||
|
, gregM
|
||
|
, partN
|
||
|
, part1
|
||
|
, part1_
|
||
|
, d
|
||
|
, d_
|
||
|
, addDay
|
||
|
, comma = 44
|
||
|
, tab = 9
|
||
|
, mvP
|
||
|
, mvN
|
||
|
, mvNum
|
||
|
, mvNumP
|
||
|
, mvNumN
|
||
|
, mvDen
|
||
|
, mvDenP
|
||
|
, mvDenN
|
||
|
, PartSplit
|
||
|
}
|