summaryrefslogtreecommitdiff
path: root/src/Gtk/State.icl
diff options
context:
space:
mode:
authorCamil Staps2019-10-21 08:58:46 +0200
committerCamil Staps2019-10-21 08:58:46 +0200
commit28b44802f1961e4df5eec43eb9d345abf514580b (patch)
tree4d0692ca5c35cde2a6aed331136ea819319862be /src/Gtk/State.icl
parentAdd fromPtr function; rename ptr to toPtr (to be able to implement "extra" wi... (diff)
Add appWorld and accWorld
Diffstat (limited to 'src/Gtk/State.icl')
-rw-r--r--src/Gtk/State.icl18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Gtk/State.icl b/src/Gtk/State.icl
index 9d81b9a..245ea7a 100644
--- a/src/Gtk/State.icl
+++ b/src/Gtk/State.icl
@@ -53,5 +53,23 @@ toState f = state \st -> let w = f st.world in ((), {st & world=w})
toStateR :: !(A.a: a -> (r,a)) -> GtkM r
toStateR f = state \st -> let (r,w) = f st.world in (r, {st & world=w})
+appWorld :: !(*World -> *World) -> GtkM ()
+appWorld f = state \st
+ # w = f (voidToWorld st.world)
+ -> ((), {st & world=worldToVoid w})
+
+accWorld :: !(*World -> (r,*World)) -> GtkM r
+accWorld f = state \st
+ # (r,w) = f (voidToWorld st.world)
+ -> (r, {st & world=worldToVoid w})
+
+voidToWorld :: !() -> *World
+voidToWorld _ = code {
+ no_op
+}
+
+worldToVoid :: !*World -> ()
+worldToVoid _ = ()
+
quit :: GtkM ()
quit = modify \st -> {st & return=True}