8 A tool for CSV

 

This chapter covers

  • Parsing numerical values from text
  • Defining and using foldings on data structures
  • Using the Functor type class and its functionality to deal with errors
  • Creating a simple command-line parsing interface

In the last chapter, we started building the backbone for an application that can work with CSV files. This chapter is concerned with finishing the project and providing functionality for parsing and printing our Csv data type.

The chapter will continue where we left off by showcasing very important concepts, such as the Functor type class and folding, to make you familiar with core functional programming concepts. We close the chapter by bringing all of these newly learned skills together in a short program, putting our library to use. Finally, we will also install the created binary to our computer locally.

8.1 Parsing data

Next, we want to give our program a way of reading and parsing CSV files. For this, we need to write functions that can read the file contents of such a file, parse delimiters and fields, and write them to a data structure.

8.1.1 Parsing numeric values

8.2 Folding data structures

8.2.1 The concept of folding

8.2.2 A structure for parsing

8.2.3 The Functor type class

8.2.4 Using folding for parsing

8.3 Printing a CSV

8.3.1 Operations on CSVs

8.4 A simple command-line parser

8.4.1 Supporting flags and complicated arguments

Summary