Skip to content

fix(haskell): render any-type as Aeson Value instead of Maybe Text#2994

Merged
schani merged 2 commits into
masterfrom
agent/fix-issue-2005
Jul 22, 2026
Merged

fix(haskell): render any-type as Aeson Value instead of Maybe Text#2994
schani merged 2 commits into
masterfrom
agent/fix-issue-2005

Conversation

@schani

@schani schani commented Jul 20, 2026

Copy link
Copy Markdown
Member

Bug

The Haskell renderer mapped quicktype's "any" type to Maybe Text, which
only decodes JSON strings or null. Any schema resolving to any-type —
including a bare empty schema {} and nested cases like
additionalProperties: true — generated Haskell code that fails to decode
valid JSON values that aren't strings or null (numbers, booleans, objects,
arrays).

Repro:

echo '{}' > empty.schema
node dist/index.js --lang haskell --src-lang schema empty.schema

Before:

type Empty = Maybe Text

After:

type Empty = Value

Root cause

HaskellRenderer.ts's haskellType mapped anyType to Maybe Text
instead of a type that can hold arbitrary JSON. TypeScript emits any,
Dart emits dynamic, and Elm already handles this correctly by emitting
Jdec.value (Elm's arbitrary-JSON type). Aeson's Value is the Haskell
equivalent — it has identity ToJSON/FromJSON instances and can
represent any JSON value.

Fix

In packages/quicktype-core/src/language/Haskell/HaskellRenderer.ts,
anyType now renders as Value (from Data.Aeson, already imported)
instead of Maybe Text.

Test coverage

  • Enabled the existing any.schema JSON Schema fixture for the Haskell
    target (previously in skipSchema).
  • Extended test/inputs/schema/any.schema to add an additionalProperties: true property alongside the existing bare {} property.
  • Extended the any.N.json samples to include non-string any-typed values
    (numbers, objects, arrays, booleans, null) that would fail to round-trip
    under the old Maybe Text mapping.

Verification

  • npm run build passes.
  • Re-ran the issue's repro command: output changed from type Empty = Maybe Text to type Empty = Value.
  • Confirmed the extended any.schema fixture would fail on the unfixed
    renderer (a Maybe Text field cannot decode a JSON number/object/array)
    and generates correct-looking Aeson-based code after the fix.
  • This sandbox has no GHC/stack toolchain available, so the Haskell fixture
    test (QUICKTEST=true FIXTURE=schema-haskell script/test) could not be
    compiled and run locally; CI will validate the generated Haskell actually
    compiles and round-trips correctly.

Fixes #2005

🤖 Generated with Claude Code

…2005)

Co-Authored-By: gpt-5.6-sol via pi <noreply@openai.com>
@schani
schani merged commit 09e9484 into master Jul 22, 2026
28 checks passed
@schani
schani deleted the agent/fix-issue-2005 branch July 22, 2026 00:58
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.

empty object in json schema should accept arbitrary json

1 participant