Dynamic and static compilation
I will explain how the compilation of yi works and how the dynamic configurations tie into this.
Dynamic configurations
Yi is basically a library which you can use to build your own editor. The configuration file is a perfectly valid haskell file which must be compiled like any other haskell file. In this file you can specify what you want your Yi to look like. You can even completely change the editor to the point that it would not be recognizable as Yi.
For this to work you need to recompile your configuration file (and also dependencies like Yi itself) for every change you make. The dynamic configurations use dyre to try to automate this process.
When a dynamic configuration starts it checks if ~/.config/yi/yi.hs
has been changed and recompiles it if it has been changed. It is also possible to manually trigger recompilation by running the reload command (M-x-reload
in the emacs and :reload
in the vim keymap), this will recompile ~/.config/yi/yi.hs
and then transfer the current state to the newly compiled Yi.
To achieve dynamic recompilation you have to kickstart the process by compiling a dynamic configuration manually first. The default yi package is a static configuration so it won’t check for changes out of the box.
Static configurations
The static configurations are more obvious in that there is no automatic recompilation so you always know exactly what version of Yi you are using. Static configurations also allow for a complete cabal project to be your configuration. The advantages of a complete cabal project is that you can have dependencies other than just Yi.
Why switch?
The dyre package that is used to provide this dynamic recompilation is derived from the way that xmonad handles recompilation. Xmonad is a window manager so it’s not restarted very often and it is inconvenient to restart so I think dynamic recompilation is very useful in that case. But Yi is a text editor and I personally restart my text editor very often so I think that Yi should not use a dynamic recompilations system unless it is very intuitive and stable.
The future
I think dynamic configurations are awesome and should be used in the future, but right now there are a few issues:
- You can’t use a complete cabal project as configuration.
- Errors in the compilation process are not handeled smoothly and can even leave Yi in a broken state.
- There’s no user friendly way to configure the dynamic recompilation (e.g. where the configuration file is located).
It would also be nice to have a subset of the configuration in a DSL to allow for seamless configuration. It should be possible to change for example the font size without recompiling the entire editor. We could use dhall for this.