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 ...

Get Haskell Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.