aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/application/application.ml20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/application/application.ml b/lib/application/application.ml
index 63e12ba..789bd80 100755
--- a/lib/application/application.ml
+++ b/lib/application/application.ml
@@ -12,18 +12,34 @@
[
type state = { value : int }
- (** Increment the state *)
+ (** Increment the state. *)
module Incr = struct
type t = unit
let update () state = { value = state.value + 1 }
end
+ (** Decrement the state. *)
+ module Incr = struct
+ type t = unit
+
+ let update () state = { value = state.value - 1 }
+ end
+
module App = Make(struct type t = state end)
- (* Create the event itself *)
+ (* Create the events *)
let incr_event = App.E ((), (module Incr:App.Event with type t = Incr.t))
+ let decr_event = App.E ((), (module Decr:App.Event with type t = Decr.t))
+
+ let init = { value = 0 } in
+ (* Run the main loop *)
+ let state = App.run
+ init
+ (E.select
+ [ incr_event
+ ; decr_event ] ) in …
]
*)