[Haskell-cafe] Managing state between client/server (frontend/backend)

Clinton Mead clintonmead at gmail.com
Sun Jan 2 08:29:32 UTC 2022


A happy new year to all the Haskell community.

My current role involves an app with a Scala backend and a React/Redux
Javascript frontend. What should be quite simple tasks are made
difficult/impossible, firstly by the fact if you even touch a Javascript
codebase in any significant way you break the code in weird and wonderful
ways, which may only be apparent as random runtime errors days, weeks or
months in the future, but another issue is that tracking some bug back from
the browser to the backend and the database is a nightmare because it's far
from obvious what's going on across the language boundary between Scala and
Javascript, particularly as everything is being flattened to JSON across
that boundary.

Anyway, I was thinking of a better way of doing this, and I thought it
would be nice if much of the code was shared between the browser frontend
and backend server though a common datatype, with the frontend just
compiled with GHCJS.

Some of the state to the client could be readonly, and some writable. The
actual details of pushing the data back and forth would be abstracted away
(as much as possible). When the client does writes, it wouldn't need to
wait for the server to process these writes, it could just save these on
the client side state, and send them off to the server to record, but
otherwise continue on.

There's quite a few nuances here I've started to think about (and there's
likely more I haven't thought about) and given that I don't think this idea
is particularly novel, are there any libraries out there that already do
roughly what I'm talking about here? If someone has already thought this
through I don't want to reinvent the wheel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20220102/30c470f0/attachment.html>


More information about the Haskell-Cafe mailing list