Closed Boarders closed 3 years ago
This should be fairly trivial to implement in main
using the modules Control.Concurrent.MVar
from base
and System.Posix.Signals
from the unix
package along with the technique described here.
This functionality has been implemented using the technique described above. See 3a1b6bdde273ed4dc09717623986e1144b006904.
Using the bracket function from here we can add the ability to clean up after an operation. If my understanding is correct when the GHC runtime system receives a SIGINT (e.g. if the user hits C-c) this cleanup action will be run.
In discussions with @recursion-ninja we decided on where this should be added so that we have an interrupt handler for the various different evaluate commands. Our idea was roughly that if, for instance, you have done a build command (which should probably be added as a global settings flag) then we save the work. If you are in the middle of reporting output then that finishes (unless the user absolutely does want to stop the program). This would also fit nicely into any more interactive top level we might add in the future.