From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Haskell org-mode problems redux Date: Thu, 30 May 2019 12:55:42 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f45d13058a1e9bfa" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:46867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWPHU-0005iw-8h for emacs-orgmode@gnu.org; Thu, 30 May 2019 13:56:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWPHT-000802-42 for emacs-orgmode@gnu.org; Thu, 30 May 2019 13:56:00 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:46509) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWPHR-0007xq-7y for emacs-orgmode@gnu.org; Thu, 30 May 2019 13:55:58 -0400 Received: by mail-lj1-x22d.google.com with SMTP id m15so6900781ljg.13 for ; Thu, 30 May 2019 10:55:55 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode Mailinglist --000000000000f45d13058a1e9bfa Content-Type: text/plain; charset="UTF-8" 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 --000000000000f45d13058a1e9bfa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 evalu= ated exclusively by the ghci REPL, which doesn't understand or play wel= l with an org babel code block.

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

#+begin_src haskell :r= esults raw
:{
=C2=A0 doubleSmallNumber x =3D
=C2=A0 =C2=A0 if x &g= t; 10
=C2=A0 =C2=A0 then x
=C2=A0 =C2=A0 else x * 2
:}
#+e= nd_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 toge= ther making a function declaration. I'm on latest org, have installed H= askell stack 8.6.3 on Ubuntu (Haskell stack 8.6.5 on Windows). The maddenin= g thing is the intermittent behavior, i.e., sometimes it likes what you'= ;re doing:

=C2=A0#+begin_src haskell :results raw<= /div>tripleMe x =3D x + x + x
#+end_src

and

#+begin_src haskell :results raw
[x | x <- [0..= 100], x `mod` 2 =3D=3D 0 && x `mod` 7 =3D=3D 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 ju= st 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 w= hen I tried all that I wasn't able to reproduce his results, rather, th= e same old problems.

Soooo, any ideas? It seems li= ke ob-haskell -- which is now built in, not separate? -- needs some attenti= on. Or somebody who has the proverbial silver bullet comes forth to save th= e day.

LB
--000000000000f45d13058a1e9bfa--