opvasger/amr/1.0.0

NOTE: the latest version is 3.1.1

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/opvasger/amr is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 1.0.0 found (32 same-name repos checked); no cached copy. Use another version.

Details

Elm AMR

Automatic message-replay for Elm!

This module records messages that are passed to the update-function during development, and automatically replays them when the program is reloaded:

  • All messages up until the first unrecognized will be replayed - This mitigates jarring app-states that could otherwise cause confusion during development.
  • There is currently no built-in way to reinitialize this kind of program, which means changes to commands sent from init won't be picked up. One way around this is to open the developer-console in the browser, and type localStorage.clear(), assuming you're using localStorage for persistance.

The API requires a few functions:

  1. Encode messages to JSON
  2. Decode messages from JSON
  3. Read JSON-encoded messages from flags
  4. Write JSON-encoded messages to an outgoing port
  5. A tiny script in your HTML to pick up port-output, persisting it somehow

A tiny example can be found here.

Design

On top the stuff described above, this module addresses some of the performance-issues related to recording every single interaction with your application:

  • Messages are encoded exactly once each, mapped to an integer, and then added to an array of integers that represent the sequence of messages update received. Integer-arrays with a mapping from integer to message should be more space-efficient than storing encoded messages directly (and redundantly).
  • Every new message is pre-encoded, when update is called, to speed up cache-writes.

Future Plans

I plan to have message-encoding/decoding be code-generated using static-analysis, distributed as a small CLI/API on NPM.