tsnobip / isotrope

An experimental safe bi-directional router for ReasonReact
12 stars 1 forks source link

Infix Operators in ReScript #5

Open woeps opened 3 years ago

woeps commented 3 years ago

Problem

Current ReScript (9.0.1) still has no support for custom infixes. Therefore the routes api can't be used in a .res file. Furthermore the operator //? can't be used in .re files as well, since // marks a comment. Creating a .ml file in a ReScript project is currently the only way to fully use route's api. Many users may not be comfortable using ocaml syntax to define their routes.

Proposal

I see isotrope as some kind of wrapper of anuragsoni/routes to make it available to ReScript users and improve the comfort using it in react. Therefore I'd like to propose to introduce a module to isotrope which holds aliases for route's infixes. (needs to be in ocaml syntax)

Open Questions

In my opinion three questions need to be answered before working on this issue gets possible:

Route's Infixes

tsnobip commented 3 years ago

Thanks for raising this issue @woeps. I asked the core team on the forum about it and apparently they're planning to add infix operators back in March, but I'm open to work on it anyway, maybe we can find a nice solution without infix.

From the beginning I thought it would be nice to have everything in a single point of access, even if still using infix operators, but haven't done it yet because I still want to have a nice API for that.

Regarding the alias name, I guess it depends on the API, it'll probably not be a one to one translation. Don't hesitate to post here your proposals, I'll work on my own too.

woeps commented 3 years ago

I just experimented a little bit, when I tried the recent changes of anurag regarding detailed information on wildcard matches.

See: