essence-of-live-coding
essence-of-live-coding copied to clipboard
Refactor cellStep using StateT and lenses?
Recently (#57) it has come up again that in essence, the Cell
constructor could also be declared as:
data Cell m a b = forall s . Data s => Cell
{ cellState :: s
, cellStep :: a -> StateT s m b
}
Is this a good idea?
Advantages
- Potential conceptual clarification
- Code reuse from
transformers
- This might resolve some strictness issues
- Simplifies and clarifies a lot of implementations where state is manually threaded right now
Disadvantages
- One more level of indirection
- Tying to a specific transformer and library
Work to do
- Use lenses (https://hackage.haskell.org/package/lens-5.0.1/docs/Control-Lens-Zoom.html#v:zoom) to implement the different cell manipulation functions
- Check whether the article still works with such changes