Skip to content

Inferior-haskell: do not insert repeated prompts. #1806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

cnngimenez
Copy link

Hi!

I found that ob-haskell.el shows multiple prompts at any code block output. This was a little annoying for me, so I tried to fix it. Then, I realized it was from the inferior-haskell: It did not remove the prompts from the process output.
For example, when starting an inferior Haskell with M-x run-haskell and writing a multiple line function, the "*haskell*" buffer looks like this:

Loaded package environment from /home/poo/.ghc/x86_64-linux-9.0.2/environments/default
GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci> ghci> :{
f x
  | x == 0 = 1
  | x < 0  = 1
  | otherwise = 2 * f (x - 1)
:}

ghci| ghci| ghci| ghci| ghci| ghci> ghci> 

Therefore, I wrote a function to remove all prompts except for the last one. All continuation prompts (ending with "| ") are completely removed too. After that, I added it to the hook comint-preoutput-filter-outputs buffer-locally. Now, the result in the "*haskell*" buffer is:

Loaded package environment from /home/poo/.ghc/x86_64-linux-9.0.2/environments/default
GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci> :{
f x
  | x == 0 = 1
  | x < 0  = 1
  | otherwise = 2 * f (x - 1)
:}

ghci> 

I believe that this output is easier to read, and the ob-haskell.el (and maybe other libraries) process the buffer output without the need for more code.

Is it good to include this modification?
Does this patch requires any other change?
Cheers.

@purcell purcell merged commit 495fb96 into haskell:master Feb 5, 2025
@purcell
Copy link
Member

purcell commented Feb 5, 2025

Looking back through a couple of PRs, since nobody actively maintains haskell-mode these days, and this seems worth merging — thanks!

@purcell
Copy link
Member

purcell commented Feb 24, 2025

Going to revert this due to #1867, but if you want to fix it up and try again, let me know.

purcell added a commit that referenced this pull request Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants