Saved state for activities
- 主要言語
- Haskell
- スター
- 1.3k
- フォーク
- 201
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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.
コントリビューションガイド
調査の方向性
まず、issue で提案されている 2 つのアプローチ、つまり source plugin による汎用シリアライゼーションとイベントログのリプレイを検討します。各アプローチに対して、不透明な状態、第一級関数、無限データ構造、増大するログがどのような影響を与えるかを調査します。実現可能な設計を文書化するか、要求されている保存状態機能が実現不可能な理由を明確に示せれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- haskell
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 20/100