emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Unnecessary Warnings Evaluating Haskell Blocks [patch]
@ 2020-05-16 17:49 Nick Daly
  0 siblings, 0 replies; only message in thread
From: Nick Daly @ 2020-05-16 17:49 UTC (permalink / raw)
  To: Org Mode

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,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-16 17:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 17:49 Unnecessary Warnings Evaluating Haskell Blocks [patch] Nick Daly

Code repositories for project(s) associated with this 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).