haskell-org: Literate Haskell with Org Mode Documentation

Haskell is well suited for literate programming. And org mode (at
least for emacs users) is well suited for the documentation part of a
literate program. Org mode provides a readable, lightweight markup
notation for pure text files with many powerful features. So can one
edit a literate haskell program in emacs such that the mode
automatically switches between haskell-mode and org-mode, depending
upon cursor location? Below is one way to do it:

The starting point is haskell-latex which utilizes multi-mode to
enable switching between latex-mode (AUCTeX or built-in mode) and the
latex style of literate haskell. The latex-mode mode needs to be
replaced by org-mode, and due to personal preference, the latex style
of literate haskell by the bird style. Modifying haskell-latex.el to
implement above changes results in the following code.

To use it, haskell-mode and org-mode should be already be installed and the following can be added to .emacs:

Update: In case above is not clear, to use org-mode markup with Haskell (in emacs) do as follows:

  1. Install org-mode and haskell-mode.
  2. Download multi-mode.el and also haskell-org.el, and store both where emacs can find them (set load-path if required).
  3. Finally, copy and paste these lines into your .emacs.