definition module Gtk.Shares /** * This module provides shares in the `GtkM` monad, allowing the programmer to * abstract from global state. They are loosely based on SDSs in iTasks, but * much less advanced. */ from Gtk.State import :: GtkM //* Identifier of a share. :: ShareId :== String //* Exported to have a TC instance --- do not use directly! :: Shared a :== (String,a) //* Types must instantiate this class to be able to be shared. class shared a | TC a //* Sets up a share with a default value (cf. iTasks' `sharedStore`). share :: !ShareId a -> Shared a | shared a getShared :: !(Shared a) -> GtkM a | shared a setShared :: !(Shared a) !a -> GtkM a | shared a updateShared :: !(a -> a) !(Shared a) -> GtkM a | shared a /** * A share with an initialization function. It will always return the same * value, namely the result of the initialization function, but that function * will only be evaluated once. It can be seen as an impure CAF. */ singletonShared :: !String !(GtkM a) -> GtkM a | shared a //* Evaluate a function with a temporary share. withShared :: a !((Shared a) -> GtkM b) -> GtkM b | shared a