[ANN] Tapak: Experimental Web Framework Based on EIO

Hello! I am a newcomer to the OCaml community, and this is my first post.

I would like to share an experimental web framework I have been working on, based on Eio. I am a happy user of Dream and Opium, but I felt there was still room for improvement.

I’ve shared my motivation here: Tapak | Syaiful Bahri

I would love to hear your suggestions and opinions regarding the API. What important features do you feel are missing in existing libraries? Personally, I miss the type-safe routing that Servant offers, as well as the Phoenix real-time API.

14 Likes

Do you know about ocsigen ?

Its the ocaml web framework with the most features that I know. It has not only type safe routing, but type safe http requests.

That is, you can mark a function as being an endpoint of sorts, and then when this function is called from the frontend, the http request for it is generated, and the function actually runs on the backend.

2 Likes

I believe you are referring to Ocsigen Eliom. I did look into it, but it is built on Lwt, and I was specifically interested in a framework that does not use Lwt and use algebraic effects instead. This is not due to any dislike for Lwt, but rather my desire to explore what an OCaml web framework built with Eio and algebraic effects might look like.

Eliom’s server-client capabilities are interesting, but they are incompatible with our existing tooling. Our teams prefer using Melange with React.js (via reason-react) for the frontend and server-reason-react for the backend

1 Like

Yes, ocsigen/eliom is opiniated, and you have to kind of opt in everything to get the benefits.

However, even if you can’t use it, looking at it to get inspiration for features for your framework is certainly worth it.

I am not a big fan of melange, because of how much more complicated it is to use random libs from opam compared to jsoo. My understanding is that it makes a lot of sense if you have an existing JS codebase or if you want to use JS tooling.

Btw, your type safe routes are something very nice. Did you get inspiration from furl ?

I think your api looks nicer, but the idea is the same.

2 Likes

This is currently what we offer through our Vif framework. The latter also uses algebraic effects and Miou as a scheduler (you can find more details here). We have wanted typed routes for a very long time. vif goes a little further than furl because it also attempts to type the content of a request (and recognises whether this content is JSON or multipart/form-data, which allows for typed forms). There is a tutorial available here and an example of a chat room (with websockets) here.

2 Likes

The router is inspirred by GitHub - anuragsoni/routes: typed bidirectional router for OCaml/ReasonML web applications, I tried to use this library first, but I wanted a custom solution for “Request Guard” which is kind like a middleware/filter but allow the validated data goes directly to request handler.

I was first modeled it as Servant way, where we accumulate the parameter in list, but it was too complicated. :rofl:

This is the closest library/framework we wanted. Unfortunately, I didn’t know it until someone mention it in my tweet. :smiley:

Anyway, Vif is looking nice. If I knew it, I won’t write a new library at all. But I learning new things along the way.

2 Likes

Great work @syaiful6. Looking forward on where you reach with Tapak :smiley:

2 Likes

There is now a (very experimental) version of Eliom (and Js_of_ocaml/Ocsipersist/Server/Toolkit/Start) using Eio instead of Lwt: WIP: Transition to eio (version with Eliom_stream) by balat · Pull Request #846 · ocsigen/eliom · GitHub

nice! hope it merged soon. :wink: