[Haskell-cafe] Restricted file reading monad

Henning Thielemann lemming at henning-thielemann.de
Sat Oct 4 18:25:28 EDT 2008

On Thu, 2 Oct 2008, George Pollard wrote:

> Hello all,
> I'm currently working on a (toy) ID3 [1] tag reader, which made me think
> of a library which might be quite useful.
> The structure of an ID3 tag goes something like this:
> Header:
> - total size of tag
> - other header info
> A series of frames, each with:
> - total size of frame
> - other header info
> - frame data
> Since the ID3 tag as a whole has size information, I need to pass that
> into the frame-reading functions to ensure that I never read past the
> end of the total header. This exact same requirement is present within
> the frame-reading function itself; it must read the frame data without
> reading past the end of the frame.

I've done exactly this for a MIDI file parser. It uses a State monad 
transformer which handles the number of remaining bytes in the chunk.

More information about the Haskell-Cafe mailing list