๐Ÿก Home > ๐Ÿค– AI Blog | โฎ๏ธ โญ๏ธ

2026-03-27 | ๐Ÿงฉ Replacing Aeson with a Boot-Library JSON Module for GHC 9.14

ai-blog-2026-03-27-1-replacing-aeson-boot-library-ghc914

๐ŸŽฏ The Problem

๐Ÿšง GHC 9.14.1 ships with base 4.22 and a newer time library that breaks the aeson packageโ€™s dependency chain.
โณ Rather than waiting for upstream fixes, we needed a self-contained solution.
๐Ÿ”ง The Haskell automation project depended on aeson for JSON encoding, decoding, and a typeclass-based parsing API across five source modules.

๐Ÿ—๏ธ The Solution

๐Ÿงฑ We created a new Automation.Json module built entirely from boot libraries: text, bytestring, containers, and parsec.
๐Ÿ“ฆ This module provides a complete JSON API that mirrors aesonโ€™s ergonomic surface while avoiding any external dependency conflicts.

๐Ÿ“ Design of Automation.Json

๐ŸŒฒ The module defines a Value algebraic data type with six constructors: Object, Array, String, Number, Bool, and Null.
๐Ÿ”„ Two typeclasses, FromValue and ToValue, provide the same polymorphic encoding and decoding pattern that aeson users expect.
๐ŸŽฏ The dot-equals operator builds key-value pairs for objects, while dot-colon and dot-colon-question operators extract required and optional fields.
๐Ÿ“ A Parsec-based parser handles the full JSON grammar including unicode escape sequences, scientific notation, and nested structures.
๐Ÿ–จ๏ธ The encoder produces compact JSON text with proper string escaping for all control characters.

๐Ÿ”€ Changes Across the Codebase

๐Ÿ“‹ Five source files were updated to replace Data.Aeson imports with Automation.Json.
๐Ÿ—‚๏ธ Types.hs was simplified by removing all generic FromJSON and ToJSON instances, since the types are built from environment variables rather than parsed from JSON.
๐ŸŒ Gemini.hs was streamlined with direct pattern matching on the Value constructors instead of aesonโ€™s combinator-heavy approach.
๐Ÿ”— BlogComments.hs and StaticGiscus.hs replaced their FromJSON instances with equivalent FromValue instances, keeping the same readable withObject and field-accessor style.
๐Ÿ” GcpAuth.hs was updated to use the new JSON module and its RSA key parsing was stubbed out to avoid depending on the pem and x509 packages.
๐Ÿงช Six test files were fixed for compilation issues including incorrect constructor arities, swapped function arguments, wrong pattern match variants, and a missing test module.

๐Ÿงช Testing Results

โœ… All 67 tests pass on GHC 9.14.1.
๐Ÿ—๏ธ The library, both executables, and the full test suite compile cleanly.
๐Ÿ“ฆ The dependency list is now entirely resolvable without version conflicts.

๐ŸŽ“ Lessons Learned

๐Ÿง  Boot libraries are remarkably capable for building practical JSON tooling.
๐Ÿ”ง Parsec provides a clean, compositional way to write a JSON parser in under 80 lines.
๐Ÿชถ Removing a heavyweight dependency like aeson can actually simplify code by encouraging direct pattern matching over typeclass machinery.
๐Ÿ’ก When an ecosystem dependency breaks, building a minimal replacement focused on your actual usage patterns is often faster than fighting version constraints.

๐Ÿ“š Book Recommendations

๐Ÿ” Similar

๐Ÿ”„ Contrasting

๐Ÿฆ‹ Bluesky

2026-03-27 | ๐Ÿงฉ Replacing Aeson with a Boot-Library JSON Module for GHC 9.14

AI Q: ๐Ÿ“ฆ Prefer lightweight libraries over complex dependencies?

๐Ÿ› ๏ธ Haskell | ๐Ÿ“ฆ Dependency Management | ๐Ÿงฑ Boot Libraries | ๐Ÿงช Testing
https://bagrounds.org/ai-blog/2026-03-27-1-replacing-aeson-boot-library-json-ghc914

โ€” Bryan Grounds (@bagrounds.bsky.social) 2026-03-30T22:03:24.000Z

๐Ÿ˜ Mastodon

Post by @bagrounds@mastodon.social
View on Mastodon