From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Re: Haskell org-mode problems redux Date: Thu, 30 May 2019 22:40:52 -0500 Message-ID: References: <5cf03c32.1c69fb81.2b66a.5651@mx.google.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b340ea058a26c88a" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:33804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWYPj-0002ot-Pm for emacs-orgmode@gnu.org; Thu, 30 May 2019 23:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWYPi-0001mq-Iv for emacs-orgmode@gnu.org; Thu, 30 May 2019 23:41:07 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]:34776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWYPi-0001h8-9t for emacs-orgmode@gnu.org; Thu, 30 May 2019 23:41:06 -0400 Received: by mail-lf1-x129.google.com with SMTP id v18so6731629lfi.1 for ; Thu, 30 May 2019 20:41:06 -0700 (PDT) In-Reply-To: <5cf03c32.1c69fb81.2b66a.5651@mx.google.com> 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: Bruno Barbier Cc: emacs-orgmode Mailinglist --000000000000b340ea058a26c88a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Gosh, it worked. So I wasn't crazy or remiss, rather, I just didn't know how deep the rabbit hole was. Thanks! One odd thing still. I tried to run #+begin_src haskell :set prompt-cont "" #+end_src and like other times before trying to run Haskell blocks it complained saying executing Haskell code block... org-babel-script-escape: =E2=80=98org-babel-script-escape=E2=80=99 expects = a string so I add :results output to the #+begin line and it works. Would anyone know what that is about? On Thu, May 30, 2019 at 3:25 PM Bruno Barbier wrote: > > Hi Lawrence, > > > Lawrence Bottorff writes: > > > 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 wit= h > an > > org babel code block. > > > ... > > Soooo, any ideas? > > I'm using the header arguments: > > > :prologue ":{\n" :epilogue ":}\n" > > > > to request org to insert those multiline tags :{ :} > (so, I'm not using ":set +m"). > > I'm defining these header args as headline properties (so that I don't > have to enter them again and again). Something like that: > > #+begin_example > ,** A title > :PROPERTIES: > :header-args:haskell: :prologue ":{\n" :epilogue ":}\n" > :END: > #+end_example > > I'm telling ghci to not insert a prompt, when waiting for the end of a > multiline. > > #+begin_src haskell > :set prompt-cont "" > #+end_src > > > Configured like this, it seems to be working quite well for me (great > job org and GHC teams!). > > > #+begin_src haskell > doubleSmallNumber x =3D > if x > 10 > then x > else x * 2 > #+end_src > > No error. > > #+begin_src haskell > let > showMe :: Int -> [String] > showMe x =3D [show x, show $ doubleSmallNumber x] > in > [ ["x", "doubleSmallNumber x"] > , showMe 3 > , showMe 13 > ] > #+end_src > > #+RESULTS: > | x | doubleSmallNumber x | > | 3 | 6 | > | 13 | 13 | > > > > My config: > > | ghci | 8.6.3 | > | emacs | 26.1 | > | org | 9.2.3 | > | OS | linux | > > > If it doesn't work for you on GNU/Linux, post the example and I will try > it on my computer (sorry, I won't be able to help you with Microsoft > Windows though). > > > > Bruno > > > > LB > --000000000000b340ea058a26c88a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Gosh, it worked. So I wasn't crazy or remiss, rather, = I just didn't know how deep the rabbit hole was. Thanks! One odd thing = still. I tried to run

#+begin_src haskell
:set prompt= -cont ""
#+end_src

and like other= times before trying to run Haskell blocks it complained saying
<= br>
executing Haskell code block...
org-babel-script-escape: = =E2=80=98org-babel-script-escape=E2=80=99 expects a string
so I add :results output to the #+begin line and it works. Wou= ld anyone know what that is about?


On Thu, May 30, 2019= at 3:25 PM Bruno Barbier <brubar= .cs@gmail.com> wrote:

Hi Lawrence,


Lawrence Bottorff <borgauf@gmail.com> writes:

> 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 wel= l with an
> org babel code block.
>
...
> Soooo, any ideas?

I'm using the header arguments:


=C2=A0 =C2=A0 :prologue ":{\n" :epilogue ":}\n"



to request org to insert those multiline tags :{ :}
(so, I'm not using ":set +m").

I'm defining these header args as headline properties (so that I don= 9;t
have to enter them again and again).=C2=A0 Something like that:

=C2=A0 #+begin_example
=C2=A0 =C2=A0 ,** A title
=C2=A0 =C2=A0 =C2=A0 =C2=A0:PROPERTIES:
=C2=A0 =C2=A0 =C2=A0 =C2=A0:header-args:haskell: :prologue ":{\n"= :epilogue ":}\n"
=C2=A0 =C2=A0 =C2=A0 =C2=A0:END:
=C2=A0 #+end_example

I'm telling ghci to not insert a prompt, when waiting for the end of a<= br> multiline.

#+begin_src haskell
:set prompt-cont ""
#+end_src


Configured like this, it seems to be working quite well for me (great
job org and GHC teams!).


#+begin_src haskell
=C2=A0 doubleSmallNumber x =3D
=C2=A0 =C2=A0 =C2=A0 if x > 10
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 then x
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else x * 2
#+end_src

No error.

#+begin_src haskell
let
=C2=A0 =C2=A0 showMe :: Int -> [String]
=C2=A0 =C2=A0 showMe x =3D [show x, show $ doubleSmallNumber x]
in
=C2=A0 [ ["x", "doubleSmallNumber x"]
=C2=A0 , showMe 3
=C2=A0 , showMe 13
=C2=A0 ]
#+end_src

#+RESULTS:
=C2=A0 =C2=A0 |=C2=A0 x | doubleSmallNumber x |
=C2=A0 =C2=A0 |=C2=A0 3 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A06 |
=C2=A0 =C2=A0 | 13 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 13 |



My config:

=C2=A0 =C2=A0 | ghci=C2=A0 | 8.6.3 |
=C2=A0 =C2=A0 | emacs |=C2=A0 26.1 |
=C2=A0 =C2=A0 | org=C2=A0 =C2=A0| 9.2.3 |
=C2=A0 =C2=A0 | OS=C2=A0 =C2=A0 | linux |


If it doesn't work for you on GNU/Linux, post the example and I will tr= y
it on my computer (sorry, I won't be able to help you with Microsoft Windows though).



Bruno


> LB
--000000000000b340ea058a26c88a--