gi-gtk-declarative-app-simple-0.4.2: Declarative GTK+ programming in Haskell in the style of Pux.

Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Declarative.App.Simple

Description

A simple application architecture style inspired by PureScript's Pux framework.

Synopsis

Documentation

data App window state event Source #

Describes an state reducer application.

Constructors

App 

Fields

  • update :: state -> event -> Transition state event

    The update function of an application reduces the current state and a new event to a Transition, which decides if and how to transition to the next state.

  • view :: state -> AppView window event

    The view renders a state value as a window, parameterized by the Apps event type.

  • inputs :: [Producer event IO ()]

    Inputs are pipes Producers that feed events into the application.

  • initialState :: state

    The initial state value of the state reduction loop.

type AppView window event = Bin window event Source #

The top-level widget for the view function of an App, requiring a GTK+ Window.

data Transition state event Source #

The result of applying the update function, deciding if and how to transition to the next state.

Constructors

Transition state (IO (Maybe event)) 
Exit

Exit the application.

run Source #

Arguments

:: (Typeable event, IsWindow window, IsBin window) 
=> App window state event

Application to run

-> IO state 

Initialize GTK and run the application in it. This is a convenience function that is highly recommended. If you need more flexibility, e.g. to set up GTK+ yourself, use runLoop instead.

runLoop :: (Typeable event, IsWindow window, IsBin window) => App window state event -> IO state Source #

Run an App. This IO action will loop, so run it in a separate thread using async if you're calling it before the GTK main loop.

    void $ Gtk.init Nothing
    void . async $ do
      runLoop app
      -- In case the run loop exits, quit the main GTK loop.
      Gtk.mainQuit
    Gtk.main