reflex-gi-gtk-0.2.0.0: Helper functions to use reflex with gi-gtk
CopyrightSven Bartscher 2020
LicenseMPL-2.0
Maintainersven.bartscher@weltraumschlangen.de
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Reflex.GI.Gtk.Run

Description

This module provides a monadic context for predictably executing IO actions that need acces to the GTK context (basically everything from Gtk and similar) in situations where code is executed in a different thread than the GTK thread.

Synopsis

Documentation

class MonadIO m => MonadRunGtk m where Source #

Typeclass for Monads that give the ability to run IO actions in the proper context for calling GTK functions. Most notably, this means that the IO action is run in the thread that GTK was initialized in.

Minimal complete definition

runGtk_, runGtkPromise

Methods

runGtk :: IO a -> m a Source #

Execute the given IO action in the correct context for calling GTK actions. This might mean executing the action in a different thread if the current thread is not the GTK thread, but it might also mean executing the action in the current thread if the current thread is the GTK thread.

runGtk_ :: IO a -> m () Source #

Like runGtk but does not return the result of the executed action and will not wait for the action to finish executing if it is run in a different thread.

Note that it is not precisely specified under which circumstances will be executed asynchronously in a different thread or synchronously in the current thread, so you should either account for both possibilities or use runGtk to always wait synchronously wait for the action to finish.

runGtkPromise :: IO a -> m (m a) Source #

Like runGtk but does not wait for the IO action to finish executing. Instead it returns another monadic action that waits for the action to finish and returns its result.

Note that just as with runGtk_ it is not exactly specified under which circumstances the action will be run asynchronously or synchronously. You should either account for both cases or use runGtk to always wait for the action to finish.

Instances

Instances details
MonadRunGtk m => MonadRunGtk (ReaderT r m) Source # 
Instance details

Defined in Reflex.GI.Gtk.Run.Class

Methods

runGtk :: IO a -> ReaderT r m a Source #

runGtk_ :: IO a -> ReaderT r m () Source #

runGtkPromise :: IO a -> ReaderT r m (ReaderT r m a) Source #

MonadRunGtk m => MonadRunGtk (PostBuildT t m) Source # 
Instance details

Defined in Reflex.GI.Gtk.Run.Class

Methods

runGtk :: IO a -> PostBuildT t m a Source #

runGtk_ :: IO a -> PostBuildT t m () Source #

runGtkPromise :: IO a -> PostBuildT t m (PostBuildT t m a) Source #

MonadRunGtk m => MonadRunGtk (TriggerEventT t m) Source # 
Instance details

Defined in Reflex.GI.Gtk.Run.Class

(ReflexHost t, MonadIO (HostFrame t)) => MonadRunGtk (ReflexGtkT t m) Source # 
Instance details

Defined in Reflex.GI.Gtk.Host

Methods

runGtk :: IO a -> ReflexGtkT t m a Source #

runGtk_ :: IO a -> ReflexGtkT t m () Source #

runGtkPromise :: IO a -> ReflexGtkT t m (ReflexGtkT t m a) Source #