Hi,
Is there a multiline interpreter for Haskell that lets you write multiline functions and edit previous lines?
Or otherwise is there a hacky way to do something like this with a command line interface library that would let you treat any command line app as having a multiline interface?
Python 3.13 released the other day contains such an interpreter, so I thought the timing would be good to ask this. OCaml has utop, which I am very happy with.
3 Likes
You can start a multiline block with :{, define your function(s), and later close it with :} to “submit” it as a single block. IIRC it should also be possible to edit the previous lines in the same multiline block.
2 Likes
Once you get to that stage it’s far easier just to open a file in your editor and load it in ghci with :add.
8 Likes
Or indeed :load, or :module or just import, depending on exactly what you want to achieve or whether you can ever remember the difference between them.
I believe :load kicks out everything previously :loaded or :added, so I think it’s typically unhelpful. I’m not sure what :module does.
:module is similar to import.
:module puts an already loaded module and all its internal scope into the current context. :module+ lets you include more.
import is just a normal Haskell import.