ChrisPenner / rasa

Extremely modular text editor built in Haskell
GNU General Public License v3.0
614 stars 42 forks source link

Lifting Actions inside BufAction #31

Closed ChrisPenner closed 7 years ago

ChrisPenner commented 7 years ago

liftAction is implemented and allows running Action inside BufAction; but leaves some things to be desired. Currently the idea is that a Buffer is focused alongside the current editor state; any BufActions that affect the buffer affect the 'COPY' of the buffer that's held alongside the editor state without actually effecting the buffer contained inside the Editor state. After executing the BufAction the Buffer in the Editor state is replaced with the copy. This allows things to get out of sync in situations where events are dispatched inside a BufAction using liftAction.

The plan to fix this is to change all lenses which access a buffer through the HasBuffer constraint into Lens Traversals; and then to rely on the ExceptT result from traversals to handle errors if a BufAction deletes the buffer it's operating on, or if something goes funny inside a dispatched action.

Should hopefully work out nicely; but I'm new to ExceptT so we'll see how it goes.

clojj commented 7 years ago

Does this impact performance negatively ? btw, I did work around that out-of-sync buffer by using the seq function (from base) If the updated buffer is not needed in dispatch, maybe this problem is not critical at all ?

ChrisPenner commented 7 years ago

These issues should be fixed now that we've switched to free-monads; let me know if problems persist.