[Haskell-cafe] Haskell in Org Mode Babel

Chris Warburton chriswarbo at googlemail.com
Thu May 29 08:45:59 UTC 2014

Apologies for the incomplete email, the Gnus "send mail" keybinding is
the same as Org mode's "evaluate code"!

I was wondering if anyone has had success with using Haskell in Org
mode. I'm writing a blog post, where I can include a code block like
the following and Org mode will print the result underneath:

#+begin_src haskell

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

By default, "haskell" code blocks will be sent to GHCi, which means I
can't do top-level definitions:

#+begin_src haskell :results value
true  x y = x
false x y = y
if_ c t e = c t e

: <interactive>:187:11: parse error on input `='

This can be worked around, but it's a little ugly and the "inferior
Haskell" comint mode doesn't strip the intermediate prompts properly:

#+begin_src haskell :prologue ":set +m" :results value both
let {true  x y = x;
     false x y = y;
     if_ c t e = c t e} in if_ true "then" "else"

: *Main| *Main| "then"

I've tried saving code to a separate file, which Org mode calls

#+begin_src haskell :tangle yes
true  x y = x
false x y = y
if_ c t e = c t e

Then loading the code from the GHCi prompt:

#+begin_src haskell :results value both
:load test.hs
if_ true "then" "else"

However it seems to be a bit hit-and-miss whether this will load the code.

How do others do this, if at all?


More information about the Haskell-Cafe mailing list