diff options
author | Camil Staps | 2019-10-22 14:52:47 +0200 |
---|---|---|
committer | Camil Staps | 2019-10-22 14:52:47 +0200 |
commit | dc004b45f8b499a4c35b08f8e18f641354f9b9d1 (patch) | |
tree | 4d82f92169922662299c51772e8e4cc62d9390d9 /src/Gtk/State.dcl | |
parent | Alphabetic order in Gtk.Widgets (diff) |
Add custom GtkM state monad with a bind that does not grow the stack
Diffstat (limited to 'src/Gtk/State.dcl')
-rw-r--r-- | src/Gtk/State.dcl | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Gtk/State.dcl b/src/Gtk/State.dcl index e97f3d3..2a5396c 100644 --- a/src/Gtk/State.dcl +++ b/src/Gtk/State.dcl @@ -2,11 +2,9 @@ definition module Gtk.State from StdMaybe import :: Maybe -from Control.Applicative import class pure -from Control.Monad.State import :: State, :: StateT, - instance pure (StateT m s) -from Control.Monad.Identity import :: Identity, - instance pure Identity +from Control.Applicative import class pure, class <*>, class Applicative +from Control.Monad import class Monad +from Data.Functor import class Functor from Data.Map import :: Map from Gtk.Signal import :: GSignalHandlerInternal @@ -18,12 +16,22 @@ from Gtk.Signal import :: GSignalHandlerInternal , signal_counter :: !Int } -:: GtkM a :== State GtkState a +:: GtkM a =: GtkM (GtkState -> (a, GtkState)) + +instance Functor GtkM +instance pure GtkM +instance <*> GtkM +instance Monad GtkM +where + (>>|) infixl 1 :: (GtkM a) (GtkM b) -> GtkM b newGtkState :: GtkState runGtk :: !(GtkM a) !*World -> (!a, !*World) +getState :: GtkM GtkState +modState :: !(GtkState -> GtkState) -> GtkM GtkState + toState :: !(A.a: a -> a) -> GtkM () toStateR :: !(A.a: a -> (r,a)) -> GtkM r |