The eternal text editor — Didactic Ersatz Emacs demonstrating immutable data-structures and the single-atom architecture.
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 coloringSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer