Skip to content

Draft: Abstract binary serialization behind a ReaderT newtype with pure encode/decode interface

Josh Meredith requested to merge JoshMeredith/ghc:binary-readerT into master

The current Binary implementation unnecessarily exposes an exclusively IO interface, preventing a pure encode/decode.

Motivation: #17363

This patch replaces the current IO serialization API with Put/Get readers, and additionally implements a Generics default instance for the updated Binary class.

This refactoring opens up:

  • Pure encode/decode
  • Abstracting the copy-paste duplication between ghc.BinIface.{readBinIface, writeBinIface}, ghc.HieBin.{readHieFile, writeHieFile}, and haddock.Haddock.InterfaceFile.{readInterfaceFile, writeInterfaceFile}
  • Replacing the GHC-specific implementation with one of the standard libraries (#3379) now that the types align more closely with reader-like implementations.
Edited by Andreas Klebinger

Merge request reports