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
message:

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

Below is a minimal example that produces the unexpected behavior.

* ECM

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=
executable.

** Org File

#+name: ecm-error-message
#+BEGIN_SRC org
  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
    :}
  ,#+end_src

  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
  ,#+end_src

  With and without the patch:

  ,#+RESULTS: addThree-apply
  : 13
#+END_SRC

** .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)))
#+END_SRC

* 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
#93c50e3a7867a1a85fc78b337172585f7a10dcc6).

#+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))
#+END_SRC

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

https://emacs.stackexchange.com/questions/35709/cannot-execute-org-babel-haskell-block

Thank you for your time,
Nick


                 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:
  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-YhhD+Ti1ZK+34kqXwZ5GFYwj++3bEzknw+GX92ZOMoeBwjw@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).