[Haskell-cafe] Any recommendations on how to interact with the running state of a program?

25 views
Skip to first unread message

Anatoly Yakovenko

unread,
May 28, 2015, 2:50:10 PM5/28/15
to haskell
I am playing around with some deep learning algorithms and I need a way to periodically read the intermediate result and change some of the system variables.

Any ideas on how to best approach this problem?  I was thinking of something basic, like having the program periodically read and write from some files.

Thanks,
Anatoly

Anatoly Yakovenko

unread,
May 28, 2015, 9:21:32 PM5/28/15
to haskell
How would the program get updated values?  via an IORef?  This thing is running until the user decides the output looks good

Anatoly

On Thu, May 28, 2015 at 12:16 PM Carlos López-Camey <c.l...@kmels.net> wrote:
Cloud Haskell + Event streaming via some Protocol (like json on websockets) ?


_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe


Charlie Durham

unread,
May 28, 2015, 9:32:39 PM5/28/15
to Anatoly Yakovenko, haskell
Check out the configurator package:

It has auto reloading of config files through the aptly named autoReload function. Pretty cool stuff. 

Charlie

Anatoly Yakovenko

unread,
May 28, 2015, 9:49:16 PM5/28/15
to Charlie Durham, haskell
Cool, thanks.
But the ChangeHandler would still be modifying some mutable state that some other thread is referencing while it's running. That would still be via an IORef?
I guess this is a similar problem as having a play/pause/skip controls to a video player. Is the interface between the "running" thread and the user triggered events an IORef? Or is there some other way to wrap that.
Thanks,
Anatoly

Charlie Durham

unread,
May 28, 2015, 10:23:06 PM5/28/15
to Anatoly Yakovenko, haskell
I think it entirely depends on how you plan to inject the new values into a running program. If you are doing iterations, then it might make sense to do an IOref that contains the entire space of values that may change and then atomically update the whole space when a config update happens. Or maybe you can put each update in a queue inside of an IORef and then do an atomic modify, or I see there is a package providing lockfree queues in hackage. Again, I think it more depends on how you are going about running your program, and where it makes sense to inject new values.

Charlie

Sylvain Henry

unread,
May 29, 2015, 5:04:02 AM5/29/15
to Charlie Durham, haskell
I would use STM to do that (i.e. put the system variables and the intermediate result in some TVars).

Sylvain
Reply all
Reply to author
Forward
0 new messages