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

Luke Palmer lrpalmer at gmail.com
Mon Jun 30 06:11:22 EDT 2008


2008/6/30 Joachim Breitner <mail at joachim-breitner.de>:
> The problem I stumbled over was that considering the type of >>=
>  (>>=): Monad m => m a -> (a -> m b) -> m b
> means that I can not „look ahead" what files would be written without
> actually reading the requested file. Of course this is not always
> possible, although I expect this code to be the exception:

I am somewhat unclear about what you are asking.  My first impression
though is that if you're running into trouble with "looking ahead",
then this algebra is probably not a Monad.  In fact, these use cases
indicate an applicative functor to me (Control.Applicative).  Of
course, the problem with applicative functors is that the syntax that
goes with them is not as imperative as monad syntax, and syntax is a
big motivator for finding monads.

Luke


More information about the Haskell-Cafe mailing list