Hi Org Maintainers,
Attached is an updated patch that makes output trimming work with
blocks that do and don't produce results. The old patch creates a
=let: Wrong type argument: arrayp, nil= error when evaluating blocks
that don't produce output. This necessarily incorporates yesterday's
patch.
Thanks for your time,
Nick
Multi-line function declarations with output still work fine.
#+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:
| 10 | 5 | 16 | 8 | 4 | 2 | 1 |
Silent declaration-only blocks correctly evaluate silently.
#+BEGIN_SRC haskell :results silent
:{
flip' :: (a -> b -> c) -> (b -> a -> c)
flip' f = \x y -> f y x
:}
#+END_SRC
Single-line function calls also return the expected results.
#+name: flip'-hello
#+BEGIN_SRC haskell
flip' zip [1,2,3,4,5,6] "hello"
#+END_SRC
#+RESULTS: flip'-hello
| h | 1 |
| e | 2 |
| l | 3 |
| l | 4 |
| o | 5 |
diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el
index bea162528..cb581fe3b 100644
--- a/lisp/ob-haskell.el
+++ b/lisp/ob-haskell.el
@@ -83,12 +83,16 @@
(cdr (member org-babel-haskell-eoe
(reverse (mapcar #'org-trim raw)))))))
(org-babel-reassemble-table
- (let ((result
+ (let* ((result
(pcase result-type
(`output (mapconcat #'identity (reverse results) "\n"))
- (`value (car results)))))
+ (`value (car results))))
+ (result
+ (if (stringp result)
+ (replace-regexp-in-string "Prelude[|>] " "" result)
+ result)))
(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))