summaryrefslogtreecommitdiff
path: root/src/Gtk/Shares.icl
diff options
context:
space:
mode:
Diffstat (limited to 'src/Gtk/Shares.icl')
-rw-r--r--src/Gtk/Shares.icl11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Gtk/Shares.icl b/src/Gtk/Shares.icl
index 13a8727..4ff107f 100644
--- a/src/Gtk/Shares.icl
+++ b/src/Gtk/Shares.icl
@@ -34,3 +34,14 @@ setShared (id,_) v =
updateShared :: !(a -> a) !(Shared a) -> GtkM a | shared a
updateShared f shared = getShared shared >>= setShared shared o f
+
+singletonShared :: !String !(GtkM a) -> GtkM a | shared a
+singletonShared name setup =
+ let shr = share name Nothing in
+ getShared shr >>= \val -> case val of
+ Just val ->
+ pure val
+ Nothing ->
+ setup >>= \val ->
+ setShared shr (Just val) >>|
+ pure val