
26 Nov
2009
26 Nov
'09
3:01 p.m.
2009/11/26 Brent Yorgey
Do you *really* need 'Chunk' to be able to hold *any* type of data? Or are there just a few alternatives? If there are only a few alternatives, you can put the alternatives together in a data type, like this:
Horribly enough, RIFF files do seem to support any type of data. A processor of RIFF files would presumably parse chunk types that it knows to expect and discard the rest. Data.Dynamic from the Hierarchical libs shipped with GHC is another option. Or a home brewed union type: data Chunk = WaveChunk { ... } | AuChunk { ... } | UnintrepretedChunk ByteString Best wishes Stephen