[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Haskell org-mode problems redux

From: Lawrence Bottorff
Subject: [O] Haskell org-mode problems redux
Date: Thu, 30 May 2019 12:55:42 -0500

I've been trying to get Haskell to work in babel code blocks for a long time. A year or so ago I tried and eventually gave up. I tried again recently . . . same old problems, i.e., the code block is evaluated exclusively by the ghci REPL, which doesn't understand or play well with an org babel code block.

Before, the recipe was to add `:set +m` to either the top of the block or run it in the REPL to allow "multiple lines" declarations, e.g., functions. Then there was the `let` in front of a function declaration, which is also a REPL workaround. Now it seems you need the :{ ... :} trick to get all the code block lines to be seen as together, i.e.,

#+begin_src haskell :results raw
  doubleSmallNumber x =
    if x > 10
    then x
    else x * 2

otherwise the block is treated as though it is being fed into the REPL one at a time with no idea these lines are together making a function declaration. I'm on latest org, have installed Haskell stack 8.6.3 on Ubuntu (Haskell stack 8.6.5 on Windows). The maddening thing is the intermittent behavior, i.e., sometimes it likes what you're doing:

 #+begin_src haskell :results raw
tripleMe x = x + x + x


#+begin_src haskell :results raw
[x | x <- [0..100], x `mod` 2 == 0 && x `mod` 7 == 0]

Prelude> [0,14,28,42,56,70,84,98]

work fine -- but often enough when trying to declare a function with type declaration first I get cryptic errors -- which are then solved with the :{ ... :} REPL kludge. One other oddness is starting a ghci session with babel creates a different sort of REPL than just starting one with haskell-mode . . . and the two REPLs seem to clash and not like each other around. Declaring :session *haskell* doesn't seem to matter. . . .

I was in touch with Rob Moss who claims to have it all working with GHC 4.4 from Debian and spacemacs, but when I tried all that I wasn't able to reproduce his results, rather, the same old problems.

Soooo, any ideas? It seems like ob-haskell -- which is now built in, not separate? -- needs some attention. Or somebody who has the proverbial silver bullet comes forth to save the day.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]