lazycat,<div><br></div><div>You may find the following link useful, as it talks about much the same approach.</div><div><br></div><div><a href="http://nathanwiegand.com/wp/2010/02/hot-swapping-binaries/">http://nathanwiegand.com/wp/2010/02/hot-swapping-binaries/</a></div>
<div><br></div><div>Sadly, any hot-swap mechanism is going to suffer from the potential loss of state where that state is not controlled by your code. </div><div><br></div><div>When that loss of state isn&#39;t acceptable you have a few mechanisms available. </div>
<div><br></div><div>By far the easiest, I think, in the gtk2hs scenario you mention is that you could refactor all of the code that interoperated with gtk2hs into another process and spawn it, communicating with it over a pipe or other communication mechanism. That way hot-swapping the current process would leave your GUI (and the pipe/IPC mechanism) intact. </div>
<div><br></div><div>You may then need to pass along whatever changes affect the gui over the pipe in a fairly manual fashion.</div><div><br></div><div>-Edward Kmett</div><div><br><div class="gmail_quote">On Thu, Jul 15, 2010 at 11:05 PM, Andy Stewart <span dir="ltr">&lt;<a href="mailto:lazycat.manatee@gmail.com">lazycat.manatee@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi all,<br>
<br>
I&#39;m research to build a hot-swap Haskell program to developing itself in<br>
Runtime, like Emacs.<br>
<br>
Essentially, Yi/Xmonad/dyre solution is &quot;replace currently executing&quot;<br>
technology:<br>
<br>
   re-compile new code with new binary entry<br>
<br>
   when re-compile success<br>
      $ do<br>
          save state before re-launch new entry<br>
          replace current entry with new binary entry (executeFile)<br>
          store state after re-launch new entry<br>
<br>
There are some problems with re-compile solution:<br>
<br>
1) You can&#39;t save *all* state with some FFI code, such as gtk2hs, you<br>
can&#39;t save state of GTK+ widget. You will lost some state after<br>
re-launch new entry.<br>
<br>
2) Sometimes re-execute is un-acceptable, example, you running some command<br>
in temrinal before you re-compile, you need re-execute command to<br>
restore state after re-launch, in this situation re-execute command is un-acceptable.<br>
<br>
I wonder have a better way that hot-swapping new code without<br>
re-compile/reboot.<br>
<br>
Thanks,<br>
<br>
  -- Andy<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>