Please see attached patch.
Regards.

On Mon, May 4, 2020 at 11:50 PM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Roland Coeurjoly <rolandcoeurj...@gmail.com> writes:
>
> > I am confused about the last point:
> > Use a let-binding instead of setq.
> >
> > If I use:
> >
> > (let* compile (string= (cdr (assq :compile params)) "yes"))
>
> I meant:
>
>   (let ((compile (string= "yes" (cdr (assq :compile params)))))
>    ...)
>
From 2c05ba85bffac4019432fa461c0e4f75cd24a0f6 Mon Sep 17 00:00:00 2001
From: Roland Coeurjoly <rolandcoeurj...@gmail.com>
Date: Tue, 5 May 2020 23:09:58 +0200
Subject: [PATCH 1/1] ob-haskell: introduce :compile header argument

* lisp/ob-haskell (org-babel-haskell-compiler):
(org-babel-header-args:haskell): new variables.
(org-babel-haskell-execute):
(org-babel-haskell-interpret): new functions.
(org-babel-execute:haskell): use new functions.
---
 lisp/org/ob-haskell.el | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/lisp/org/ob-haskell.el b/lisp/org/ob-haskell.el
index d32a2f7bc0..55989adba1 100644
--- a/lisp/org/ob-haskell.el
+++ b/lisp/org/ob-haskell.el
@@ -23,7 +23,7 @@
 
 ;;; Commentary:
 
-;; Org-Babel support for evaluating Haskell source code.
+;; Org Babel support for evaluating Haskell source code.
 ;; Haskell programs must be compiled before
 ;; they can be run, but haskell code can also be run through an
 ;; interactive interpreter.
@@ -62,19 +62,19 @@ org-babel-haskell-eoe
 
 (defvar haskell-prompt-regexp)
 
-(defcustom org-babel-Haskell-compiler "ghc"
+(defcustom org-babel-haskell-compiler "ghc"
   "Command used to compile a Haskell source code file into an executable.
-May be either a command in the path, like ghc
-or an absolute path name, like /usr/local/bin/ghc
-parameter may be used, like ghc -v"
+May be either a command in the path, like \"ghc\"
+or an absolute path name, like \"/usr/local/bin/ghc\".
+The command can include a parameter, such as \"ghc -v\""
   :group 'org-babel
-  :version "27.0"
+  :package-version '(Org "9.4")
   :type 'string)
 
-(defconst org-babel-header-args:haskell '((compile . :any))
+(defconst org-babel-header-args:haskell '(compile . :any)
   "Haskell-specific header arguments.")
 
-(defun org-babel-Haskell-execute (body params)
+(defun org-babel-haskell-execute (body params)
   "This function should only be called by `org-babel-execute:haskell'"
   (let* ((tmp-src-file (org-babel-temp-file
 			"Haskell-src-"
@@ -85,8 +85,10 @@ org-babel-Haskell-execute
          (cmdline (cdr (assq :cmdline params)))
          (cmdline (if cmdline (concat " " cmdline) ""))
          (flags (cdr (assq :flags params)))
-         (flags (mapconcat 'identity
-		           (if (listp flags) flags (list flags)) " "))
+         (flags (mapconcat #'identity
+		           (if (listp flags)
+                               flags
+                             (list flags)) " "))
          (libs (org-babel-read
 	        (or (cdr (assq :libs params))
 	            (org-entry-get nil "libs" t))
@@ -97,11 +99,12 @@ org-babel-Haskell-execute
     (with-temp-file tmp-src-file (insert body))
     (org-babel-eval
      (format "%s -o %s %s %s %s"
-             org-babel-Haskell-compiler
+             org-babel-haskell-compiler
 	     tmp-bin-file
 	     flags
 	     (org-babel-process-file-name tmp-src-file)
-	     libs) "")
+	     libs)
+     "")
     (let ((results
 	   (org-babel-eval
 	    (concat tmp-bin-file cmdline) "")))
@@ -116,10 +119,9 @@ org-babel-Haskell-execute
          (org-babel-pick-name
 	  (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
          (org-babel-pick-name
-	  (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))
-      )))
+	  (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))))
 
-(defun org-babel-interpret-Haskell (body params)
+(defun org-babel-interpret-haskell (body params)
   (require 'inf-haskell)
   (add-hook 'inferior-haskell-hook
             (lambda ()
@@ -157,10 +159,10 @@ org-babel-interpret-Haskell
 
 (defun org-babel-execute:haskell (body params)
   "Execute a block of Haskell code."
-  (setq compile (string= (cdr (assq :compile params)) "yes"))
+  (let ((compile (string= "yes" (cdr (assq :compile params)))))
   (if (not compile)
-      (org-babel-interpret-Haskell body params)
-    (org-babel-Haskell-execute body params)))
+      (org-babel-interpret-haskell body params)
+    (org-babel-haskell-execute body params))))
 
 (defun org-babel-haskell-initiate-session (&optional _session _params)
   "Initiate a haskell session.
-- 
2.20.1

Reply via email to