Skip to content

REPL Support #477

Closed
Closed
@alanz

Description

@alanz

Haskell is legendary as a REPL driven language, via ghci. This is the last major piece missing from our IDE offering.

How will we do it?

This is my personal brain dump, specifically to seed a discussion on the topic. Nothing cast in concrete.
Note: I use "the server" to refer to the conglomerate of HLS, ghcide, hie-bios, etc.

  • The REPL has to be part of the running server.
    • Given the immense memory usage cost we already incur, running a separate ghci session does not make sense
    • Also keeping things in sync becomes problematic
  • It has to have unfettered access to its own IO
    • A user needs to be able to run code, which they have just written. This mostly does IO
    • A corollary of this is that running user code should not cause a lack of responsiveness in the server
  • It has to have a well-defined, well-integrated way of integrating with an IDE.
    • We have come this far using LSP, ideally we should leverage existing protocols implemented in most IDEs

My high level view of a way of achieving all these goals is the following

  • Use the Debug Adapter Protocol (DAP)
    • This already has first class support in VsCode and emacs, and coming to others as it picks up usage
  • Expose a DAP TCP endpoint in the running server.
  • DAP is just a message passing protocol, intending to talk to a target manager. This role is played by the server.
  • Use the RunInTerminal reverse request to initiate the session. This opens up an inferior terminal in the client, which exposes the REPL
  • Run something in this terminal which talks back to another endpoint in the server. This endpoint is used to run the read-eval-print loop for a ghci session
  • The ghci session runs via remote-interpreter, against hooked stdio pipes, which are routed via the third endpoint to the terminal in the client.

Voila. The rest is detail.

Back of envelope sketch of the concept

block-diagram

See also

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: in discussionNot actionable, because discussion is still ongoing or there's no decision yettype: enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions