On Mon, Jun 13, 2011 at 4:45 PM, M.C.A. (Marco) Devillers < [email protected]> wrote:
> > The urge to do I/O at all the wrong places is a born instinct. > > > The original poster was well aware how to factor out IO out of his program, > as made apparent by his initial comment: "An option I suppose would be to > read the dictionary at the top level, and then pass it all the way down to > the analysis routine that uses it, but that exposes the details of how the > analysis is done, and couples the top and bottom levels of the previously > modular functions." > > His original argument was a genuine observation that IO sometimes seems to > be adverse to the loose coupling of modules. Dissing that argument away as: > "you are doing IO at the wrong place," doesn't convince me the least. > > There are ways to decouple IO from pure code. I often have a "Main" datatype which constructs a "pure context" (based on command line arguments, files and their contents, etc) which is then "interpreted" by pure code. In other words, this is a pure control structure, which is computed by IO (sometimes in an applicative style, sometimes in a monadic one), and then passed into the pure world for processing. This can be as tightly or loosely coupled as we like, assuming we understand that if a value is even partially based on the results of an IO computation, then IO is going to drive the computation of that value. There's no way around that.
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
