Merlin and ReScript

So anyone knows the story, there? :slight_smile: Merlin worked for ReScript and now it doesn’t anymore, or what? Or there are better alternatives?

Using rescript syntax, no. The only option is to use one of the official IDE extensions.

For reasonml syntax it can still work but you have to downgrade to old versions. The tooling all dropped support for OCaml 4.06 some time ago, and more recently stopped using .merlin files completely.

Are those the main blockers? OCaml 4.06 and .merlin files? Maybe there’s a doc somewhere that describes the inner workings of ReScript? Not sure how it works there. IIRC, Reason was just a new lexer + parser on top of OCaml…?

Reason was. ReScript isn’t. That was part of what drove the separation; a desire to remove the “must be 100% OCaml compatible” restriction.

The way OCaml tooling works with Reason syntax is they added support for piping everything through the refmt command-line tool. No such tool exists for ReScript, and as ReScript diverges from OCaml it becomes less and less possible to adapt existing tooling. As this was the plan from the beginning, no such adaption was attempted.

OK, so ReScript is a fork of OCaml? Using its type-checking, but not other parts of the compiler pipeline?

Simply said ReScript is a fork of OCaml / JSOO, with changes in the type system and pattern matcher engine, with some extra additions like uncurried functions, and some extra decorators to allow better JS interop / compilation. In current master it also removes some builtin in functionality that’s not relevant for the JS target, e.g. some parts of Pervasives and the Format module.

You can actually check out the source code. The inlined ocaml compiler code can be found in the jscomp/ml folder, with some local changes here and there.

3 Likes

Interesting tidbit about ReScript and JSOO. For no reason, I always assumed that BuckleScript/ReScript was written from scratch. Though, at this point, ReScript is probably as similar to JSOO as WebKit is to KHTML.