From 35ae2d8a41be2123f2af5be58d51755c6065ea9f Mon Sep 17 00:00:00 2001 From: Charles Winebrinner Date: Tue, 1 Feb 2022 09:33:40 -0600 Subject: [PATCH] Blarg! Approved-by: pbrant --- runtests | 4 -- samples/Case.tmpl | 73 ++++++++++++++++++------------------- samples/County.tmpl | 42 ++++++++++----------- samples/SelfContained.tmpl | 55 ---------------------------- src/Ccap/Codegen/Scala.purs | 2 +- 5 files changed, 58 insertions(+), 118 deletions(-) delete mode 100644 samples/SelfContained.tmpl diff --git a/runtests b/runtests index 55fd7b8..6ee314e 100755 --- a/runtests +++ b/runtests @@ -32,8 +32,4 @@ for i in samples/*.tmpl; do # TODO: Test compilation of generated output. done -# We can at least test compile this one for now - -./codegen.js -p Test.Generated -m purs -o test/generated samples/SelfContained.tmpl - spago test diff --git a/samples/Case.tmpl b/samples/Case.tmpl index 4eea02e..b3ddc7b 100644 --- a/samples/Case.tmpl +++ b/samples/Case.tmpl @@ -4,41 +4,40 @@ purs: Samples.Case import Domains type Case: { - caseNo: Domains.CaseNoT - countyNo: Domains.CountyNoT - caseType: Domains.CaseTypeT - filingDate: Domains.DateT - isConfidential: Boolean - isFiledWoCtofc: Boolean - lastChargeSeqNo: Domains.ChargeSeqNoT - lastCvJgSeqNo: Domains.CivilJdgmtSeqNoT - lastHistSeqNo: Domains.HistSeqNoT - lastPartySeqNo: Domains.PartyNoT - lastRelSeqNo: Domains.RelSeqNoT - statusCode: Domains.StatusCodeT - isSeal: Boolean - isExpunge: Boolean - isElectronicFiling: Boolean - isPartySeal: Boolean - bondId: Maybe Domains.BondIdT - branchId: Maybe Domains.BranchIdT - caption: Maybe Domains.CaptionT - daCaseNo: Maybe Domains.DaCaseNoT - dispCtofcNo: Maybe Domains.CtofcNoT - fileCtofcDate: Maybe Domains.DateT - filingCtofcNo: Maybe Domains.CtofcNoT - issAgencyNo: Maybe Domains.IssAgencyNoT - maintCode: Maybe Domains.MaintCodeT - oldCaseNo: Maybe String - plntfAgencyNo: Maybe Domains.PlntfAgencyNoT - previousRespCo: Maybe Domains.CtofcNoT - prosAgencyNo: Maybe Domains.ProsAgencyNoT - prosAtty: Maybe Domains.AttyNoT - respCtofcNo: Maybe Domains.CtofcNoT - wcisClsCode: Maybe Domains.WcisClsCodeT - unifiedCaseNo: Maybe Domains.UnifiedCaseNoT - statClsCode: Maybe Domains.WcisClsCodeT - optInCode: Maybe Domains.PublicOptInCodeT - lastDocNumber: Domains.CaseDocNoT + caseNo: Domains.CaseNoT, + countyNo: Domains.CountyNoT, + caseType: Domains.CaseTypeT, + filingDate: Domains.DateT, + isConfidential: Boolean, + isFiledWoCtofc: Boolean, + lastChargeSeqNo: Domains.ChargeSeqNoT, + lastCvJgSeqNo: Domains.CivilJdgmtSeqNoT, + lastHistSeqNo: Domains.HistSeqNoT, + lastPartySeqNo: Domains.PartyNoT, + lastRelSeqNo: Domains.RelSeqNoT, + statusCode: Domains.StatusCodeT, + isSeal: Boolean, + isExpunge: Boolean, + isElectronicFiling: Boolean, + isPartySeal: Boolean, + bondId: Maybe Domains.BondIdT, + branchId: Maybe Domains.BranchIdT, + caption: Maybe Domains.CaptionT, + daCaseNo: Maybe Domains.DaCaseNoT, + dispCtofcNo: Maybe Domains.CtofcNoT, + fileCtofcDate: Maybe Domains.DateT, + filingCtofcNo: Maybe Domains.CtofcNoT, + issAgencyNo: Maybe Domains.IssAgencyNoT, + maintCode: Maybe Domains.MaintCodeT, + oldCaseNo: Maybe String, + plntfAgencyNo: Maybe Domains.PlntfAgencyNoT, + previousRespCo: Maybe Domains.CtofcNoT, + prosAgencyNo: Maybe Domains.ProsAgencyNoT, + prosAtty: Maybe Domains.AttyNoT, + respCtofcNo: Maybe Domains.CtofcNoT, + wcisClsCode: Maybe Domains.WcisClsCodeT, + unifiedCaseNo: Maybe Domains.UnifiedCaseNoT, + statClsCode: Maybe Domains.WcisClsCodeT, + optInCode: Maybe Domains.PublicOptInCodeT, + lastDocNumber: Domains.CaseDocNoT, } - diff --git a/samples/County.tmpl b/samples/County.tmpl index 112ab5f..9a219d7 100644 --- a/samples/County.tmpl +++ b/samples/County.tmpl @@ -33,34 +33,34 @@ type AssessFacilityId: wrap Int type SomethingMoney: wrap Decimal type County: { - countyNo: Domains.CountyNoT - countyNoX: CountyNo - countyName: CountyName - assessFacilityId: Maybe AssessFacilityId - soapPort: Int + countyNo: Domains.CountyNoT, + countyNoX: CountyNo, + countyName: CountyName, + assessFacilityId: Maybe AssessFacilityId, + soapPort: Int, } type Big: { a1: Int - b1: String - c1: Decimal - d1: Boolean - a2: Int - b2: String - c2: Decimal - d2: Boolean - a3: Int - b3: String - c3: Decimal - d3: Boolean - a4: Int - b4: String - c4: Decimal - d4: Boolean + b1: String, + c1: Decimal, + d1: Boolean, + a2: Int, + b2: String, + c2: Decimal, + d2: Boolean, + a3: Int, + b3: String, + c3: Decimal, + d3: Boolean, + a4: Int, + b4: String, + c4: Decimal, + d4: Boolean, } type Response: { - counties: Array County + counties: Array County, } type CountyEnum: [ diff --git a/samples/SelfContained.tmpl b/samples/SelfContained.tmpl deleted file mode 100644 index 86691a8..0000000 --- a/samples/SelfContained.tmpl +++ /dev/null @@ -1,55 +0,0 @@ -// A self-contained example that we can compile without additional -// dependencies. -scala: test.generated.SelfContained -purs: Test.Generated.SelfContained - -type CountyNo: Int -type CountyName: String -type OtherCountyName: wrap String -type AssessFacilityId: wrap Int -type SomethingMoney: wrap Decimal - -// We can wrap a type in a pre-existing newtype -type Bunnies: wrap Int - - -type County: { - countyNo: CountyNo - countyName: CountyName - assessFacilityId: Maybe AssessFacilityId - soapPort: Int -} - -type Big: { - a1: Int - b1: String - c1: Decimal - d1: Boolean - a2: Int - b2: String - c2: Decimal - d2: Boolean - a3: Int - b3: String - c3: Decimal - d3: Boolean - a4: Int - b4: String - c4: Decimal - d4: Boolean -} - -type Response: { - counties: Array County -} - -type CountyEnum: [ - | Adams - | Ashland - | Baron - | Etc -] - diff --git a/src/Ccap/Codegen/Scala.purs b/src/Ccap/Codegen/Scala.purs index ed66de3..a6218eb 100644 --- a/src/Ccap/Codegen/Scala.purs +++ b/src/Ccap/Codegen/Scala.purs @@ -405,7 +405,7 @@ sumTypeDecoder name constructors = do failureBranch = text ("case (n, l) => sys.error(s\"Match error on type " <> name <> " for constructor $n with ${l.length} parameters\")") func = - text "val d: Decoder.Form[M, Blarg] =" + text ("val d: Decoder.Form[M, " <> name <> "] =") // indented (text "p match" `curly` (branches `NonEmptyArray.snoc` failureBranch)) // text "d.disjunction" pure