summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2019-10-21 08:58:46 +0200
committerCamil Staps2019-10-21 08:58:46 +0200
commit28b44802f1961e4df5eec43eb9d345abf514580b (patch)
tree4d0692ca5c35cde2a6aed331136ea819319862be
parentAdd fromPtr function; rename ptr to toPtr (to be able to implement "extra" wi... (diff)
Add appWorld and accWorld
-rw-r--r--src/Gtk/State.dcl3
-rw-r--r--src/Gtk/State.icl18
2 files changed, 21 insertions, 0 deletions
diff --git a/src/Gtk/State.dcl b/src/Gtk/State.dcl
index 81373e2..e97f3d3 100644
--- a/src/Gtk/State.dcl
+++ b/src/Gtk/State.dcl
@@ -27,4 +27,7 @@ runGtk :: !(GtkM a) !*World -> (!a, !*World)
toState :: !(A.a: a -> a) -> GtkM ()
toStateR :: !(A.a: a -> (r,a)) -> GtkM r
+appWorld :: !(*World -> *World) -> GtkM ()
+accWorld :: !(*World -> (r,*World)) -> GtkM r
+
quit :: GtkM ()
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}