Draft: Abstract binary serialization behind a ReaderT newtype with pure encode/decode interface
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}
, andhaddock.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.