In this chapter we have covered the advantages and disadvantages of lazy I/O and its alternatives: strict I/O and some streaming solutions. We learned to connect to remote network endpoints as clients and to write own network servers in Haskell. We also learned that acquired I/O resources such as handles and sockets must always be freed. For this, we considered two main solutions: functions such as bracket
and the ResourceT
monad transformer.
After reading this chapter you should now understand and be able to use lazy I/O without surprising memory leaks and correctly release all acquired resources as well as exceptions. You know and can use three streaming libraries: rudimentary io-streams
, elegant pipes
, and industrial conduits
. You are also bound to enjoy doing logging from your Haskell programs with FastLogger and monads with monad-logger
.
In the next chapter, we will focus on concurrent programming in Haskell. Light-Lightweight GHC threads give a lot of flexibility for the concurrent...