pwncash/dhall/common.dhall

191 lines
4.4 KiB
Plaintext
Raw Normal View History

2022-12-11 17:51:11 -05:00
let List/map =
https://prelude.dhall-lang.org/v21.1.0/List/map
sha256:dd845ffb4568d40327f2a817eb42d1c6138b929ca758d50bc33112ef3c885680
2022-12-15 22:48:14 -05:00
let T =
./Types.dhall
2022-12-15 22:59:33 -05:00
sha256:23b804c330543233c1ec70de379ee7dacd34ba1851b2fa183d16c8436b1b7279
2022-12-14 23:59:23 -05:00
2022-12-11 17:51:11 -05:00
let nullSplit =
2022-12-14 23:59:23 -05:00
\(a : T.SplitAcnt) ->
\(c : T.SplitCur) ->
T.ExpSplit::{ sAcnt = a, sCurrency = c }
let nullOpts = T.TxOpts::{=}
let nullVal = T.MatchVal::{=}
let nullMatch = T.Match::{=}
let nullCron = T.CronPat::{=}
2022-12-11 17:51:11 -05:00
let nullMod =
\(by : Natural) ->
2022-12-14 23:59:23 -05:00
\(u : T.TimeUnit) ->
T.ModPat::{ mpBy = by, mpUnit = u }
2022-12-11 17:51:11 -05:00
let cron1 =
\(y : Natural) ->
\(m : Natural) ->
\(d : Natural) ->
2022-12-14 23:59:23 -05:00
T.DatePat.Cron
2022-12-11 17:51:11 -05:00
( nullCron
2022-12-14 23:59:23 -05:00
// { cronYear = Some (T.MDYPat.Single y)
, cronMonth = Some (T.MDYPat.Single m)
, cronDay = Some (T.MDYPat.Single d)
2022-12-11 17:51:11 -05:00
}
)
let matchInf_ = nullMatch
2022-12-14 23:59:23 -05:00
let matchInf = \(x : T.ToTx) -> nullMatch // { mTx = Some x }
2022-12-11 17:51:11 -05:00
let matchN_ = \(n : Natural) -> nullMatch // { mTimes = Some n }
2022-12-14 23:59:23 -05:00
let matchN =
\(n : Natural) -> \(x : T.ToTx) -> matchInf x // { mTimes = Some n }
2022-12-11 17:51:11 -05:00
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 }
2022-12-14 23:59:23 -05:00
let mY = \(y : Natural) -> T.MatchDate.On (T.MatchYMD.Y y)
2022-12-11 17:51:11 -05:00
let mYM =
2022-12-14 23:59:23 -05:00
\(y : Natural) ->
\(m : Natural) ->
T.MatchDate.On (T.MatchYMD.YM (gregM y m))
2022-12-11 17:51:11 -05:00
let mYMD =
\(y : Natural) ->
\(m : Natural) ->
\(d : Natural) ->
2022-12-14 23:59:23 -05:00
T.MatchDate.On (T.MatchYMD.YMD (greg y m d))
2022-12-11 17:51:11 -05:00
let mRngY =
\(y : Natural) ->
\(r : Natural) ->
2022-12-14 23:59:23 -05:00
T.MatchDate.In { _1 = T.MatchYMD.Y y, _2 = r }
2022-12-11 17:51:11 -05:00
let mRngYM =
\(y : Natural) ->
\(m : Natural) ->
\(r : Natural) ->
2022-12-14 23:59:23 -05:00
T.MatchDate.In { _1 = T.MatchYMD.YM (gregM y m), _2 = r }
2022-12-11 17:51:11 -05:00
let mRngYMD =
\(y : Natural) ->
\(m : Natural) ->
\(d : Natural) ->
\(r : Natural) ->
2022-12-14 23:59:23 -05:00
T.MatchDate.In { _1 = T.MatchYMD.YMD (greg y m d), _2 = r }
2022-12-11 17:51:11 -05:00
2022-12-14 23:59:23 -05:00
let PartSplit = { _1 : T.AcntID, _2 : T.Decimal, _3 : Text }
2022-12-11 17:51:11 -05:00
let partN =
2022-12-14 23:59:23 -05:00
\(c : T.SplitCur) ->
\(a : T.SplitAcnt) ->
2022-12-11 17:51:11 -05:00
\(comment : Text) ->
\(ss : List PartSplit) ->
let toSplit =
\(x : PartSplit) ->
2022-12-14 23:59:23 -05:00
nullSplit (T.SplitAcnt.ConstT x._1) c
// { sValue = Some (T.SplitNum.ConstN x._2), sComment = x._3 }
2022-12-11 17:51:11 -05:00
in [ nullSplit a c // { sComment = comment } ]
2022-12-14 23:59:23 -05:00
# List/map PartSplit T.ExpSplit.Type toSplit ss
2022-12-11 17:51:11 -05:00
let part1 =
2022-12-14 23:59:23 -05:00
\(c : T.SplitCur) ->
\(a : T.SplitAcnt) ->
2022-12-11 17:51:11 -05:00
\(comment : Text) ->
partN c a comment ([] : List PartSplit)
let part1_ =
2022-12-14 23:59:23 -05:00
\(c : T.SplitCur) ->
\(a : T.SplitAcnt) ->
partN c a "" ([] : List PartSplit)
2022-12-11 17:51:11 -05:00
let dec =
\(s : Bool) ->
\(w : Natural) ->
\(d : Natural) ->
\(p : Natural) ->
2022-12-14 23:59:23 -05:00
{ whole = w, decimal = d, precision = p, sign = s } : T.Decimal
2022-12-11 17:51:11 -05:00
let dec2 = \(s : Bool) -> \(w : Natural) -> \(d : Natural) -> dec s w d 2
let d = dec2 True
let d_ = dec2 False
let addDay =
2022-12-14 23:59:23 -05:00
\(x : T.GregorianM) ->
2022-12-11 17:51:11 -05:00
\(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 }
2022-12-15 22:48:14 -05:00
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
}
/\ T