In org-mode, a line starting with a colon is formatted as source code. ( http://orgmode.org/manual/Literal-examples.html )
In literate Haskell, source code lines start w
I'm a bit late, but I recently started to work on the 99 Haskell problems and decided to collect my work in an org mode file.
The orgmode way of literate programming (as I understand it), is to encapsulate source code blocks in BEGIN/END blocks. For example,
#+BEGIN_SRC hs :tangle yes
myReverse :: [a] -> [a]
myReverse l = myReverse' l []
myReverse' [] accu = accu
myReverse' (x:xs) accu = myReverse' xs (x:accu)
#+END_SRC
Such a structured orgmode document can then be
exported Exporting is the transformation of an orgmode file to one of several other file formats by means of a backend. Some of those formats are PDF, LateX or HTML.
tangled This goes in the direction of literate programming and weaving. Code blocks can be exported to pure source files. This is what I do in my 99 problems file.
executed Source code blocks can be executed, and the result of this execution can be placed directly in the orgmode file. I have not tried this yet for haskell.
You can have a look at my attempts at github: https://github.com/dischoen/H99 There I tangle the orgmode file to two haskell files, a module and a test harness, which can then be tested in ghc or ghci.
So, obviousely this is not the intended ways to use org.
The main issue when doing this is that both, org-mode and haskell-mode are major modes. So I cannot use them in parallel.
Nevertheless this is how it works, it is a hack, and I am not sure about side effects ..:
When viewing a file in emacs, the (a?) code trigger seems to be in org-activate-code (org.el), but this is not used for export. For HTML export I had to touch org-html.el too.
I changed:
In org.el line 5378, function org-activate-code from
"^[ \t]*\\(:\\(?: .*\\|$\\)\n?\\)"
to
"^[ \t]*\\([:>]\\(?: .*\\|$\\)\n?\\)"
And in org-html.el line 1508 and 1516, function org-export-as-html from
(string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line)
to
(string-match "^[ \t]*[:>]\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line)
and (line 1516)
(string-match "^[ \t]*[:>]\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
Looking at it I assume that this has to be adapted for every export channel one intends to use.
Not an exact answer to your question, but an example of how I write literate Haskell using org: https://github.com/haroldcarr/make-mp3-copies
The README.org is the literate Haskell, the MakeMP3Copies.hs is the resulting haskell file that is "tangled" out of the .org file.
I export to HTML and publish on my blog: http://haroldcarr.com/posts/2013-09-11-flac-to-mp3-via-haskell-shelly-and-ffmpeg.html
The README.org also autorenders on github (although there is some stuff in the autorendering that is only meant for HTML that I have not taken the time to fix).
I had essentially the same motivation, to use org-mode markup for my Haskell (Bird style) literate programs. I ended up using multi-mode which allows multiple emacs major modes to be used for different regions in the same buffer (there are others but multi-mode suited my requirements). I cooked up haskell-org which enables org-mode and haskell-mode to be used in a single buffer via multi-mode.
More details in this blog entry. The setup works well enough that I use it for my Haskell coding.