Creating a Parsing Function

Before we can start unpacking an entire archive we need to think smaller. A filepack archive is made up of one or more different FileData values, and each of those FileData values are in turn made up of all of the individual values in the overall record. If we want to unpack a FileData, we’ll need to start by being able to unpack each of the individual types that make up a FileData record.

Let’s start by decoding Word32 values. Not only do we need to decode these because they are one of the types that make up a FileData record, but we’re also going to need to deal with the Word32 size field prefixes that we added to help us encode compound values more easily.

We already have a Decode instance for Word32 that makes ...

Get Effective Haskell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.