haskell / haskell/haskell-mode

Add an interactive function to send the top-level definition the point is currently in to the REPL

Open
#608 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
1.4k
Forks
354
Avg merge
5d 10h
Merged PRs (30d)
2

Description

Working in the Haskell REPL with only the ability to reload a file is extremely painful, because reloading a file throws away all local bindings. I propose that `haskell-mode` learns a new interactive function that sends just the current top-level definition to the REPL, shadowing the existing binding with that name.

As a motivating example, consider building a parser for a CSV file. First of all, I load the CSV contents into a string in the REPL with `csvStr <- readFile "data.csv"`. Next, I work on my `parse :: String -> [Record]` function. Whenever I make changes I send this function to the REPL, and then I can test `parse csvStr`. I don't have to reload the CSV file every time I change that function.

This becomes more important when the data I'm testing against comes from a database query. With the current behavior I have to reconnect to PostgreSQL, issue my query, and then I can test my changes. For all purposes, this makes the REPL significantly less productive than it could be.

We probably don't have the ability to send _all_ top-level definitions to the REPL - for example, I'm not sure it's possible to redefine type class instances. However, just redefining functions would be a good start.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.