
Hi,
This is no longer a problem I managed to get this working by adding the
following lines:
updater <- mkUpdater (cGetTime clock) (return () `stepper` quitOnDestory
windowDestroy)
idleAdd (updater >> return True)
Levi
On Mon, Nov 24, 2008 at 10:30 PM, Levi Stephen
Hi,
I'm trying to set up a simple program combining Reactive and GTK. I have the program below so far, but mainQuit is never called. After looking at a couple of adapters I tried adding the commented out line, but this didn't work for me.
I'm sure I've probably missed something, but I'm not sure what.
Thanks, Levi
main = do initGUI
clock <- makeClock
(windowDestroy, sink) <- makeEvent clock
w <- windowNew w `onDestroy` sink () widgetShowAll w
-- forkE (tSync clock) $ quitOnDestroy windowDestroy
mainGUI
quitOnDestroy :: Event () -> Event (IO ()) quitOnDestroy e = fmap (const mainQuit) e
tSync :: Clock TimeT-> ITime -> IO () tSync clock t = sleepPast (cGetTime clock) (exact t)

On 26 Nov 2008, at 22:50, Levi Stephen wrote:
Hi,
This is no longer a problem I managed to get this working by adding the following lines:
updater <- mkUpdater (cGetTime clock) (return () `stepper` quitOnDestory windowDestroy)
idleAdd (updater >> return True)
Excellent! I look forward to seeing a release of reactive-gtk some time, it'd be lovely to be able to program "proper" GUIs in a truely functional way. Bob

On Thu, Nov 27, 2008 at 8:26 AM, Thomas Davie
On 26 Nov 2008, at 22:50, Levi Stephen wrote:
Hi,
This is no longer a problem I managed to get this working by adding the following lines:
updater <- mkUpdater (cGetTime clock) (return () `stepper` quitOnDestory windowDestroy)
idleAdd (updater >> return True)
Excellent! I look forward to seeing a release of reactive-gtk some time, it'd be lovely to be able to program "proper" GUIs in a truely functional way.
Bob
Just don't hold your breath ;) My project is more to develop an app, but I'm experimenting with using reactive and gtk together. Hopefully something like reactive-gtk could come out of it, but that isn't what I'm aiming for atm. If anything useful does turn up, I will package it though. In particular, I'm not sure what the best way to represent GUIs in a reactive program is. Currently I'm just using an approach similar to the above, where any GTK event is 'wrapped' using makeEvent to create a reactive Event. I hope to get a better idea of what the best way is as I proceed and refactor as I go. Levi

If you're curious about functional approaches to GUIs, check out the
following:
- http://haskell.org/haskellwiki/Phooey
- http://haskell.org/haskellwiki/TV
- http://haskell.org/haskellwiki/Eros
- http://haskell.org/haskellwiki/Grapefruit
I'm very interested in making more progress in this area.
- Conal
2008/11/26 Levi Stephen
On Thu, Nov 27, 2008 at 8:26 AM, Thomas Davie
wrote: On 26 Nov 2008, at 22:50, Levi Stephen wrote:
Hi,
This is no longer a problem I managed to get this working by adding the following lines:
updater <- mkUpdater (cGetTime clock) (return () `stepper` quitOnDestory windowDestroy)
idleAdd (updater >> return True)
Excellent! I look forward to seeing a release of reactive-gtk some time, it'd be lovely to be able to program "proper" GUIs in a truely functional way.
Bob
Just don't hold your breath ;)
My project is more to develop an app, but I'm experimenting with using reactive and gtk together. Hopefully something like reactive-gtk could come out of it, but that isn't what I'm aiming for atm. If anything useful does turn up, I will package it though.
In particular, I'm not sure what the best way to represent GUIs in a reactive program is. Currently I'm just using an approach similar to the above, where any GTK event is 'wrapped' using makeEvent to create a reactive Event. I hope to get a better idea of what the best way is as I proceed and refactor as I go.
Levi
_______________________________________________ Reactive mailing list Reactive@haskell.org http://www.haskell.org/mailman/listinfo/reactive

I'm glad you got it sorted out. Thanks for sharing the answer with us.
We'll get a rationale & useful set of tools together, sooner or later.
- Conal
2008/11/26 Levi Stephen
Hi,
This is no longer a problem I managed to get this working by adding the following lines:
updater <- mkUpdater (cGetTime clock) (return () `stepper` quitOnDestory windowDestroy)
idleAdd (updater >> return True)
Levi
On Mon, Nov 24, 2008 at 10:30 PM, Levi Stephen
wrote: Hi,
I'm trying to set up a simple program combining Reactive and GTK. I have the program below so far, but mainQuit is never called. After looking at a couple of adapters I tried adding the commented out line, but this didn't work for me.
I'm sure I've probably missed something, but I'm not sure what.
Thanks, Levi
main = do initGUI
clock <- makeClock
(windowDestroy, sink) <- makeEvent clock
w <- windowNew w `onDestroy` sink () widgetShowAll w
-- forkE (tSync clock) $ quitOnDestroy windowDestroy
mainGUI
quitOnDestroy :: Event () -> Event (IO ()) quitOnDestroy e = fmap (const mainQuit) e
tSync :: Clock TimeT-> ITime -> IO () tSync clock t = sleepPast (cGetTime clock) (exact t)
_______________________________________________ Reactive mailing list Reactive@haskell.org http://www.haskell.org/mailman/listinfo/reactive
participants (3)
-
Conal Elliott
-
Levi Stephen
-
Thomas Davie