[Haskell-cafe] A Monad for on-demand file generation?

Joachim Breitner mail at joachim-breitner.de
Tue Jul 1 17:57:47 EDT 2008


thanks again for you input. Just one small remark:

Am Dienstag, den 01.07.2008, 14:52 -0700 schrieb Ryan Ingram:
> On 7/1/08, Joachim Breitner <mail at joachim-breitner.de> wrote:
> > Am Montag, den 30.06.2008, 16:54 -0700 schrieb Ryan Ingram:
> > > 1) unsafeInterleaveIO seems like a big hammer to use for this problem,
> > > and there are a lot of gotchas involved that you may not have fully
> > > thought out.  But you do meet the main criteria (file being read is
> > > assumed to be constant for a single run of the program).
> >
> > Any other gotcha? Anyways, is this really worse than the similary lazy
> > readFile? Using that would not safe the call to open, but at least the
> > reading and processing, in the same situations.
> Well, you're also (from your description) probably writing some
> tracking information to an IORef of some sort.  That can happen in the
> middle of an otherwise pure computation, and it's difficult to know
> exactly when it'll get triggered, due to laziness.  You can probably
> make it work :)

Well, for the tracking information, I can do it purely, by copying code
from StateT (or WriterT or ReaderT, I’m not sure :-)), and adapting
slightly (e.g. the (>>) optimization). So besides unsafeInterleaveIO, no
“bad, unpure stuff” should be necessary.

I think I’ll put my ideas to code soon and post it here.

Joachim Breitner
  e-Mail: mail at joachim-breitner.de
  Homepage: http://www.joachim-breitner.de
  ICQ#: 74513189
  Jabber-ID: nomeata at joachim-breitner.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080701/0e2c5e95/attachment.bin

More information about the Haskell-Cafe mailing list