Plans to provide a ReScript REPL

Loving your work and super excited to be able to abandon Typescript for this.

My question - are there any plans to provide a REPL for Rescript?

6 Likes

There were some user-land attempts at a REPL proof of concept, but I don’t think they got very far before hitting some hard problems. At least that’s my impression of the situation.

I had some ideas for design that would use Node’s built-in JavaScript REPL and redirect the input to a custom function to compile the Reason code. A naive implementation might just save the text history and recompile on each text submission. But compiling the whole program for each input could end up being slow & less responsive than most people want in a REPL. At the very least, it’s an inefficient design.

I’ll admit I haven’t thought too much about it, though. Maybe someone else has a better handle on what it would take to implement a proper REPL.

@austindd I think performance is not a problem (at least that much). Scala repl is slow IMO and still pretty useful.

1 Like

especially given how fast rescript compiler is, that shouldn’t be an issue in itself.

1 Like

Yeah, for small input sizes, it probably wouldn’t be noticeable. But if we choose to load massive dependency trees and run ppx transforms, it could potentially get sluggish. Then again, incremental compilation should mostly mitigate the issue of large dependency trees.

Other things to think about include auto-complete, real-time type info in the terminal, pretty-printing values & type signatures, etc. The Node REPL doesn’t provide much help with that, and will require some engineering effort.

I suppose the best way to address those questions is to build a proof of concept. Maybe I’ll try it out in the near future.

But keep in mind I don’t have a lot of experience in this domain. Other folks probably have deeper insight/experience with this kind of thing. I’d love for those people to weigh in.

2 Likes

There used to be rtop. does it still work? It was annoying that one couldn’t load modules with it, tough.

No plans on that, bc it is tricky to get the details right. Time will probably be invested in improving the web playground infrastructure instead.

I usually use a Scratch.res file and run the script directly via node… not really a repl, but at least I can easily inspect the emitted js, and also see the actual runtime results

2 Likes