From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YH4iJwU7UGPNlAAAbAwnHQ (envelope-from ) for ; Wed, 19 Oct 2022 19:59:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id UDknJwU7UGNtFgEAauVa8A (envelope-from ) for ; Wed, 19 Oct 2022 19:59:33 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1DF8929D3D for ; Wed, 19 Oct 2022 19:59:33 +0200 (CEST) Received: from localhost ([::1]:51280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olDLn-0001gN-C8 for larch@yhetil.org; Wed, 19 Oct 2022 13:59:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olDKk-0001eX-Gq for emacs-orgmode@gnu.org; Wed, 19 Oct 2022 13:58:30 -0400 Received: from smtp6-g21.free.fr ([2a01:e0c:1:1599::15]:18040) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olDKi-0003Zc-PM for emacs-orgmode@gnu.org; Wed, 19 Oct 2022 13:58:26 -0400 Received: from tosh-laptop (unknown [IPv6:2a01:e0a:505:3460:1a16:a0c4:3f89:c0d9]) by smtp6-g21.free.fr (Postfix) with ESMTPS id 0958C780377; Wed, 19 Oct 2022 19:58:15 +0200 (CEST) Received: by tosh-laptop (sSMTP sendmail emulation); Wed, 19 Oct 2022 20:03:21 +0200 From: Bruno Barbier To: Ihor Radchenko , "Thomas S. Dye" Cc: emacs-orgmode Subject: Re: Haskell code blocks In-Reply-To: <87czaoaziu.fsf@localhost> References: <87a6gdaa9i.fsf@tsdye.online> <87tu40cyo5.fsf@localhost> <878rlcqxcn.fsf@tsdye.online> <87czaocuic.fsf@localhost> <87pmeoa045.fsf@tsdye.online> <87czaoaziu.fsf@localhost> Date: Wed, 19 Oct 2022 20:03:20 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: softfail client-ip=2a01:e0c:1:1599::15; envelope-from=brubar.cs@gmail.com; helo=smtp6-g21.free.fr X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, MISSING_MID=0.497, NML_ADSP_CUSTOM_MED=0.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action Message-Id: X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666202373; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=htlDOMRBi1lUdEs0/ji1w2apPIvBOFYcXFrKzKdITx0=; b=YlptgOOKisbdsxC274u5kvyitIOaweyZ9KAxhcWLMBSsCQPVAX/S9tlM/YH/6LJSRrywot AwgsIW2RswjxcuWz4Jzspf5yFxyEDvuU8mbEjwrbbyMyRQOlZ1quSd5LetBcWdzgKotjwj oh7N7VFn5N5m6Cuuumvbm5+xA0YzD4t/UUGVzOP26gGJcpVzSXkpRxxyEHLwi6ICXmg5qb lZgbQNUaXqCUcYyesTdNrgp/FLXip/OJOY0GOlRs+7Psl51V1mHksZFF4d+Ftr6t1Q9HEr lHY+9A0VILdfxdD/lhVkeCARqyOydzToVpt8MwI+uNCaDkaO+v4kzVULO4/RqA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666202373; a=rsa-sha256; cv=none; b=ECoOhuLnn/4vKvxnVz3lBasqTiLouzgTVbNLNxSrToVxeTG0nzq2vlHuLszXxKDlZ4CYlq jfS9APMpMOUXOFocTpGOQnj4neKsBnyAfK5A0jV+hSOPtuXUZZHGHuIKqQ+sTPyOouU8tT rXWTfCg0yZczN87mUCq4zMGGBAz9m7jLh5M18klk9tx48ZbE7o1sDUgouR+AFDe2aoZAGY TkwNw02nRun9UtQ6B2jKHgVKw3c61Utdf4cbafPsSyOhV8862WWp6WwRnVIKdWyTRuiRZr n7hP7ceGPzLo3rwhyb9fyaaZjkSmzAwLSh4FcryvNXD3/2WimZg9ivEZuhwzkw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 3.77 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1DF8929D3D X-Spam-Score: 3.77 X-Migadu-Scanner: scn1.migadu.com X-TUID: VfbPWT9+bTuM --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Thomas, Ihor, I'm not currently using ob-haskell, but I do have a version of GHC. As I may use ob-haskell one day, I decided to take a look. Here are the versions I'm using: #+begin_src elisp (list (list "emacs" emacs-version) (list "org" org-version) (list "ghc" (string-trim (shell-command-to-string "ghc -V"))) ) #+end_src #+RESULTS: | emacs | 29.0.50 = | | org | 9.6-pre = | | ghc | The Glorious Glasgow Haskell Compilation System, version 8.10.= 7 | The following code block is incorrect: #+begin_src haskell :results output main :: IO ()=20 main =3D putStrLn "Hello, World!" main #+end_src #+RESULTS: : :2:1-4: error: : =E2=80=A2 Variable not in scope: main :: IO () : =E2=80=A2 Perhaps you meant =E2=80=98min=E2=80=99 (imported from P= relude) : Prelude> Hello, World! The first line tries to evaluate 'main' which doesn't exist (yet). The following modified block works, using the compiler. #+begin_src haskell :compile yes :results output main :: IO ()=20 main =3D putStrLn "Hello, World!" #+end_src #+RESULTS: : Hello, World! The following works using the interpreter: #+begin_src haskell let { main :: IO ()=20 , main =3D putStrLn "Hello, World!" } main #+end_src #+RESULTS: : Hello, World! A simpler version, that just print "Hello, World!" works: #+begin_src haskell putStrLn "Hello, World!" #+end_src #+RESULTS: : Hello, World! Just evaluating the string doesn't work! #+begin_src haskell "Hello world!" #+end_src #+RESULTS: as we don't get any result ... If I understand correctly, it seems to be a bug in ob-haskell; `org-babel-comint-with-output' shouldn't be instructed to remove the output if it matches the input, else, it will remove any constant. Adding a type annotation is enough to make it works: #+begin_src haskell "Hello world!" :: String #+end_src #+RESULTS: : Hello world! =20=20=20 Or fixing `org-babel-interpret-haskell' (see attached patch): #+begin_src haskell "Hello world!" #+end_src #+RESULTS: : Hello world! Another example that works too, with or without the patch: #+begin_src haskell concat ["Hello", ", ", "World", "!"] #+end_src #+RESULTS: : Hello, World! I've attached the patch that I've used to fix ob-haskell. Should I submit a patch for ob-haskell ? Bruno --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-babel-interpret-haskell-Don-t-remove-outputs-tha.patch Content-Description: Fix org-babel-interpret-haskell >From f2e91a62469e84ce1d3036216ae3eca4084f3b94 Mon Sep 17 00:00:00 2001 From: Bruno BARBIER Date: Wed, 19 Oct 2022 19:44:42 +0200 Subject: [PATCH] org-babel-interpret-haskell: Don't remove outputs that match inputs * lisp/ob-haskell.el (org-babel-interpret-haskell): Change the call to `org-babel-comint-with-output'. --- lisp/ob-haskell.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el index d195dcf87..99e590bfb 100644 --- a/lisp/ob-haskell.el +++ b/lisp/ob-haskell.el @@ -136,7 +136,7 @@ (defun org-babel-interpret-haskell (body params) (comint-preoutput-filter-functions (cons 'ansi-color-filter-apply comint-preoutput-filter-functions)) (raw (org-babel-comint-with-output - (session org-babel-haskell-eoe t full-body) + (session org-babel-haskell-eoe nil full-body) (insert (org-trim full-body)) (comint-send-input nil t) (insert org-babel-haskell-eoe) -- 2.37.3 --=-=-=--