Have a look at the binary package, or any of its non-lazy variants: cereal or binary-strict .
In all three cases, since you have a specific binary format, I'd ignore the type class Binary defined in each, and instead focus on the Put and Get monads they define.