* Org Haskell code blocks
@ 2022-10-25 14:47 Dominik Schrempf
2022-10-25 15:08 ` Dominik Schrempf
0 siblings, 1 reply; 9+ messages in thread
From: Dominik Schrempf @ 2022-10-25 14:47 UTC (permalink / raw)
To: Emacs Org Mode Mailing List
Hello,
I have trouble using Haskell code blocks in Org Mode.
1. I need to use the following Org Mode file header:
#+property: :header-args:haskell: :prologue ":{\n" :epilogue ":}\n"
#+begin_src haskell :exports none :results none
:set prompt-cont ""
#+end_src
Otherwise, the results of Haskell code blocks are scrambled.
2. I need to set `haskell-process-type' to `ghci'. The default
interpreter `cabal-repl' does not find any external modules (even core
modules included with GHC).
However, I get the error message "org-babel-script-escape:
‘org-babel-script-escape’ expects a string", when executing the first
code block which starts the interpreter. Seemingly, the error has no
effect because everything works fine.
3. I have to set `org-edit-src-content-indentation` to 0, and always put
the source code to text column 0, otherwise syntax highlighting does not
work.
Do others have the same problems? If so, have there been discussions
about how to improve this situation?
Thank you for your help!
Dominik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org Haskell code blocks
2022-10-25 14:47 Org Haskell code blocks Dominik Schrempf
@ 2022-10-25 15:08 ` Dominik Schrempf
2022-10-25 18:06 ` Bruno Barbier
0 siblings, 1 reply; 9+ messages in thread
From: Dominik Schrempf @ 2022-10-25 15:08 UTC (permalink / raw)
To: Emacs Org Mode Mailing List
I apologize, the settings described in Point 1 actually have no effect.
Multi line input works out of the box (at least with "ghci" as
described). However, the result output is still scrambled (e.g., empty
lines, unnecessary "ghci>" prompts in results)
Dominik
Dominik Schrempf <dominik.schrempf@gmail.com> writes:
> Hello,
>
> I have trouble using Haskell code blocks in Org Mode.
>
> 1. I need to use the following Org Mode file header:
>
> #+property: :header-args:haskell: :prologue ":{\n" :epilogue ":}\n"
>
> #+begin_src haskell :exports none :results none
> :set prompt-cont ""
> #+end_src
>
> Otherwise, the results of Haskell code blocks are scrambled.
>
> 2. I need to set `haskell-process-type' to `ghci'. The default
> interpreter `cabal-repl' does not find any external modules (even core
> modules included with GHC).
>
> However, I get the error message "org-babel-script-escape:
> ‘org-babel-script-escape’ expects a string", when executing the first
> code block which starts the interpreter. Seemingly, the error has no
> effect because everything works fine.
>
> 3. I have to set `org-edit-src-content-indentation` to 0, and always put
> the source code to text column 0, otherwise syntax highlighting does not
> work.
>
> Do others have the same problems? If so, have there been discussions
> about how to improve this situation?
>
> Thank you for your help!
>
> Dominik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org Haskell code blocks
2022-10-25 15:08 ` Dominik Schrempf
@ 2022-10-25 18:06 ` Bruno Barbier
2022-10-25 18:51 ` Dominik Schrempf
0 siblings, 1 reply; 9+ messages in thread
From: Bruno Barbier @ 2022-10-25 18:06 UTC (permalink / raw)
To: Dominik Schrempf, Emacs Org Mode Mailing List
Hi,
Dominik Schrempf <dominik.schrempf@gmail.com> writes:
> ...
> However, the result output is still scrambled (e.g., empty
> lines, unnecessary "ghci>" prompts in results)
>
For me, ghci is selected by default.
Here is the config I've used to test it:
| emacs-version | 28.1 |
| org-version | 9.5.2 |
| haskell-process-type | auto |
| org-babel-script-escape | <not available> |
Here is my simple test:
#+begin_src haskell
1+2
#+end_src
#+RESULTS:
: 3
The variable 'org-babel-script-escape' doesn't exist in the version that
I'm using. And, the prompt is not "ghci>" but the current module name.
Which version of org are you using ? Could you try with a recent version
and provide a minimal complete example using a minimal configuration ?
(see the org mode manual (info "(org)Feedback")).
Thanks,
Bruno
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org Haskell code blocks
2022-10-25 18:06 ` Bruno Barbier
@ 2022-10-25 18:51 ` Dominik Schrempf
2022-10-26 4:19 ` Ihor Radchenko
0 siblings, 1 reply; 9+ messages in thread
From: Dominik Schrempf @ 2022-10-25 18:51 UTC (permalink / raw)
To: Bruno Barbier; +Cc: emacs-orgmode
Hi Bruno,
glad to hear that it works for you.
Ad 'org-babel-script-escape': I use Org version 9.6. I do not temper
with 'org-babel-script-escape', it is used by the respective babel
modules --- 'ob-haskell' in this case. The error also occurs with
'cabal-repl' as process type.
Ad 'haskell-process-type': When I use 'haskell-process-type' 'auto', it
chooses 'cabal-repl' which will also fire up 'ghci' but the setup is
faulty, because it does not find any modules, as I described. I just
checked and this is not a fault of org-mode. The command 'cabal repl'
also fails to access any modules when executed in the terminal. I think
it requires a `.cabal` file, which I usually do not have when using an
Org file. I quote the help text from 'cabal repl':
Open an interactive session for a component within the project.
I think this is not the correct default for Org mode, because usually
there is no "project", but just an Org file.
If I use 'haskell-process-type' 'ghci', all modules I have installed
along with GHC are found, as I expect them to be.
Ad scrambling: The scrambling happens with multi-line input. For example
#+begin_src haskell :exports both :results output
let x = 10
let y = 12
x*y
[x,y]
#+end_src
#+results:
:
: ghci> 120
: [10,12]
Do you get syntax highlighting when the source code is indented (for
example in list items).
Thanks for your reply!
Dominik
Bruno Barbier <brubar.cs@gmail.com> writes:
> Hi,
>
> Dominik Schrempf <dominik.schrempf@gmail.com> writes:
>
>> ...
>> However, the result output is still scrambled (e.g., empty
>> lines, unnecessary "ghci>" prompts in results)
>>
>
> For me, ghci is selected by default.
>
> Here is the config I've used to test it:
>
> | emacs-version | 28.1 |
> | org-version | 9.5.2 |
> | haskell-process-type | auto |
> | org-babel-script-escape | <not available> |
>
>
> Here is my simple test:
>
> #+begin_src haskell
> 1+2
> #+end_src
>
> #+RESULTS:
> : 3
>
> The variable 'org-babel-script-escape' doesn't exist in the version that
> I'm using. And, the prompt is not "ghci>" but the current module name.
>
> Which version of org are you using ? Could you try with a recent version
> and provide a minimal complete example using a minimal configuration ?
> (see the org mode manual (info "(org)Feedback")).
>
> Thanks,
>
>
> Bruno
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org Haskell code blocks
2022-10-25 18:51 ` Dominik Schrempf
@ 2022-10-26 4:19 ` Ihor Radchenko
2022-10-26 6:24 ` Dominik Schrempf
0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2022-10-26 4:19 UTC (permalink / raw)
To: Dominik Schrempf; +Cc: Bruno Barbier, emacs-orgmode
Dominik Schrempf <dominik.schrempf@gmail.com> writes:
> Ad scrambling: The scrambling happens with multi-line input. For example
>
> #+begin_src haskell :exports both :results output
> let x = 10
> let y = 12
> x*y
> [x,y]
> #+end_src
>
> #+results:
> :
> : ghci> 120
> : [10,12]
I am unable to reproduce on the latest main.
Likely because of recent fixes in ob-comint.
> Do you get syntax highlighting when the source code is indented (for
> example in list items).
I have the above code fontified.
Could you please provide an example of the code that is not being fontified?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org Haskell code blocks
2022-10-26 4:19 ` Ihor Radchenko
@ 2022-10-26 6:24 ` Dominik Schrempf
2022-10-26 6:57 ` Ihor Radchenko
0 siblings, 1 reply; 9+ messages in thread
From: Dominik Schrempf @ 2022-10-26 6:24 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Bruno Barbier, emacs-orgmode
Dear Ihor,
thank you, these are great news!
Syntax highlighting is not working, for example, with the following
snippet and code block:
begin_snippet
- An example of a function:
#+begin_src haskell :exports code :results none
f :: a -> b
#+end_src
end_snippet
Note the indentation. The code block is indented by 2 spaces, because it
belongs to the list item above. The indentation makes the syntax
highlighting fail. It may well be that this is non-standard usage of
code blocks, but it is very convenient to preserve indentation in this
way.
I also fixed the detection of 'haskell-process-type'. It turns out, I
had some local configuration preferring 'cabal-repl', even without the
required project files. 'haskell-process-type' 'auto' works correctly, I
apologize.
Thank you for your help!
Dominik
Ihor Radchenko <yantar92@posteo.net> writes:
> Dominik Schrempf <dominik.schrempf@gmail.com> writes:
>
>> Ad scrambling: The scrambling happens with multi-line input. For example
>>
>> #+begin_src haskell :exports both :results output
>> let x = 10
>> let y = 12
>> x*y
>> [x,y]
>> #+end_src
>>
>> #+results:
>> :
>> : ghci> 120
>> : [10,12]
>
> I am unable to reproduce on the latest main.
> Likely because of recent fixes in ob-comint.
>
>> Do you get syntax highlighting when the source code is indented (for
>> example in list items).
>
> I have the above code fontified.
> Could you please provide an example of the code that is not being fontified?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Org Haskell code blocks
2022-10-26 6:24 ` Dominik Schrempf
@ 2022-10-26 6:57 ` Ihor Radchenko
2022-10-26 9:11 ` Dominik Schrempf
0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2022-10-26 6:57 UTC (permalink / raw)
To: Dominik Schrempf; +Cc: Bruno Barbier, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 385 bytes --]
Dominik Schrempf <dominik.schrempf@gmail.com> writes:
> Syntax highlighting is not working, for example, with the following
> snippet and code block:
>
> begin_snippet
>
> - An example of a function:
>
> #+begin_src haskell :exports code :results none
> f :: a -> b
> #+end_src
>
> end_snippet
Works on my side (I think).
See the attached screenshot.
I am on the latest main.
[-- Attachment #2: haskell-fontification.png --]
[-- Type: image/png, Size: 22268 bytes --]
[-- Attachment #3: Type: text/plain, Size: 225 bytes --]
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-10-27 3:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-25 14:47 Org Haskell code blocks Dominik Schrempf
2022-10-25 15:08 ` Dominik Schrempf
2022-10-25 18:06 ` Bruno Barbier
2022-10-25 18:51 ` Dominik Schrempf
2022-10-26 4:19 ` Ihor Radchenko
2022-10-26 6:24 ` Dominik Schrempf
2022-10-26 6:57 ` Ihor Radchenko
2022-10-26 9:11 ` Dominik Schrempf
2022-10-27 3:32 ` Ihor Radchenko
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).