[Haskell-cafe] Re: Hot-Swap with Haskell
lazycat.manatee at gmail.com
Fri Jul 16 00:06:02 EDT 2010
Don Stewart <dons at galois.com> writes:
>> Hi all,
>> I'm research to build a hot-swap Haskell program to developing itself in
>> Runtime, like Emacs.
>> Essentially, Yi/Xmonad/dyre solution is "replace currently executing"
>> re-compile new code with new binary entry
>> when re-compile success
>> $ do
>> save state before re-launch new entry
>> replace current entry with new binary entry (executeFile)
>> store state after re-launch new entry
>> There are some problems with re-compile solution:
>> 1) You can't save *all* state with some FFI code, such as gtk2hs, you
>> can't save state of GTK+ widget. You will lost some state after
>> re-launch new entry.
>> 2) Sometimes re-execute is un-acceptable, example, you running some command
>> in temrinal before you re-compile, you need re-execute command to
>> restore state after re-launch, in this situation re-execute command is un-acceptable.
>> I wonder have a better way that hot-swapping new code without
> Well, the other approach to reloadable modules, using either object code
> plugins, or bytecode plugins, giving you module-level granularity.
Thanks for your reply.
I have read your papers : "Dynamic Application From the Group Up" and "Plugging Haskell In"
In "Dynamic Application From the Group Up", you introduction how to use
re-compile technology implement source-code level hot-swapping.
In "Plugging Haskell In", you introduction to how to buld hot-swapping
with object-code level.
Yes, Dynamic linking can add new code to a running program, but how to
replace existing binding with new ones?
Looks you still need some reboot when you do *replace* and not just *add*.
Infact, reboot is okay, only problem is *keep state*, some *static state*
is easier to re-build, example, if you want restore editor buffer state, you
just need save (filepath, cursorPosition), you can re-open file and
restore cursor position after reboot process.
Difficult is *Stream State*, such as:
delete operation in file-manager
command running in temrinal
network communications in browser
It's really difficult to restore those state, and re-execute is
You can found the screenshot of my project at http://www.flickr.com/photos/48809572@N02/
Currently, the closest library to implement dynamic linking is your
plugins package (http://hackage.haskell.org/package/plugins-1.4.1),
i really want to write some code to test it, unfortunately, it's
broken with Cabal-220.127.116.11 that can't compile with ghc-6.12.x/ghc-6.12.3,
can you fix it if you have time? It's so great package...
I'm looking for some paper about "Haskell and hot-swapping".
Any paper or suggestion are welcome!
More information about the Haskell-Cafe