Skip to content

Migrate to aeson 2.0+ (KeyMap API)#5

Open
anpryl wants to merge 3 commits intosebright:masterfrom
anpryl:aeson-2.0-compat
Open

Migrate to aeson 2.0+ (KeyMap API)#5
anpryl wants to merge 3 commits intosebright:masterfrom
anpryl:aeson-2.0-compat

Conversation

@anpryl
Copy link
Copy Markdown

@anpryl anpryl commented Feb 9, 2026

Summary

Migrates from Data.HashMap.Strict to Data.Aeson.Key / Data.Aeson.KeyMap for compatibility with aeson 2.0+.

Changes

  • Replace import qualified Data.HashMap.Strict as H with Data.Aeson.Key and Data.Aeson.KeyMap imports
  • Update Args type alias from A.Object to KM.KeyMap A.Value
  • Convert all H.lookup calls to KM.lookup with AK.fromText key wrapping
  • Update .:, .:?, and .= operators to use AK.fromText for text keys
  • Replace emptyObject with A.Object KM.empty
  • Update MethodMap type from H.HashMap Text to KM.KeyMap
  • Remove unordered-containers dependency (no longer needed)
  • Relax upper bounds for base, bytestring, text, vector, deepseq, mtl
  • Set aeson >=2.0 && <2.3

Fixes #3

Generated with Claude Code

anpryl and others added 3 commits February 9, 2026 19:54
aeson 2.0 replaced HashMap-based Object with KeyMap-based Object.
This updates all HashMap operations to use the KeyMap and Key APIs:
- H.lookup -> KM.lookup with AK.fromText for key conversion
- Object type alias -> KM.KeyMap A.Value
- .: and .:? operators now use AK.fromText for string keys
- Object construction uses AK.fromText for keys
- emptyObject replaced with A.Object KM.empty
- MethodMap type updated from HashMap to KeyMap
- Dependency bounds updated: aeson >=2.0, removed unordered-containers
- Relaxed upper bounds for base, bytestring, text, vector, deepseq, mtl

Fixes sebright#3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Data.Aeson.KeyMap no longer exports adjust in aeson 2.2.x.
Replace with KM.lookup + KM.insert pattern.
Previously, parseArg used A.fromJSON which discards the JSONPath
accumulated by (.:) and withObject, producing bare error strings like
"expected Number, got String".

Switch to iparse/IResult/formatError so that the full path is included
in the error: "Error in $.products[0].price: expected Number, got String".
This makes JSON-RPC -32602 errors actionable without guessing which field
caused the failure.
@sebright
Copy link
Copy Markdown
Owner

Thank you for making this PR. I already merged #3, because it supports more versions of aeson, but I could merge the JSONPath change if you want to rebase the last commit (and only give a better error message for newer versions of aeson).

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.

2 participants