Summary

We explored three styles of doing I/O in Haskell: imperative I/O, lazy I/O, and Iteratee I/O. While imperative I/O gave us fine control over resource management and space requirements, it had to be written at a low level of abstraction.

In contrast to this, lazy I/O stood out as elegant and written at a high level of abstraction, giving us great decoupling between producers and consumers. Then we explored the high price we pay for relinquishing control of when side effects occur.

Finally, we found that Iteratee I/O gives us the best of both worlds, fine control over resource management and usage, and written at a very high level of abstraction.

While looking at the three styles, we paid close attention to who was driving evaluation. We looked at the means of decoupling producers and consumers of data and also the extent to which producers and consumers can communicate in the midst of data processing.

In the next chapter, we will focus on patterns for composition with a focus on the fundamental types: Functor, Applicative Functor, Arrow, and Monad. There is much more to compose in Haskell than functions!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset