Skip to content

Modernize Elm target to 0.19#2959

Merged
schani merged 3 commits into
masterfrom
elm-0.19
Jul 20, 2026
Merged

Modernize Elm target to 0.19#2959
schani merged 3 commits into
masterfrom
elm-0.19

Conversation

@schani

@schani schani commented Jul 20, 2026

Copy link
Copy Markdown
Member

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

  • Decode pipelines are seeded with Jdec.succeed Foo instead of Jpipe.decode Foo (decode was removed in NoRedInk/elm-json-decode-pipeline 1.0; install instructions in the header comment updated accordingly).
  • The 0.19 elm/json encoder API (Json.Encode.list/array take the element encoder, Json.Encode.dict exists) makes the generated makeArrayEncoder/makeListEncoder/makeDictEncoder helpers unnecessary — they are gone; only makeNullableEncoder remains.
  • Imports no longer expose map/toList (ambiguous under 0.19 shadowing rules): import Dict exposing (Dict), plus import Array exposing (Array) only with --array-type array; List needs no import.
  • Elm 0.19 forbids parameters shadowing top-level definitions, so the parameter names used by generated functions (x, y, r, f, m, str, somethingElse) are now forbidden as generated global identifiers (caught by priority/unions.json, which has a type named x).
  • Generated identifiers can no longer start with _ (an 0.19 syntax error, caught by blns-object.json).
  • String literals escape non-printables with 0.19's \u{XXXX} syntax instead of \uXXXX/\UXXXXXXXX (caught by identifiers.json / nst-test-suite.json).

array-type now defaults to list

Defaults-audit recommendation #13, deferred until this modernization: List is the idiomatic Elm collection, and with the 0.19 encoder API the list path needs no helper at all. --array-type array still 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.jsonelm.json (elm/core, elm/json, NoRedInk/elm-json-decode-pipeline 1.0.1).
  • Main.elm uses Platform.worker (Platform.program is gone) and Jdec.errorToString for decode errors.
  • runner.js uses the 0.19 embedding API (Elm.Main.init() instead of Elm.Main.worker()).
  • A Warmup.elm module is compiled once by the setup command so all package dependencies are downloaded/built into the shared ELM_HOME cache before per-sample compiles run in parallel (elm 0.19.1 can corrupt its package registry on concurrent cold-cache downloads). The sysconfcpus hack 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.json and the recursion schemas (union-list, list, ref-remote, mutually-recursive, postman-collection, vega-lite, simple-ref, plus newly recursive-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 JS in operator, which finds inherited Object.prototype members — decoding {} yields a non-null "constructor".
  • nested-intersection-union.schema: the generated decoder accepts invalid union members because all class properties decode via Jpipe.optional (same limitation as documented for C++).
  • The five newly enabled identifier-heavy JSON inputs are in skipDiffViaSchema (schema round-trip changes inferred names/types); all 20 pre-existing skipDiffViaSchema entries were re-checked and still differ.

CI

- elm,schema-elm is 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 both FIXTURE=elm and FIXTURE=schema-elm, as do npm run test:unit and npm run lint.

🤖 Generated with Claude Code

schani and others added 3 commits July 20, 2026 08:42
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>
@schani
schani merged commit 1b96c26 into master Jul 20, 2026
28 checks passed
@schani
schani deleted the elm-0.19 branch July 20, 2026 13:27
@schani

schani commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

Follow-up: the toolchain moved to elm 0.19.2 in #2960 (0.19.2 refuses "elm-version": "0.19.1" applications and the release assets were renamed; no language changes, and the cold-cache warmup is still needed — the corruption reproduces with 0.19.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant