pwncash/dhall/common.dhall

176 lines
4.1 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
2023-02-27 22:04:06 -05:00
let T = ./Types.dhall
2022-12-14 23:59:23 -05:00
2023-06-10 21:38:13 -04:00
let nullEntry =
2023-04-30 11:52:30 -04:00
\(a : T.EntryAcntGetter) ->
\(c : T.EntryCurGetter) ->
2023-06-10 21:38:13 -04:00
T.ToEntryGetter::{ eAcnt = a, eCurrency = c, eTags = [] : List T.TagID }
2022-12-14 23:59:23 -05:00
let nullOpts = T.TxOpts::{=}
2023-04-30 11:52:30 -04:00
let nullVal = T.ValMatcher::{=}
2022-12-14 23:59:23 -05:00
2023-04-30 11:52:30 -04:00
let nullMatch = T.StatementParser::{=}
2022-12-14 23:59:23 -05:00
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
2023-04-30 22:54:20 -04:00
// { cpYear = Some (T.MDYPat.Single y)
, cpMonth = Some (T.MDYPat.Single m)
, cpDay = Some (T.MDYPat.Single d)
2022-12-11 17:51:11 -05:00
}
)
let matchInf_ = nullMatch
2023-04-30 23:00:26 -04:00
let matchInf = \(x : T.TxGetter) -> nullMatch // { spTx = Some x }
2022-12-11 17:51:11 -05:00
2023-04-30 23:00:26 -04:00
let matchN_ = \(n : Natural) -> nullMatch // { spTimes = Some n }
2022-12-11 17:51:11 -05:00
2022-12-14 23:59:23 -05:00
let matchN =
2023-04-30 23:00:26 -04:00
\(n : Natural) -> \(x : T.TxGetter) -> matchInf x // { spTimes = 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 }
2023-04-30 11:52:30 -04:00
let mY = \(y : Natural) -> T.DateMatcher.On (T.YMDMatcher.Y y)
2022-12-11 17:51:11 -05:00
let mYM =
2022-12-14 23:59:23 -05:00
\(y : Natural) ->
\(m : Natural) ->
2023-04-30 11:52:30 -04:00
T.DateMatcher.On (T.YMDMatcher.YM (gregM y m))
2022-12-11 17:51:11 -05:00
let mYMD =
\(y : Natural) ->
\(m : Natural) ->
\(d : Natural) ->
2023-04-30 11:52:30 -04:00
T.DateMatcher.On (T.YMDMatcher.YMD (greg y m d))
2022-12-11 17:51:11 -05:00
let mRngY =
\(y : Natural) ->
\(r : Natural) ->
2023-04-30 11:52:30 -04:00
T.DateMatcher.In { _1 = T.YMDMatcher.Y y, _2 = r }
2022-12-11 17:51:11 -05:00
let mRngYM =
\(y : Natural) ->
\(m : Natural) ->
\(r : Natural) ->
2023-04-30 11:52:30 -04:00
T.DateMatcher.In { _1 = T.YMDMatcher.YM (gregM y m), _2 = r }
2022-12-11 17:51:11 -05:00
let mRngYMD =
\(y : Natural) ->
\(m : Natural) ->
\(d : Natural) ->
\(r : Natural) ->
2023-04-30 11:52:30 -04:00
T.DateMatcher.In { _1 = T.YMDMatcher.YMD (greg y m d), _2 = r }
2022-12-11 17:51:11 -05:00
2023-06-10 21:38:13 -04:00
let PartEntry = { _1 : T.AcntID, _2 : Double, _3 : Text }
2022-12-11 17:51:11 -05:00
let partN =
2023-04-30 11:52:30 -04:00
\(c : T.EntryCurGetter) ->
\(a : T.EntryAcntGetter) ->
2022-12-11 17:51:11 -05:00
\(comment : Text) ->
2023-06-10 21:38:13 -04:00
\(ss : List PartEntry) ->
let toEntry =
\(x : PartEntry) ->
nullEntry (T.EntryAcntGetter.ConstT x._1) c
2023-04-30 22:54:20 -04:00
// { eValue = Some (T.EntryNumGetter.ConstN x._2)
, eComment = x._3
2023-04-30 11:52:30 -04:00
}
2022-12-11 17:51:11 -05:00
2023-06-10 21:38:13 -04:00
in [ nullEntry a c // { eComment = comment } ]
# List/map PartEntry T.ToEntryGetter.Type toEntry ss
2022-12-11 17:51:11 -05:00
let part1 =
2023-04-30 11:52:30 -04:00
\(c : T.EntryCurGetter) ->
\(a : T.EntryAcntGetter) ->
2022-12-11 17:51:11 -05:00
\(comment : Text) ->
2023-06-10 21:38:13 -04:00
partN c a comment ([] : List PartEntry)
2022-12-11 17:51:11 -05:00
let part1_ =
2023-04-30 11:52:30 -04:00
\(c : T.EntryCurGetter) ->
\(a : T.EntryAcntGetter) ->
2023-06-10 21:38:13 -04:00
partN c a "" ([] : List PartEntry)
2022-12-11 17:51:11 -05:00
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 }
2023-04-30 22:56:40 -04:00
let mvP = nullVal // { vmSign = Some True }
2022-12-11 17:51:11 -05:00
2023-04-30 22:56:40 -04:00
let mvN = nullVal // { vmSign = Some False }
2022-12-11 17:51:11 -05:00
2023-04-30 22:56:40 -04:00
let mvNum = \(x : Natural) -> nullVal // { vmNum = Some x }
2022-12-11 17:51:11 -05:00
2023-04-30 22:56:40 -04:00
let mvDen = \(x : Natural) -> nullVal // { vmDen = Some x }
2022-12-11 17:51:11 -05:00
2023-04-30 22:56:40 -04:00
let mvNumP = \(x : Natural) -> mvP // { vmNum = Some x }
2022-12-11 17:51:11 -05:00
2023-04-30 22:56:40 -04:00
let mvNumN = \(x : Natural) -> mvN // { vmNum = Some x }
2022-12-11 17:51:11 -05:00
2023-04-30 22:56:40 -04:00
let mvDenP = \(x : Natural) -> mvP // { vmDen = Some x }
2022-12-11 17:51:11 -05:00
2023-04-30 22:56:40 -04:00
let mvDenN = \(x : Natural) -> mvN // { vmDen = Some x }
2022-12-11 17:51:11 -05:00
2023-06-10 21:38:13 -04:00
in { nullEntry
2022-12-15 22:48:14 -05:00
, nullMatch
, nullVal
, nullOpts
, nullCron
, nullMod
, cron1
, mY
, mYM
, mYMD
, mRngY
, mRngYM
, mRngYMD
, matchInf_
, matchInf
, matchN_
, matchN
, match1_
, match1
, greg
, gregM
, partN
, part1
, part1_
, addDay
, comma = 44
, tab = 9
, mvP
, mvN
, mvNum
, mvNumP
, mvNumN
, mvDen
, mvDenP
, mvDenN
2023-06-10 21:38:13 -04:00
, PartEntry
2022-12-15 22:48:14 -05:00
}
/\ T