-
Notifications
You must be signed in to change notification settings - Fork 3
REPL state management relies on hard-coded delays and lacks error awareness #5
Description
Location
src/repl.ts (approx. lines 37–62)
Problem
The current REPL state management assumes that commands complete successfully after fixed delays. This makes module loading and evaluation fragile and non-deterministic, especially on slower systems or when compilation errors occur.
Issues Identified
- REPL commands rely on fixed delays (
1000ms,200ms,300ms) to assume completion. - There is no verification that a module actually loaded successfully.
- Errors produced by GHCi (compile or runtime) are not detected or surfaced.
- Internal module tracking adds modules even if loading fails.
- Module unloading or failed reloads are not reflected in tracked state.
- Terminal visibility is used as a synchronization mechanism, which is unreliable.
Why This Is a Problem
- Fixed delays behave differently across machines and system load.
- Failed module loads can appear “successful” to the extension.
- Users do not receive clear feedback when compilation fails.
- Internal REPL state can become inconsistent with actual GHCi state.
- Makes future features (function listing, per-module execution) harder to build reliably.
Expected Behavior
- REPL interactions should be synchronized based on actual completion, not timeouts.
- Module loads should only be recorded if they succeed.
- Errors from GHCi should be detectable and made available to the extension.
- Internal state should accurately reflect what is loaded in the REPL.
- Behavior should be consistent across macOS, Linux, and Windows.
Guidance (Non-prescriptive)
Contributors working on this issue may want to explore:
- More deterministic ways of detecting when a GHCi command finishes.
- Capturing and interpreting GHCi output instead of assuming success.
- Event- or output-based completion signals rather than fixed delays.
- Improving how module state is tracked when loads or reloads fail.
The exact approach and design choices are intentionally left open.
How to Test
-
Install the extension from VS Code (or run it via the extension host).
-
Clone the test repository:
https://github.com/midhunann/haskell-test -
Open the repository in VS Code.
-
Try loading modules and evaluating expressions in the REPL.
-
Introduce intentional syntax or type errors and observe behavior.
-
Modify and reload modules repeatedly.
-
Verify that:
- Failed loads are detected
- Errors are visible to the user
- REPL state remains consistent after failures
Priority
Medium — this does not block basic usage, but it significantly affects reliability, correctness, and future extensibility.