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: Unnecessary Warnings Evaluating Haskell Blocks [patch]
Date: Sat, 16 May 2020 12:49:18 -0500	[thread overview]
Message-ID: <CAM-YhhD+Ti1ZK+34kqXwZ5GFYwj++3bEzknw+GX92ZOMoeBwjw@mail.gmail.com> (raw)

Hello Org Maintainers,

This issue has been reproduced on org versions 9.1.14 and Git master,
and comes with a patch.

* Issue

ob-haskell.el::org-babel-execute:haskell produces spurious error
messages when running haskell blocks without =:results output=
specified.  If =:results= is not specified or is set to =value=, or
=silent=, evaluating haskell blocks with =C-c C-c= produces an error

: org-babel-script-escape: ‘org-babel-script-escape’ expects a string".

Below is a minimal example that produces the unexpected behavior.


The ECM is in two parts, below.

2. The Org sample that produces the error.
3. The minimal =~/.emacs=.

You may need to install the =ghc= package to get the =ghci=

** Org File

#+name: ecm-error-message
  1. Evaluate the addThree-delcare block to produce the error message.
     If you receive an error about how =haskell-prompt-regexp= is
     undefined, evaluate the block again, that is a transient error.

  Create the =addThree= function that adds three to any number.  Use
  =:results silent= to suppress the RESULTS block because we don't
  care about the results of a function declaration.

  ,#+name: addThree-declare
  ,#+begin_src haskell :results silent
    addThree :: (Num a) =>  a -> a
    addThree x = x + 3

  Observed behavior (without the patch below):

  "org-babel-script-escape: ‘org-babel-script-escape’ expects a string"

  With the patch:

  (no output)

  2. Apply the =addThree= function and get the result:

  ,#+name: addThree-apply
  ,#+begin_src haskell
    addThree 10

  With and without the patch:

  ,#+RESULTS: addThree-apply
  : 13

** .emacs

This is the minimal example .emacs file to produce this error:

#+BEGIN_SRC elisp
  (require 'org)
  (require 'ob-haskell)
  (setq org-babel-load-languages '((haskell . t)))

* Patch

This unnecessary error message can be corrected with the following
patch that applies cleanly on both Debian Stable's Org version 9.1.14
and the current git master (commit

#+BEGIN_SRC diff
--- org-9.1.14/ob-haskell.el
+++ org-9.1.14/ob-haskell.el
@@ -92,7 +92,7 @@
               (`output (mapconcat #'identity (reverse (cdr results)) "\n"))
               (`value (car results)))))
        (org-babel-result-cond (cdr (assq :result-params params))
-     result (org-babel-script-escape result)))
+     result (if (stringp result) (org-babel-script-escape result))))
      (org-babel-pick-name (cdr (assq :colname-names params))
               (cdr (assq :colname-names params)))
      (org-babel-pick-name (cdr (assq :rowname-names params))

This error may also prevent execution entirely in different
configurations, but I have not been able to reliably confirm that


Thank you for your time,

                 reply	other threads:[~2020-05-16 17:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

  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-YhhD+Ti1ZK+34kqXwZ5GFYwj++3bEzknw+GX92ZOMoeBwjw@mail.gmail.com \
    --to=nick.m.daly@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* 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


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