How the communication between editors and the ghci repl is made?

Hi everyone.

I would like to ask, in the context of Tidal, how the communication between the different editors and the ghci repl happens? Is it through OSC with a String inside?

I'm trying to understand it by looking the engines of some tools: tidal-vim, Flok, Strudel's osc and the Pulsar plugin . But there are so many pieces there I couldn't find where the relevant parts for the communication between them and the ghci were.


There’s usually no OSC between the editor and GHCi. In the case of the Pulsar plug-in, the plug-in is a Node JS script that spawns a child process running GHCi and then sends it code through the standard IO. The vim plug-in is a similar wrapper around GHCi, as is Flok (except Flok is pulling code from online connections).

In the case of Strudel's osc functionality, it's actually skipping Tidal (and GHCi) entirely. Instead, it uses osc to communicate directly to SuperDirt running in SuperCollider.

Thank you, @mindofmatthew
How this child processes connect with Tidal?

Let's say that @xinniw, because neovim's API is all in Lua, decides use it as the editor for Tranquility. There's a neovim plugin (nvim-repl) that opens a split with ghci. To send selected text, a line or a block of code from the editor should not be a problem, but then how to make ghci do the Tidal stuff?

Basically, you need to find where a BootTidal.hs file is on the coder's system. If they have a custom boot file, that could be saved in some sort of configuration, but if you want the built-in boot file provided by the Tidal installation, you can run the following command:

ghc -e "import Paths_tidal" -e "getDataDir>>=putStr"

This will print the path to the folder. The boot file will be at <folder path>/BootTidal.hs (or \ on Windows filesystems).

Then, you can start GHCi, automatically running this boot file, by executing the command:

ghci -ghci-script <BootTidal path>

On my specific machine, that looks like:

ghci -ghci-script "/home/matthew/.cabal/store/ghc-9.4.4/tidal-1.9.3-988e1310dfad49c6e1653dd6426004b86b6200f9b39f2e47dc0c5b8add151507/share/BootTidal.hs"

That will print out several lines as Tidal starts up. From then on, you can type a line of Tidal code at the command line and hit enter to evaluate it. Basically, once you've loaded a Tidal boot file, sending text to ghci is all that you need for it to work.