emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Daly <nick.m.daly@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] ob-haskell: Line Continuations Mangle Block Output
Date: Sun, 17 May 2020 14:30:32 -0500	[thread overview]
Message-ID: <CAM-YhhCxDAtD3=6VzK0ojYfF5=Zti8OS7LnUbResqC0uCtTZGg@mail.gmail.com> (raw)

[-- 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

             reply	other threads:[~2020-05-17 19:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 19:30 Nick Daly [this message]
2020-05-17 20:07 ` [PATCH] ob-haskell: Line Continuations Mangle Block Output 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM-YhhCxDAtD3=6VzK0ojYfF5=Zti8OS7LnUbResqC0uCtTZGg@mail.gmail.com' \
    --to=nick.m.daly@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).