Jan-Willem Maessen <[EMAIL PROTECTED]> writes: > Pixel <[EMAIL PROTECTED]> asks: > > I'm trying to achieve something like (ocaml) > > [code deleted] > > which is a foldl on 2 iterators. I've managed to use monads for one iterator, > > but i completly miss the way to work with 2 monads. Is there really no other > > solution than creating a monad over the 2 iterators?? > > Why monadic iterators at all? One of the great things about lazy > lists is they encapsulate iteration nicely: Elements can be generated > as they're consumed.
oops, i forgot this. /me was trying to translate from a language to another without thinking :-( of course, an iterator over a structure is a "to_list" function. /me bad [...] > You're having trouble combining the results of two state monads > precisely because they're manipulating two *independent* pieces of > state, and you're trying to combine the *states* of the monads in some > fashion. What should the type of the result of the manipulation be? > Where are the initial states of each computation coming from? I don't quite understand those questions. Combining states is a common task in imperative world. I must be missing something. I still don't understand what is to be done to mix monads. As far as I've seen the only really used monad is IO. So I can't find useful examples using the standard library. But suppose I have GUI which interacts via the gui and has getLine' and print', how can i do something that: - getLine on IO, getLine' on GUI - verify it is the same - print on IO, print' on GUI - ... > Some computations really are much more easily done in the value domain > then under a wrapper like a monad which obscures their real structure. Well, the intention was to hide the real structure :) But i agree i missed something simple... thanks, Pixel. _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
