[Haskell-cafe] NewBinary/ BinMem and IO monad

Marc Weber marco-oweber at gmx.de
Wed May 3 18:21:58 EDT 2006


I'm trying to write some true type library (implementing only the tables
I need at the moment).

When loading a font file it doesn't make sense to "parse" every table
which isn't needed. So lazyness of haskell would perfectly meet
requirements here.
My problem: NewBinary supports memory buffers. After loading a file to
mem it can't change anymore so I no longer need an IO monad.

It looks like this:

bh <- readBinMem "file"
b::Word8 <- get bh

Of cause I can't remove the monad here because bh contains an internal
pointer to the current position... but it might be done returning the
new pointer:
(bh2,b::Word8) = get bh ?

Then I would be able to lazily parse the tables eg: 

getTable1 bh = do
  bh = seek bh offset -- seek to the beginning of the table
  get binary data and build internal representation
  return list of glyph and outlines and ...

of cause this mem should be readonly then..

Would it make sense to implement this? Does it already exist?

Marc


More information about the Haskell-Cafe mailing list