* Haskell code blocks @ 2022-01-03 1:16 Thomas S. Dye 2022-10-19 2:52 ` Ihor Radchenko 2022-10-22 5:06 ` Jarmo Hurri 0 siblings, 2 replies; 15+ messages in thread From: Thomas S. Dye @ 2022-01-03 1:16 UTC (permalink / raw) To: emacs-orgmode Aloha all, Happy New Year! I'm struggling to write a minimal ob-doc-haskell.org for Worg. I installed Haskell via Spacemacs (development branch) and the Haskell installation appears to be functioning correctly. The obligatory Hello World! example yields bad results. #+name: haskell-hello-world #+begin_src haskell main :: IO () main = putStrLn "Hello, World!" main #+end_src #+RESULTS: haskell-hello-world : Prelude> Hello, World! I'm guessing the "Prelude>" part of the output is the prompt from the interpreter. I found this in ob-haskell.el: (setq-local comint-prompt-regexp (concat haskell-prompt-regexp "\\|^λ?> ")))) But I couldn't find a way to modify haskell-prompt-regexp without changing the source. Advice welcome. All the best, Tom -- Thomas S. Dye https://tsdye.online/tsdye ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Haskell code blocks 2022-01-03 1:16 Haskell code blocks Thomas S. Dye @ 2022-10-19 2:52 ` Ihor Radchenko 2022-10-19 3:50 ` Thomas S. Dye 2022-10-22 5:06 ` Jarmo Hurri 1 sibling, 1 reply; 15+ messages in thread From: Ihor Radchenko @ 2022-10-19 2:52 UTC (permalink / raw) To: Thomas S. Dye; +Cc: emacs-orgmode "Thomas S. Dye" <tsd@tsdye.online> writes: > I'm struggling to write a minimal ob-doc-haskell.org for Worg. > > I installed Haskell via Spacemacs (development branch) and the > Haskell installation appears to be functioning correctly. > > The obligatory Hello World! example yields bad results. > > #+name: haskell-hello-world > #+begin_src haskell > main :: IO () > main = putStrLn "Hello, World!" > main > #+end_src > > #+RESULTS: haskell-hello-world > : Prelude> Hello, World! > > I'm guessing the "Prelude>" part of the output is the prompt from > the interpreter. > > I found this in ob-haskell.el: > > (setq-local comint-prompt-regexp > (concat haskell-prompt-regexp "\\|^λ?> > ")))) > > But I couldn't find a way to modify haskell-prompt-regexp without > changing the source. > > Advice welcome. I guess you can report this as a bug in Haskell-mode? haskell-prompt-regexp is defined there. If absolutely necessary and if you want that _your_ Haskell prompt is different from Haskell-mode defaults, just setq haskell-prompt-regexp in your config. -- 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] 15+ messages in thread
* Re: Haskell code blocks 2022-10-19 2:52 ` Ihor Radchenko @ 2022-10-19 3:50 ` Thomas S. Dye 2022-10-19 4:22 ` Ihor Radchenko 0 siblings, 1 reply; 15+ messages in thread From: Thomas S. Dye @ 2022-10-19 3:50 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Thomas S. Dye, emacs-orgmode Thanks Ihor. I don't actually use Haskell. Earlier this year I attempted to complete the Org Babel language documents on Worg, but couldn't get the obligatory "hello world" code block to behave in Haskell. I'm guessing that ob-haskell.el actually works for experienced Haskell programmers and was hoping someone had a solution to the Prelude> problem. I'm not sure when I might get back to this. All the best, Tom Ihor Radchenko <yantar92@posteo.net> writes: > "Thomas S. Dye" <tsd@tsdye.online> writes: > >> I'm struggling to write a minimal ob-doc-haskell.org for Worg. >> >> I installed Haskell via Spacemacs (development branch) and the >> Haskell installation appears to be functioning correctly. >> >> The obligatory Hello World! example yields bad results. >> >> #+name: haskell-hello-world >> #+begin_src haskell >> main :: IO () >> main = putStrLn "Hello, World!" >> main >> #+end_src >> >> #+RESULTS: haskell-hello-world >> : Prelude> Hello, World! >> >> I'm guessing the "Prelude>" part of the output is the prompt >> from >> the interpreter. >> >> I found this in ob-haskell.el: >> >> (setq-local comint-prompt-regexp >> (concat haskell-prompt-regexp >> "\\|^λ?> >> ")))) >> >> But I couldn't find a way to modify haskell-prompt-regexp >> without >> changing the source. >> >> Advice welcome. > > I guess you can report this as a bug in Haskell-mode? > haskell-prompt-regexp is defined there. > > If absolutely necessary and if you want that _your_ Haskell > prompt is > different from Haskell-mode defaults, just setq > haskell-prompt-regexp in > your config. -- Thomas S. Dye https://tsdye.online/tsdye ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Haskell code blocks 2022-10-19 3:50 ` Thomas S. Dye @ 2022-10-19 4:22 ` Ihor Radchenko 2022-10-19 4:47 ` Thomas S. Dye 0 siblings, 1 reply; 15+ messages in thread From: Ihor Radchenko @ 2022-10-19 4:22 UTC (permalink / raw) To: Thomas S. Dye; +Cc: emacs-orgmode "Thomas S. Dye" <tsd@tsdye.online> writes: > Thanks Ihor. I don't actually use Haskell. Earlier this year I > attempted to complete the Org Babel language documents on Worg, > but couldn't get the obligatory "hello world" code block to behave > in Haskell. I'm guessing that ob-haskell.el actually works for > experienced Haskell programmers and was hoping someone had a > solution to the Prelude> problem. I'm not sure when I might get > back to this. To clarify, it looks like Prelude Emacs is doing something wrong here. Something that breaks haskell-mode and consequently ob-haskell. -- 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] 15+ messages in thread
* Re: Haskell code blocks 2022-10-19 4:22 ` Ihor Radchenko @ 2022-10-19 4:47 ` Thomas S. Dye 2022-10-19 10:17 ` Ihor Radchenko 0 siblings, 1 reply; 15+ messages in thread From: Thomas S. Dye @ 2022-10-19 4:47 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Thomas S. Dye, emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > "Thomas S. Dye" <tsd@tsdye.online> writes: > >> Thanks Ihor. I don't actually use Haskell. Earlier this year >> I >> attempted to complete the Org Babel language documents on Worg, >> but couldn't get the obligatory "hello world" code block to >> behave >> in Haskell. I'm guessing that ob-haskell.el actually works for >> experienced Haskell programmers and was hoping someone had a >> solution to the Prelude> problem. I'm not sure when I might >> get >> back to this. > > To clarify, it looks like Prelude Emacs is doing something wrong > here. > Something that breaks haskell-mode and consequently ob-haskell. I'm using Spacemacs. Prelude is a standard module in Haskell. I thought that might be the source. Tom -- Thomas S. Dye https://tsdye.online/tsdye ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Haskell code blocks 2022-10-19 4:47 ` Thomas S. Dye @ 2022-10-19 10:17 ` Ihor Radchenko 2022-10-19 18:03 ` Bruno Barbier [not found] ` <notmuch-sha1-431220eef964237e131dcf36f817756f3537caf1> 0 siblings, 2 replies; 15+ messages in thread From: Ihor Radchenko @ 2022-10-19 10:17 UTC (permalink / raw) To: Thomas S. Dye; +Cc: emacs-orgmode "Thomas S. Dye" <tsd@tsdye.online> writes: >> To clarify, it looks like Prelude Emacs is doing something wrong >> here. >> Something that breaks haskell-mode and consequently ob-haskell. > > I'm using Spacemacs. Prelude is a standard module in Haskell. I > thought that might be the source. Thanks for the extra info! What happens if you run Haskell repl and check the values of haskell-prompt-regexp and comint-prompt-regexp in the Haskell repl buffer? -- 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] 15+ messages in thread
* Re: Haskell code blocks 2022-10-19 10:17 ` Ihor Radchenko @ 2022-10-19 18:03 ` Bruno Barbier [not found] ` <notmuch-sha1-431220eef964237e131dcf36f817756f3537caf1> 1 sibling, 0 replies; 15+ messages in thread From: Bruno Barbier @ 2022-10-19 18:03 UTC (permalink / raw) To: Ihor Radchenko, Thomas S. Dye; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 2686 bytes --] Hi Thomas, Ihor, I'm not currently using ob-haskell, but I do have a version of GHC. As I may use ob-haskell one day, I decided to take a look. Here are the versions I'm using: #+begin_src elisp (list (list "emacs" emacs-version) (list "org" org-version) (list "ghc" (string-trim (shell-command-to-string "ghc -V"))) ) #+end_src #+RESULTS: | emacs | 29.0.50 | | org | 9.6-pre | | ghc | The Glorious Glasgow Haskell Compilation System, version 8.10.7 | The following code block is incorrect: #+begin_src haskell :results output main :: IO () main = putStrLn "Hello, World!" main #+end_src #+RESULTS: : <interactive>:2:1-4: error: : • Variable not in scope: main :: IO () : • Perhaps you meant ‘min’ (imported from Prelude) : Prelude> Hello, World! The first line tries to evaluate 'main' which doesn't exist (yet). The following modified block works, using the compiler. #+begin_src haskell :compile yes :results output main :: IO () main = putStrLn "Hello, World!" #+end_src #+RESULTS: : Hello, World! The following works using the interpreter: #+begin_src haskell let { main :: IO () , main = putStrLn "Hello, World!" } main #+end_src #+RESULTS: : Hello, World! A simpler version, that just print "Hello, World!" works: #+begin_src haskell putStrLn "Hello, World!" #+end_src #+RESULTS: : Hello, World! Just evaluating the string doesn't work! #+begin_src haskell "Hello world!" #+end_src #+RESULTS: as we don't get any result ... If I understand correctly, it seems to be a bug in ob-haskell; `org-babel-comint-with-output' shouldn't be instructed to remove the output if it matches the input, else, it will remove any constant. Adding a type annotation is enough to make it works: #+begin_src haskell "Hello world!" :: String #+end_src #+RESULTS: : Hello world! Or fixing `org-babel-interpret-haskell' (see attached patch): #+begin_src haskell "Hello world!" #+end_src #+RESULTS: : Hello world! Another example that works too, with or without the patch: #+begin_src haskell concat ["Hello", ", ", "World", "!"] #+end_src #+RESULTS: : Hello, World! I've attached the patch that I've used to fix ob-haskell. Should I submit a patch for ob-haskell ? Bruno [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Fix org-babel-interpret-haskell --] [-- Type: text/x-diff, Size: 1030 bytes --] From f2e91a62469e84ce1d3036216ae3eca4084f3b94 Mon Sep 17 00:00:00 2001 From: Bruno BARBIER <brubar.cs@gmail.com> Date: Wed, 19 Oct 2022 19:44:42 +0200 Subject: [PATCH] org-babel-interpret-haskell: Don't remove outputs that match inputs * lisp/ob-haskell.el (org-babel-interpret-haskell): Change the call to `org-babel-comint-with-output'. --- lisp/ob-haskell.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el index d195dcf87..99e590bfb 100644 --- a/lisp/ob-haskell.el +++ b/lisp/ob-haskell.el @@ -136,7 +136,7 @@ (defun org-babel-interpret-haskell (body params) (comint-preoutput-filter-functions (cons 'ansi-color-filter-apply comint-preoutput-filter-functions)) (raw (org-babel-comint-with-output - (session org-babel-haskell-eoe t full-body) + (session org-babel-haskell-eoe nil full-body) (insert (org-trim full-body)) (comint-send-input nil t) (insert org-babel-haskell-eoe) -- 2.37.3 ^ permalink raw reply related [flat|nested] 15+ messages in thread
[parent not found: <notmuch-sha1-431220eef964237e131dcf36f817756f3537caf1>]
* Re: Haskell code blocks [not found] ` <notmuch-sha1-431220eef964237e131dcf36f817756f3537caf1> @ 2022-10-21 3:10 ` Ihor Radchenko 2022-11-07 7:24 ` Ihor Radchenko 1 sibling, 0 replies; 15+ messages in thread From: Ihor Radchenko @ 2022-10-21 3:10 UTC (permalink / raw) To: Bruno Barbier; +Cc: Thomas S. Dye, emacs-orgmode Bruno Barbier <brubar.cs@gmail.com> writes: > I've attached the patch that I've used to fix ob-haskell. > > Should I submit a patch for ob-haskell ? > > Bruno > > > From f2e91a62469e84ce1d3036216ae3eca4084f3b94 Mon Sep 17 00:00:00 2001 > From: Bruno BARBIER <brubar.cs@gmail.com> > Date: Wed, 19 Oct 2022 19:44:42 +0200 > Subject: [PATCH] org-babel-interpret-haskell: Don't remove outputs that match > inputs Thanks! Could you also create testing/lisp/test-ob-haskell.el file and add your examples as tests in there? -- 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] 15+ messages in thread
* Re: Haskell code blocks [not found] ` <notmuch-sha1-431220eef964237e131dcf36f817756f3537caf1> 2022-10-21 3:10 ` Ihor Radchenko @ 2022-11-07 7:24 ` Ihor Radchenko 2022-11-08 18:46 ` Bruno Barbier 1 sibling, 1 reply; 15+ messages in thread From: Ihor Radchenko @ 2022-11-07 7:24 UTC (permalink / raw) To: Bruno Barbier; +Cc: Thomas S. Dye, emacs-orgmode Bruno Barbier <brubar.cs@gmail.com> writes: > I've attached the patch that I've used to fix ob-haskell. Applied onto main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0de063a52181bd96ac9bf023454781f07c3353b3 -- 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] 15+ messages in thread
* Re: Haskell code blocks 2022-11-07 7:24 ` Ihor Radchenko @ 2022-11-08 18:46 ` Bruno Barbier 2022-11-09 2:54 ` Ihor Radchenko 2023-03-13 11:38 ` Ihor Radchenko 0 siblings, 2 replies; 15+ messages in thread From: Bruno Barbier @ 2022-11-08 18:46 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Thomas S. Dye, emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > Applied onto main. > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0de063a52181bd96ac9bf023454781f07c3353b3 Thanks Ihor. Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have some spare time, but I'm unable so far to find tests that I can't reliably break. I'll open a new thread when I think my 'test-ob-haskell.el' is worth reviewing. Bruno. > -- > 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] 15+ messages in thread
* Re: Haskell code blocks 2022-11-08 18:46 ` Bruno Barbier @ 2022-11-09 2:54 ` Ihor Radchenko 2023-03-13 11:38 ` Ihor Radchenko 1 sibling, 0 replies; 15+ messages in thread From: Ihor Radchenko @ 2022-11-09 2:54 UTC (permalink / raw) To: Bruno Barbier; +Cc: Thomas S. Dye, emacs-orgmode Bruno Barbier <brubar.cs@gmail.com> writes: > Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have > some spare time, but I'm unable so far to find tests that I can't > reliably break. > > I'll open a new thread when I think my 'test-ob-haskell.el' is worth > reviewing. Thanks for continued work on this! -- 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] 15+ messages in thread
* Re: Haskell code blocks 2022-11-08 18:46 ` Bruno Barbier 2022-11-09 2:54 ` Ihor Radchenko @ 2023-03-13 11:38 ` Ihor Radchenko 2023-03-15 18:12 ` Bruno Barbier [not found] ` <notmuch-sha1-86fc4270780c1f4b2624b20be5d3684ddf44d9c0> 1 sibling, 2 replies; 15+ messages in thread From: Ihor Radchenko @ 2023-03-13 11:38 UTC (permalink / raw) To: Bruno Barbier; +Cc: Thomas S. Dye, emacs-orgmode Bruno Barbier <brubar.cs@gmail.com> writes: > Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have > some spare time, but I'm unable so far to find tests that I can't > reliably break. May I know if you are still working on this? Do you need any help? -- 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] 15+ messages in thread
* Re: Haskell code blocks 2023-03-13 11:38 ` Ihor Radchenko @ 2023-03-15 18:12 ` Bruno Barbier [not found] ` <notmuch-sha1-86fc4270780c1f4b2624b20be5d3684ddf44d9c0> 1 sibling, 0 replies; 15+ messages in thread From: Bruno Barbier @ 2023-03-15 18:12 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Thomas S. Dye, emacs-orgmode Hi Ihor, Ihor Radchenko <yantar92@posteo.net> writes: > Bruno Barbier <brubar.cs@gmail.com> writes: > >> Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have >> some spare time, but I'm unable so far to find tests that I can't >> reliably break. > > May I know if you are still working on this? > Do you need any help? My tests were too easy to break. I tried to learn more about haskell-mode, but I got lost. Then, it got down in my todo list. I'll check what I have this week-end and come back to you. But, that might just be a set of tests that randomly fail. Anyway, we'll decide from there. Thanks for your ping. Bruno > > -- > 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] 15+ messages in thread
[parent not found: <notmuch-sha1-86fc4270780c1f4b2624b20be5d3684ddf44d9c0>]
* Re: Haskell code blocks [not found] ` <notmuch-sha1-86fc4270780c1f4b2624b20be5d3684ddf44d9c0> @ 2023-03-19 9:20 ` Bruno Barbier 0 siblings, 0 replies; 15+ messages in thread From: Bruno Barbier @ 2023-03-19 9:20 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Thomas S. Dye, emacs-orgmode Hi Ihor, >> Bruno Barbier <brubar.cs@gmail.com> writes: >> >>> Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have >>> some spare time, but I'm unable so far to find tests that I can't >>> reliably break. FTR: I've opened a new thread, with a patch containing tests: https://lists.gnu.org/archive/html/emacs-orgmode/2023-03/msg00274.html Bruno. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Haskell code blocks 2022-01-03 1:16 Haskell code blocks Thomas S. Dye 2022-10-19 2:52 ` Ihor Radchenko @ 2022-10-22 5:06 ` Jarmo Hurri 1 sibling, 0 replies; 15+ messages in thread From: Jarmo Hurri @ 2022-10-22 5:06 UTC (permalink / raw) To: emacs-orgmode Greetings Thomas. "Thomas S. Dye" <tsd@tsdye.online> writes: > I'm struggling to write a minimal ob-doc-haskell.org for Worg. > > The obligatory Hello World! example yields bad results. > > #+name: haskell-hello-world > #+begin_src haskell > > main :: IO () > main = putStrLn "Hello, World!" > main > #+end_src > > #+RESULTS: haskell-hello-world > : Prelude> Hello, World! The good ole obligatory part is fulfilled by including ":session none": #+name: haskell-hello-world #+begin_src haskell :session none main :: IO () main = putStrLn "Hello, World!" main #+end_src #+RESULTS: haskell-hello-world : Hello, World! All the best, Jarmo ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2023-03-19 9:21 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-01-03 1:16 Haskell code blocks Thomas S. Dye 2022-10-19 2:52 ` Ihor Radchenko 2022-10-19 3:50 ` Thomas S. Dye 2022-10-19 4:22 ` Ihor Radchenko 2022-10-19 4:47 ` Thomas S. Dye 2022-10-19 10:17 ` Ihor Radchenko 2022-10-19 18:03 ` Bruno Barbier [not found] ` <notmuch-sha1-431220eef964237e131dcf36f817756f3537caf1> 2022-10-21 3:10 ` Ihor Radchenko 2022-11-07 7:24 ` Ihor Radchenko 2022-11-08 18:46 ` Bruno Barbier 2022-11-09 2:54 ` Ihor Radchenko 2023-03-13 11:38 ` Ihor Radchenko 2023-03-15 18:12 ` Bruno Barbier [not found] ` <notmuch-sha1-86fc4270780c1f4b2624b20be5d3684ddf44d9c0> 2023-03-19 9:20 ` Bruno Barbier 2022-10-22 5:06 ` Jarmo Hurri
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.