The eternal text editor — Didactic Ersatz Emacs demonstrating immutable data-structures and the single-atom architecture.
/plugin marketplace add plurigrid/asi/plugin install plurigrid-asi-skills@plurigrid/asiThis skill inherits all available tools. When active, it can use any tool Claude has access to.
The eternal text editor — Didactic Ersatz Emacs demonstrating immutable data-structures and the single-atom architecture.
Ewig demonstrates how to build a text editor using:
// Single atom state
atom<editor_state> state;
// All mutations are pure transformations
state.update([](editor_state s) {
return s.insert_char('x'); // Returns new state, doesn't mutate
});
┌─────────────────────────────────────────────────────┐
│ Ewig │
├─────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Single Atom │ │
│ │ (immutable editor_state) │ │
│ └─────────────────────────────────────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────┐ ┌─────────┐ │
│ │ immer │ structural │ lager │ │
│ │ vectors │ sharing │ cursors │ │
│ └─────────┘ └─────────┘ │
│ │
└─────────────────────────────────────────────────────┘
Persistent immutable data structures for C++:
#include <immer/vector.hpp>
immer::vector<char> buffer = {'h', 'e', 'l', 'l', 'o'};
auto new_buffer = buffer.push_back('!'); // O(log n), shares structure
Unidirectional data-flow architecture:
auto store = lager::make_store<action>(
model{},
lager::with_reducer(update),
lager::with_effect(effect)
);
Ewig's immutable architecture aligns with CRDT principles:
| Ewig Concept | CRDT Parallel |
|---|---|
| Immutable state | Operation-based CRDT |
| Structural sharing | Delta-state CRDT |
| Single atom | Causal consistency |
| Pure transformations | Commutative operations |
The single-atom pattern can be applied to terminal state:
// Terminal state as immutable atom
struct terminal_state {
immer::flex_vector<line> lines;
cursor_pos cursor;
gf3_trit trit; // GF(3) assignment
};
atom<terminal_state> term_state;
git clone https://github.com/bmorphism/ewig
cd ewig
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
./ewig
code-refactoring - Immutable refactoring patternsbisimulation-game - State equivalencegay-mcp - Deterministic UI coloring