The tasks of a lexical analyzer for Haskell

The main tasks of the lexical analyzer is grouping characters into lexemes and throwing away white space.

This sounds simple enough, but there are many non-trivial subtasks:

This is why the monolithic code is so complex...