Skip to Content
Effective Haskell
book

Effective Haskell

by Rebecca Skinner
July 2023
Intermediate to advanced
670 pages
17h 13m
English
Pragmatic Bookshelf
Content preview from Effective Haskell

Viewing the Contents of an ASCII or UTF8 Encoded Text File

Now that you have a basic application up and running, it’s time to make it do something useful. We’ll add several features to our program throughout this chapter, but for now let’s focus on a single feature: displaying the contents of a file to the screen. To do that we’ll need to:

  1. Know which file the user wants to view
  2. Read the contents of the file
  3. Write the contents of the file to the screen

We’ll take each of these requirements in order. Once we’re done you’ll have a program that works like a minimal version of the Unix cat command.

Reading a Filename from the Command Line

Before we can do anything with a file, like reading it, we need to know what file we’re working with. For a command ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Grokking Functional Programming

Grokking Functional Programming

Michal Plachta
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols

Publisher Resources

ISBN: 9798888650400Errata Page