Saved state for activities
- Vorherrschende Sprache
- Haskell
- Sterne
- 1.3k
- Forks
- 201
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Students would like to be able to save the state of their programs and load it back again. They could save games, edit and work with documents in which they record data and manipulate it, and so on. Very exciting!
At face value, this seems impossible to implement, because there is no type class constraint on the state type, meaning that it's opaque to the framework code. and cannot be serialized.
Here's an idea for a solution: automatically derive Generic for all data types, and add wildcard constraints to all functions. This can be done in a source plugin. But here's the problem with that. Even if we can dig around inside state with GHC generics, it can contain first-class functions and infinite data structures, which are not serializable. So this solution doesn't work for all cases. It means you have to be careful what you put in your state if you want to be able to save.
Here's a different idea for a solution: use event logs as the state type. This is the same trick from @nomeata's work on multi-player games, where different clients synchronize their state by consistently replaying logs. But, here's the problem with event logs: they grow over time, and never shrink. That's fine for keeping two clients in sync (at least as long as they remain connected...) but for a long-term saved-game format or something like that, there's unbounded work that must be done to restore a saved state. This is less than ideal.
Is it possible to combine these ideas? Does there exist some way of storing serialized state when it exists, but an event log when it doesn't, and possibly using observable sharing to identify shortcuts in the event log where events that only modify serializable parts of the state can be merged? Maybe. Sounds complicated, but it's worth a thought.
Beitragsleitfaden
Rechercherichtung
Beginne mit der Prüfung der beiden im Issue vorgeschlagenen Ansätze: generische Serialisierung über ein Source-Plugin und die Wiedergabe des Event-Logs. Untersuche, wie sich opaker Zustand, Funktionen erster Klasse, unendliche Datenstrukturen und wachsende Logs auf die einzelnen Ansätze auswirken. Als erledigt gilt die Aufgabe, wenn ein tragfähiges Design dokumentiert oder eindeutig festgestellt wurde, warum die angeforderte Funktion zum Speichern des Zustands nicht umsetzbar ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- haskell
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 20/100