Conversation
Modernize the Elm renderer from Elm 0.18 (which elm.org no longer
supports) to Elm 0.19:
- Seed decode pipelines with `Jdec.succeed` instead of the `decode`
function that was removed in NoRedInk/elm-json-decode-pipeline 1.0.
- Use the 0.19 elm/json encoder API: `Json.Encode.list`/`array` now take
the element encoder directly and `Json.Encode.dict` exists, so the
generated `makeArrayEncoder`/`makeListEncoder`/`makeDictEncoder`
helpers are gone; only `makeNullableEncoder` remains.
- Stop exposing `map`/`toList` from imports (Elm 0.19 shadowing rules);
only `Dict` (and `Array` when needed) are exposed.
- Forbid the parameter names used by generated functions (`x`, `y`, `r`,
`f`, `m`, `str`, `somethingElse`) as global identifiers: Elm 0.19 does
not allow a parameter to shadow a top-level definition.
- Never start generated identifiers with an underscore, which Elm 0.19
rejects.
- Escape non-printable characters in string literals with Elm's
`\u{XXXX}` syntax; the previously used `\uXXXX`/`\UXXXXXXXX` forms are
syntax errors in Elm 0.19.
- Update the usage comment to `elm install NoRedInk/elm-json-decode-pipeline`
and fix a stray backtick in it.
Elm 0.18 output is not supported anymore.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`List` is the idiomatic Elm collection type, and with the 0.19 `Json.Encode.list` API it needs no custom encoder helper. Generating `Array` is still available via `--array-type array`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Rewrite the fixture driver for Elm 0.19: `elm.json` replaces `elm-package.json`, `Main.elm` uses `Platform.worker` and `Jdec.errorToString`, and `runner.js` uses the 0.19 embedding API (`Elm.Main.init()`). The setup command compiles a new `Warmup.elm` to pre-populate the shared ELM_HOME package cache, because elm 0.19.1 can corrupt its package registry when parallel compiles race on a cold cache; the 0.18-era `sysconfcpus` hack is gone. Every skip-list entry was re-verified against elm 0.19.1: - `identifiers.json`, `simple-identifiers.json`, `blns-object.json`, `nst-test-suite.json`, and `keywords.json` now pass (they only failed on 0.19 escape syntax, leading underscores, and shadowing, all fixed in the renderer) and are only excluded from the diff-via-schema code comparison, where schema round-tripping changes inferred names. - The recursive inputs stay skipped: Elm type aliases cannot be recursive. - `constructor.schema` and `keyword-unions.schema` stay skipped with an accurate reason: elm/json's field decoder uses the JS `in` operator, which finds inherited Object.prototype members. - `nested-intersection-union.schema` is newly skipped: the generated decoder accepts invalid union members because all class properties decode via `Jpipe.optional`. - `recursive-union-flattening.schema` (added since the fixture was disabled) is skipped for recursion. The quicktest renderer option flips to `array-type: array` to keep the non-default Array path covered now that `list` is the default. The full corpus passes locally with elm 0.19.1 (215 JSON tests including misc, 67 schema tests), so `elm,schema-elm` returns to the CI matrix; the workflow's elm 0.19.1 install step already existed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
Author
|
Follow-up: the toolchain moved to elm 0.19.2 in #2960 (0.19.2 refuses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modernizes the Elm target from Elm 0.18 to Elm 0.19 and brings the Elm fixtures back into CI.
Breaking: Elm 0.18 output is removed
The renderer now emits Elm 0.19 code only. There was never a version option, so nothing was deleted from the options surface — the generated code simply targets 0.19 now, and 0.18 projects can stay on older quicktype releases.
Generated-output changes
Jdec.succeed Fooinstead ofJpipe.decode Foo(decodewas removed in NoRedInk/elm-json-decode-pipeline 1.0; install instructions in the header comment updated accordingly).Json.Encode.list/arraytake the element encoder,Json.Encode.dictexists) makes the generatedmakeArrayEncoder/makeListEncoder/makeDictEncoderhelpers unnecessary — they are gone; onlymakeNullableEncoderremains.map/toList(ambiguous under 0.19 shadowing rules):import Dict exposing (Dict), plusimport Array exposing (Array)only with--array-type array;Listneeds no import.x,y,r,f,m,str,somethingElse) are now forbidden as generated global identifiers (caught bypriority/unions.json, which has a type namedx)._(an 0.19 syntax error, caught byblns-object.json).\u{XXXX}syntax instead of\uXXXX/\UXXXXXXXX(caught byidentifiers.json/nst-test-suite.json).array-typenow defaults tolistDefaults-audit recommendation #13, deferred until this modernization:
Listis the idiomatic Elm collection, and with the 0.19 encoder API thelistpath needs no helper at all.--array-type arraystill works and stays covered in CI by a quicktest entry (quickTestRendererOptions).Fixture revival
The driver in
test/fixtures/elm/is rewritten for 0.19:elm-package.json→elm.json(elm/core, elm/json, NoRedInk/elm-json-decode-pipeline 1.0.1).Main.elmusesPlatform.worker(Platform.programis gone) andJdec.errorToStringfor decode errors.runner.jsuses the 0.19 embedding API (Elm.Main.init()instead ofElm.Main.worker()).Warmup.elmmodule is compiled once by the setup command so all package dependencies are downloaded/built into the sharedELM_HOMEcache before per-sample compiles run in parallel (elm 0.19.1 can corrupt its package registry on concurrent cold-cache downloads). Thesysconfcpushack for the 0.18 compiler is gone.Skip lists (every entry re-verified against elm 0.19.1)
Un-skipped (fixed by the renderer changes above):
identifiers.json,simple-identifiers.json,blns-object.json,nst-test-suite.json,keywords.json.Still skipped, with verified reasons:
recursive.json,direct-recursive.json,bug427.json,bug790.json,list.jsonand the recursion schemas (union-list,list,ref-remote,mutually-recursive,postman-collection,vega-lite,simple-ref, plus newlyrecursive-union-flattening): Elm type aliases cannot be recursive.constructor.schema,keyword-unions.schema: compile and run now, but elm/json's field decoder uses the JSinoperator, which finds inheritedObject.prototypemembers — decoding{}yields a non-null"constructor".nested-intersection-union.schema: the generated decoder accepts invalid union members because all class properties decode viaJpipe.optional(same limitation as documented for C++).skipDiffViaSchema(schema round-trip changes inferred names/types); all 20 pre-existingskipDiffViaSchemaentries were re-checked and still differ.CI
- elm,schema-elmis re-enabled in the test matrix; the workflow's elm 0.19.1 install step already existed. Locally validated with elm 0.19.1: the full corpus (215 JSON tests incl. misc, 67 schema tests) passes for bothFIXTURE=elmandFIXTURE=schema-elm, as donpm run test:unitandnpm run lint.🤖 Generated with Claude Code