Crosspost from /r/haskell: https://www.reddit.com/r/haskell/comments/1fvgzv4/gtvmhs_a_game_asset_toolkit_using_haskell_for/?
I’ve previously posted about various packages I’ve written supporting
- parser & serializer-like generics
- type-level string parsing
- types as binary schema
- refinement types (a rewrite of refined)
- generically strengthening & weakening types
Most of these I originally wrote while reversing a game, then span out into a
general-purpose library. I’ve finally come full-circle and replaced the
toolkit’s innards with their library versions.
The project output (an executable with various tools for coding between
binary/JSON schemas of a format, compression utilities etc.) is probably not of
much interest for most people. Instead, I want to present how effective Haskell
can be for something slightly more out there: reverse engineering.
See the GTVM.SCP docs and source in particular for how
easily we’re able to define both a binary schema and a simplified version for
transforming in user code; and then get JSON parsing/serializing, binary
parsing/serializing, value bounds assertions (strengthening) totally for free.
I really hate to think how I would’ve had to write this in C! It would be ten
times longer, and I definitely would have gotten a field mixed up, or shadowed
some variable somewhere. (It probably wouldn’t even be much faster at runtime.)
I would gladly field any questions about the project or its implementation.