Examples

To hopefully illuminate the role of the different data structures,
here are the command-line options for a (very simple) compiler,
done in two different ways.
The difference arises because the type of getOpt is
parameterized by the type of values derived from flags.

Interpreting flags as concrete values

A simple choice for the type associated with flags is to define a type
Flag as an algebraic type representing the possible flags and their
arguments:

Similarly, each flag could yield a monadic function transforming a record,
of type Options -> IO Options (or any other monad), allowing option
processing to perform actions of the chosen monad, e.g. printing help or
version messages, checking that file arguments exist, etc.