haskell / haskell/haskell-language-server

Enable eval plugin to run in its own terminal and enable terminal to be piped to a log file

Open
#4,390 3 comments 1 reaction 0 assignees View on GitHub
component: hls-eval-plugin type: enhancement
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
4d 3h
Merged PRs (30d)
12

Description

## Is your enhancement request related to a problem? Please describe.

I just discovered that in VSCode the `eval` plugin logs to the Haskell Output window in addition adding the result to the code editor.

#### Code to Eval
```haskell
-- >>> helloWorldNonInteractive
-- "DONE"
helloWorldNonInteractive :: IO Text
helloWorldNonInteractive = putStrLn "Hello, World!" >> pure "DONE"
```

#### VSCode Haskell Output
```bash
2024-08-24T23:53:08.298464Z | Info | Live bytes: 95.98MB Heap size: 718.27MB
2024-08-24T23:54:08.351720Z | Info | Live bytes: 95.98MB Heap size: 718.27MB
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
toIfaceIdDetails [DataConWrapper]
Hello, World!
2024-08-24T23:55:08.383369Z | Info | Live bytes: 95.98MB Heap size: 718.27MB
```

It is also apparent that the output that is interleaved with the HLS logs are not copied to file when that option is selected in VSCode settings.

#### haskell.log
```
2024-08-24T23:54:08.351135Z | Info | Live bytes: 95.98MB Heap size: 718.27MB
2024-08-24T23:55:08.382573Z | Info | Live bytes: 95.98MB Heap size: 718.27MB
2024-08-24T23:56:08.436285Z | Info | Live bytes: 95.98MB Heap size: 718.27MB
2024-08-24T23:57:08.481933Z | Info | Live bytes: 95.98MB Heap size: 718.27MB
```

## Describe the solution you'd like

It would be awesome if there could be an option with the `eval` plugin to output to a separate output window, free of the noise of HLS logs and optionally log the same to a file. Better still if an interactive terminal could be used instead of a an output window. Interactive code seems to bork the current version hls `eval` (which is understandable given there is no way to interact with a program invoked via `eval`).

```haskell
-- >>> helloWorld
-- "DONE"
helloWorld :: IO Text
helloWorld = do
putStrLn "What is your name?"
name <- T.getLine
putStrLn $ "Hello, " <> toS name <> "!"
pure "DONE"
```

this will cause a `Connection got disposed` error

## Describe alternatives you've considered

A somewhat similar ux can be achieved with `cabal repl` or `ghcid` or more recently `ghciwatch` but it would be great to be able to do it all with `eval`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.