From 28b44802f1961e4df5eec43eb9d345abf514580b Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 21 Oct 2019 08:58:46 +0200 Subject: Add appWorld and accWorld --- src/Gtk/State.icl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/Gtk/State.icl') 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} -- cgit v1.2.3