July 2023
Intermediate to advanced
670 pages
17h 13m
English
In the last chapter, you built a tool to encode a file archive as raw binary data. One of the biggest challenges that we ran into as we were developing that project was the fact that we wanted to support files with different types in a single archive. We were able to do this by using existential types to erase the information about a specific type but keep the important information that it had an Encode instance.
The fundamental reason that this approach worked for encoding was that, at some point, the user of our library had to create values that were loaded into a FilePack, and those values had to have instances that said how the data should be encoded. Our existential type allowed us to forget the other information ...