2008/10/1 George Pollard <[EMAIL PROTECTED]>:

> 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.

What you want for this is the environment monad, also known as the
Reader monad in Haskell. It gives you something similar to a piece of
read-only global state. For this application, you'd pass in two pieces
of state: the file handle to read, and the limit on the number of
bytes that a client can read.

Since we can't easily combine the normal Reader monad and IO, we use a
monad transformer stack.

I've attached an example for your amusement.

Attachment: ReadHelper.hs
Description: Binary data

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to