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

Joachim Breitner mail at joachim-breitner.de
Thu Jul 3 17:37:08 EDT 2008


Am Donnerstag, den 03.07.2008, 11:35 -0700 schrieb David Roundy:
> On Thu, Jul 03, 2008 at 07:09:58PM +0100, ChrisK wrote:
> > Joachim Breitner wrote:
> > You are violating the monad laws.  (f >> k) and (f >>= \_ -> k)
> > should do the same thing.  You might write a version of liftIO that
> > has the effect you want, however.
> I don't mind a little anarchy in the monad laws...  :)

It depends on what level you want them to be true. Assuming the rest of
the code is correct, the only difference that (f >> k) from (f >>= \_ ->
k) is that a file write in k, which would make no difference, would be
omitted. In this sense, the monad laws are followed.

> I must say that I prefer the automatic computation of dependencies as
> outlined by Joachim. 


> Of course, to create a "make" replacement, you'd also have to be able
> to call external programs and track which files they use, which is a
> hard problem, particularly as which files they use may depend on the
> contents of the files that they use.  One could, however, lift calls
> to well-behaved external programs (e.g. those like ghc or gcc that can
> output their dependencies) into this sort of monad.

That’s easily possible with a custom sourceAction, which allows you to
set the action, and the time stamp detection independently.

Joachim "nomeata" Breitner
  mail: mail at joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C
  JID: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/
  Debian Developer: nomeata at debian.org
-------------- 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/20080703/6607d84e/attachment.bin

More information about the Haskell-Cafe mailing list