emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ob-haskell: Line Continuations Mangle Block Output


From: Nick Daly
Subject: Re: [PATCH] ob-haskell: Line Continuations Mangle Block Output
Date: Sat, 23 May 2020 21:46:55 -0500

Apologies, one last patch.

On Sat, May 23, 2020 at 7:02 PM Nick Daly <address@hidden> wrote:
> : "^\\*?[[:upper:]][\\._[:alnum:]]*\\(?:
> \\*?[[:upper:]][\\._[:alnum:]]*\\)*\\( λ\\)?> "
>
> =comint-prompt-regexp='s variable documentation calls out much simpler
> regexps
>
> : "^[^>]+\\(> \\)?"

This simplified patch breaks one case that I'd forgotten about: the
true one-liner, where the output displays before the "Prelude> "
prompt even appears.

#+BEGIN_SRC haskell
scanl (+) 0 [1,2,3,4]
#+END_SRC

#+BEGIN_EXAMPLE
Prelude> scanl (+) 0 [1,2,3,4]
"org-babel-haskell-eoe"
[0,1,3,6,10]
Prelude> "org-babel-haskell-eoe"
Prelude>
#+END_EXAMPLE

This latest patch updates the original (more complicated) regexp that
works with this out-of-order output.  This should display the expected
result in all known cases:

One liners:

#+BEGIN_SRC haskell
scanl (+) 0 [1,2,3,4]
#+END_SRC

#+RESULTS:
| 0 | 1 | 3 | 6 | 10 |

Silent multi-line blocks:

#+BEGIN_SRC haskell :results silent
:{
flip' :: (a -> b -> c) -> (b -> a -> c)
flip' f = \x y -> f y x
:}
#+END_SRC

Multi-line blocks with value results:

#+BEGIN_SRC haskell
:{
sum' :: (Num a) => [a] -> a
sum' xs = foldl (\ acc x -> acc + x) 0 xs
:}
sum' [1,2,3,4] == 10
#+END_SRC

#+RESULTS:
: True

Multi-line blocks with output results:

#+BEGIN_SRC haskell :results output
:{
sum' :: (Num a) => [a] -> a
sum' xs = foldl (\ acc x -> acc + x) 0 xs
:}
print "hi"
#+END_SRC

#+RESULTS:
:
: hi

Thanks again for your time,
Nick

Attachment: ob-haskell-trim-prelude-4.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]