diff options
author | Camil Staps | 2019-11-01 18:41:10 +0100 |
---|---|---|
committer | Camil Staps | 2019-11-01 18:41:10 +0100 |
commit | 0497dfb79211aa1e64304fa446d230c41ca73daa (patch) | |
tree | cc29910a32b81db4430aff1a74172174039e9c25 /src/Gtk/Shares.dcl | |
parent | Remove dependency on supporting C code (diff) |
Cleanup and add documentation
Diffstat (limited to 'src/Gtk/Shares.dcl')
-rw-r--r-- | src/Gtk/Shares.dcl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Gtk/Shares.dcl b/src/Gtk/Shares.dcl index d1e5556..48db8eb 100644 --- a/src/Gtk/Shares.dcl +++ b/src/Gtk/Shares.dcl @@ -1,20 +1,35 @@ 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! +//* 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 |