Re: Haskell code blocks

2023-03-19 Thread Bruno Barbier



Hi Ihor,

>> Bruno Barbier  writes:
>>
>>> Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have
>>> some spare time, but I'm unable so far to find tests that I can't
>>> reliably break.

FTR: I've opened a new thread, with a patch containing tests:

   https://lists.gnu.org/archive/html/emacs-orgmode/2023-03/msg00274.html

Bruno.




Re: Haskell code blocks

2023-03-15 Thread Bruno Barbier


Hi Ihor,

Ihor Radchenko  writes:

> Bruno Barbier  writes:
>
>> Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have
>> some spare time, but I'm unable so far to find tests that I can't
>> reliably break.
>
> May I know if you are still working on this?
> Do you need any help?

My tests were too easy to break. I tried to learn more about
haskell-mode, but I got lost. Then, it got down in my todo list.

I'll check what I have this week-end and come back to you.  But, that
might just be a set of tests that randomly fail.  Anyway, we'll decide
from there.

Thanks for your ping.

Bruno





>
> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: Haskell code blocks

2023-03-13 Thread Ihor Radchenko
Bruno Barbier  writes:

> Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have
> some spare time, but I'm unable so far to find tests that I can't
> reliably break.

May I know if you are still working on this?
Do you need any help?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Haskell code blocks

2022-11-08 Thread Ihor Radchenko
Bruno Barbier  writes:

> Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have
> some spare time, but I'm unable so far to find tests that I can't
> reliably break.
>
> I'll open a new thread when I think my 'test-ob-haskell.el' is worth
> reviewing.

Thanks for continued work on this!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Haskell code blocks

2022-11-08 Thread Bruno Barbier
Ihor Radchenko  writes:

> Applied onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0de063a52181bd96ac9bf023454781f07c3353b3

Thanks Ihor.

Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have
some spare time, but I'm unable so far to find tests that I can't
reliably break.

I'll open a new thread when I think my 'test-ob-haskell.el' is worth
reviewing.

Bruno.





> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: Haskell code blocks

2022-11-06 Thread Ihor Radchenko
Bruno Barbier  writes:

> I've attached the patch that I've used to fix ob-haskell.

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0de063a52181bd96ac9bf023454781f07c3353b3

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Haskell code blocks

2022-10-22 Thread Jarmo Hurri


Greetings Thomas.

"Thomas S. Dye"  writes:

> I'm struggling to write a minimal ob-doc-haskell.org for Worg.
>
> The obligatory Hello World! example yields bad results.
>
> #+name: haskell-hello-world
> #+begin_src haskell 
>
> main :: IO () 
> main = putStrLn  "Hello, World!"
> main
> #+end_src
>
> #+RESULTS: haskell-hello-world
> : Prelude> Hello, World!

The good ole obligatory part is fulfilled by including ":session none":

 #+name: haskell-hello-world
 #+begin_src haskell :session none
   main :: IO () 
   main = putStrLn  "Hello, World!"
   main
 #+end_src

 #+RESULTS: haskell-hello-world
 : Hello, World!

All the best,

Jarmo




Re: Haskell code blocks

2022-10-20 Thread Ihor Radchenko
Bruno Barbier  writes:

> I've attached the patch that I've used to fix ob-haskell.
>
> Should I submit a patch for ob-haskell ?
>
> Bruno
>
>
> 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

Thanks! Could you also create testing/lisp/test-ob-haskell.el file and
add your examples as tests in there?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Haskell code blocks

2022-10-19 Thread Bruno Barbier

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 () 
 main = putStrLn  "Hello, World!"
 main
   #+end_src

   #+RESULTS:
   : :2:1-4: error:
   : • Variable not in scope: main :: IO ()
   : • Perhaps you meant ‘min’ (imported from Prelude)
   : 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 () 
 main = putStrLn  "Hello, World!"
   #+end_src

   #+RESULTS:
   : Hello, World!


The following works using the interpreter:
   #+begin_src haskell
 let { main :: IO () 
 , main = 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!
   
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


>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



Re: Haskell code blocks

2022-10-19 Thread Ihor Radchenko
"Thomas S. Dye"  writes:

>> To clarify, it looks like Prelude Emacs is doing something wrong 
>> here.
>> Something that breaks haskell-mode and consequently ob-haskell.
>
> I'm using Spacemacs.  Prelude is a standard module in Haskell.  I 
> thought that might be the source.

Thanks for the extra info!
What happens if you run Haskell repl and check the values of
haskell-prompt-regexp and comint-prompt-regexp in the Haskell repl
buffer?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Haskell code blocks

2022-10-18 Thread Thomas S. Dye



Ihor Radchenko  writes:


"Thomas S. Dye"  writes:

Thanks Ihor.  I don't actually use Haskell.  Earlier this year 
I 
attempted to complete the Org Babel language documents on Worg, 
but couldn't get the obligatory "hello world" code block to 
behave 
in Haskell.  I'm guessing that ob-haskell.el actually works for 
experienced Haskell programmers and was hoping someone had a 
solution to the Prelude> problem.  I'm not sure when I might 
get 
back to this.


To clarify, it looks like Prelude Emacs is doing something wrong 
here.

Something that breaks haskell-mode and consequently ob-haskell.


I'm using Spacemacs.  Prelude is a standard module in Haskell.  I 
thought that might be the source.


Tom
--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Haskell code blocks

2022-10-18 Thread Ihor Radchenko
"Thomas S. Dye"  writes:

> Thanks Ihor.  I don't actually use Haskell.  Earlier this year I 
> attempted to complete the Org Babel language documents on Worg, 
> but couldn't get the obligatory "hello world" code block to behave 
> in Haskell.  I'm guessing that ob-haskell.el actually works for 
> experienced Haskell programmers and was hoping someone had a 
> solution to the Prelude> problem.  I'm not sure when I might get 
> back to this.

To clarify, it looks like Prelude Emacs is doing something wrong here.
Something that breaks haskell-mode and consequently ob-haskell.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Haskell code blocks

2022-10-18 Thread Thomas S. Dye
Thanks Ihor.  I don't actually use Haskell.  Earlier this year I 
attempted to complete the Org Babel language documents on Worg, 
but couldn't get the obligatory "hello world" code block to behave 
in Haskell.  I'm guessing that ob-haskell.el actually works for 
experienced Haskell programmers and was hoping someone had a 
solution to the Prelude> problem.  I'm not sure when I might get 
back to this.


All the best,
Tom

Ihor Radchenko  writes:


"Thomas S. Dye"  writes:


I'm struggling to write a minimal ob-doc-haskell.org for Worg.

I installed Haskell via Spacemacs (development branch) and the 
Haskell installation appears to be functioning correctly.


The obligatory Hello World! example yields bad results.

#+name: haskell-hello-world
#+begin_src haskell 
main :: IO () 
main = putStrLn  "Hello, World!"

main
#+end_src

#+RESULTS: haskell-hello-world
: Prelude> Hello, World!

I'm guessing the "Prelude>" part of the output is the prompt 
from 
the interpreter.


I found this in ob-haskell.el:

  (setq-local comint-prompt-regexp
  (concat haskell-prompt-regexp 
  "\\|^λ?> 
  "
  
But I couldn't find a way to modify haskell-prompt-regexp 
without 
changing the source.


Advice welcome.


I guess you can report this as a bug in Haskell-mode?
haskell-prompt-regexp is defined there.

If absolutely necessary and if you want that _your_ Haskell 
prompt is
different from Haskell-mode defaults, just setq 
haskell-prompt-regexp in

your config.



--
Thomas S. Dye
https://tsdye.online/tsdye



Re: Haskell code blocks

2022-10-18 Thread Ihor Radchenko
"Thomas S. Dye"  writes:

> I'm struggling to write a minimal ob-doc-haskell.org for Worg.
>
> I installed Haskell via Spacemacs (development branch) and the 
> Haskell installation appears to be functioning correctly.
>
> The obligatory Hello World! example yields bad results.
>
> #+name: haskell-hello-world
> #+begin_src haskell 
> main :: IO () 
> main = putStrLn  "Hello, World!"
> main
> #+end_src
>
> #+RESULTS: haskell-hello-world
> : Prelude> Hello, World!
>
> I'm guessing the "Prelude>" part of the output is the prompt from 
> the interpreter.
>
> I found this in ob-haskell.el:
>
>   (setq-local comint-prompt-regexp
>   (concat haskell-prompt-regexp "\\|^λ?> 
>   "
>   
> But I couldn't find a way to modify haskell-prompt-regexp without 
> changing the source.
>
> Advice welcome.

I guess you can report this as a bug in Haskell-mode?
haskell-prompt-regexp is defined there.

If absolutely necessary and if you want that _your_ Haskell prompt is
different from Haskell-mode defaults, just setq haskell-prompt-regexp in
your config.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at