Functional programming differs significantly from imperative programming in the ways we design programs. Typing discipline adds some specifics, too. When we code in Haskell, we think in a special way: in terms of the given data and the desired processing results (with both sides expressed by types), instead of focusing on the steps we should execute to get those results.
- By using GHCi REPL (read-evaluate-print-loop) without writing a program
- By writing functions properly
- By keeping pure functions separate from the I/O actions that communicate to users
- By expressing ideas with types
We’ll also explore several of Haskell’s libraries for text processing, which is arguably one of the most common, albeit routine, tasks in software development nowadays.
Suppose we want to analyze the vocabulary of a given text. Many sophisticated methods for such analysis are available, but we will do something quite basic, though still useful: