emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ob-haskell: Line Continuations Mangle Block Output
@ 2020-05-17 19:30 Nick Daly
  2020-05-17 20:07 ` Nick Daly
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Daly @ 2020-05-17 19:30 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 748 bytes --]

Hi Org Maintainers,

Please see the attached patch to remove "Prelude> " and "Prelude| " line
continuations from the block result output when parsing blocks that contain
multi-line function declarations.

This likely requires yesterday's patch to return value-type results from
Haskell blocks.  This patch applies cleanly against the org-mode master.

#+name: chain-ecm
#+BEGIN_SRC haskell
  :{
  chain :: (Integral a) => a -> [a]
  chain 1 = [1]
  chain n
      | even n = n:chain (n `div` 2)
      | odd n  = n:chain (n*3 + 1)
  :}
  chain 10
#+END_SRC

Results without patch:
: Prelude| Prelude| Prelude| Prelude| Prelude| Prelude| Prelude>
[10,5,16,8,4,2,1]

Results with patch:
: | 10 | 5 | 16 | 8 | 4 | 2 | 1 |

Thank you for your time,
Nick

[-- Attachment #2: ob-haskell-trim-prelude.diff --]
[-- Type: text/x-patch, Size: 783 bytes --]

--- lisp/ob-haskell.el
+++ lisp/ob-haskell.el
@@ -84,9 +84,11 @@
                                        (reverse (mapcar #'org-trim raw)))))))
     (org-babel-reassemble-table
      (let ((result
-            (pcase result-type
-              (`output (mapconcat #'identity (reverse results) "\n"))
-              (`value (car results)))))
+	    (replace-regexp-in-string
+	     "Prelude[|>] " ""
+             (pcase result-type
+               (`output (mapconcat #'identity (reverse results) "\n"))
+               (`value (car results))))))
        (org-babel-result-cond (cdr (assq :result-params params))
 	 result (if (stringp result) (org-babel-script-escape result))))
      (org-babel-pick-name (cdr (assq :colname-names params))

Diff finished.  Sun May 17 14:26:21 2020

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-05-31 17:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-17 19:30 [PATCH] ob-haskell: Line Continuations Mangle Block Output Nick Daly
2020-05-17 20:07 ` Nick Daly
2020-05-20  5:51   ` Kyle Meyer
2020-05-24  0:02     ` Nick Daly
2020-05-24  2:46       ` Nick Daly
2020-05-26  0:05         ` Kyle Meyer
2020-05-31 17:00           ` Nick Daly
2020-05-26  0:02       ` Kyle Meyer

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).