ChrisPenner / rasa

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

Convert Action and BufAction Free monads #32

Closed ChrisPenner closed 7 years ago

ChrisPenner commented 7 years ago

For those who are unfamiliar with free, it's basically a version of a monad which only 'Keeps Track' of the things you'd like to do rather than actually executing them. Even IOs are just stored in a wrapper without being executed. Then once the actions are all sequenced you run them through an 'interpreter' which actually does things based on a mapping from the Action Descriptions to actual functionality.

Re-writing in terms of Free adds a little boilerplate; but gives us much more expressability and power. It allows us to log out ever message we perform; it allows us to "mock out" results from IO calls, and makes testing much simpler.

It is a little more confusing; so if you have questions please ask; but I definitely believe that it's in Rasa's best interests in the long run!