Lesson 13: Pipes

Contents
  • Introducing pipes
  • Pipe composition (>->)
    • Producers
    • Consumers
    • Effects
  • Pipe construction
  • Socket producers and consumers
  • The parsing pipe
  • The encoding pipe
  • mapM
    • Exercise: Implement map and mapM
  • Try it out
  • Where to go from here

Using Attoparsec’s incremental parsing ability, we fed the parser small chunks at a time. This approach eliminates the lazy I/O and affords us some more manual control over the I/O at the expense of being slightly more cumbersome.

A streaming library like pipesThe pipes packageAnother popular choice is conduit. provides a good middle ground between the two approaches, giving us back some of the convenience of lazy datatypes – and some additional ability to decompose our code into smaller cohesive pieces – without sacrificing fine-grained control over the operations of the program.

Sign up for access to the full page, plus the complete archive and all the latest content.