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.