emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Haskell org-mode problems redux
@ 2019-05-30 17:55 Lawrence Bottorff
  2019-05-30 21:25 ` Bruno Barbier
  0 siblings, 1 reply; 3+ messages in thread
From: Lawrence Bottorff @ 2019-05-30 17:55 UTC (permalink / raw)
  To: emacs-orgmode Mailinglist

[-- Attachment #1: Type: text/plain, Size: 2181 bytes --]

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
:}
#+end_src

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
#+end_src

and

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

#+RESULTS:
Prelude> [0,14,28,42,56,70,84,98]
[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.

LB

[-- Attachment #2: Type: text/html, Size: 2548 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-31  3:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 17:55 Haskell org-mode problems redux Lawrence Bottorff
2019-05-30 21:25 ` Bruno Barbier
2019-05-31  3:40   ` Lawrence Bottorff

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).