For some examples, see the transient-examples repository: distributedApps.hs and webapp.hs
The source code can be executed in the commmand line if you have docker installed.
Axiom (the new name of ghcjs-hplay) is also the Web user interface of Transient. The Web functionality of transient will be called Axiom, like the cruise starship of Wall-e. Axiom is made to let you navigate the universe of nodes in the cloud through your browser while you are comfortably seated in your hoverchair.
Unlike his predecessor, hplayground, Axiom has full integration with Transient and can run widgets that run code on the server, the client or both.
Axiom execute browser widgets that are reactive, can be composed monadically and algebraically (applicative, alternative, monoidal..). At the same time they participate in cloud computations. A widget can execute code in the server and, trough the server, in any node on the cloud using the same cloud primitives defined in transient-universe. The example applications include widgets that perform distributed map-reduce and federated chat servers as well as stream fibonacci numbers from server to client and from client to server.
To see how it integrates with Transient and how to create client-server applications, see the web paragraphs of the transient tutorial.
To see how to create client side applications and widgets (with no server code integration), look for hplayground package. Tutorial
How it works
The JS program compiled with GHCJS is sent to the browser, then it opens a websockets connection. Then the most useful primitive is
atRemote wich execute his argument in the server and return the result back to the client (or viceversa, see below). The communication transport the variables necessary for executing the computation remotely. There is no explicit serialization neither communication. All is done implicitly.
atRemote can be executed inside itself, so a computation can jump from server to client and back. So a browser can be controlled by the server or the other way aroud. But the execution starts in the browser. There is very little data to transport to execute remotely. In the other side, streaming and reactivity in both directions is included with no additional considerations with
atRemote and other primitives. Isn't awesome?
In the other side, there is an experimental template editor to generate static HTML templates. The server can execute a rest route and bring the corresponding page template and the JS code to the browser, so web crawlers can find something to read.
Also in Axiom everithing compose algebraically with standard applicative, alternative and monoidal operators, and also monadically:
Larger widgets can be composed with algebraic combinations of smaller widgets. No limits. Widgets can have server side (they can use
atRemote) so they are full stack, autonomous pieces down to the cloud. They make perfect software components.
Events do not bubble up to the top like in the case of React. An event within a widget produce a monadic response that executes widgets down trough the monad without affecting the surrounding rendering not affected by the event. That is why Axiom does not need a Virtual DOM, and the logic of the application and the execution flow match, so it produces a clean and understandable code. look at the TODO app (it is client-side only)
Axiom also implement widgets that works as spreadsheet cells, with formulas depending on other cells. These formulas can be executed in the server, so they have full access to databases, mumber crunching, map-reduce etc. This functionality need some testing.
Axiom is in the process of becoming a Server-side as well as Client-side library for creating Web application. The last release support page templates for the creation of server-side content.
In the future it will manage routes in the server side besides client side, and will generate dinamic HTML content in the server as well as in the client.