[Haskell-cafe] Hot-Swap with Haskell

Andy Stewart lazycat.manatee at gmail.com
Fri Jul 16 07:35:56 EDT 2010

Thomas Schilling <nominolo at googlemail.com> writes:

> What would be the semantics of hot-swapping?  For, example, somewhere
> in memory you have a thunk of expression e.  Now the user wants to
> upgrade e to e'.  Would you require all thunks to be modified?  A
> similar problem occurs with stack frames.
> You'd also have to make sure that e and e' have the same (or
> compatible types).  e' most likely has different free variables than
> e, how can you translate thunk one to the other?
> Now assuming you don't try to do this, how would you handle the case
> when something goes wrong?
Good question.

Infact, currently, i just use same technology with Yi/XMonad.
Re-compile modules, and save some initial state before re-launch, and
do re-execute some command to re-store those state after re-launch. 

Re-compile will drop old code, and restore state in new code.
But re-compile solution not neat way since some state will lost.

About your "upgrade expression" question, i haven no answer, that's why i
post this topic to looking for a better solution.

I know Emacs use some "indirection symbol table" for hot-swapping, but
it's not safe since it not do type-check.

Maybe we can wrap 'Dynamic' check type for safe re-load in runtime,
if type match then upgrade, otherwise stop upgrade and
keep old state.

I just test re-compile technology, not try dynamic linking/load
technology that Dons introduce in "Plugging Haskell In.pdf" since 'plugins'
package is broken at the moment.

Anyway, i believe this have a neat way to make static typing language
can extension dynamic.

Now, i'm reading Dons' new paper "Dynamic Extension of Typed Functional
Languages" (http://www.cse.unsw.edu.au/~dons/papers/dons-phd-thesis.pdf)

I hope i can find answer after read this paper...

Any discuss are welcome!

  -- Andy

> On 16 July 2010 04:05, Andy Stewart <lazycat.manatee at gmail.com> wrote:
>> 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"
>> technology:
>>   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
>> re-compile/reboot.
>> Thanks,
>>  -- Andy
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list