From 155fec516022d2d5a1343312792dce21f466573a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 6 Sep 2021 10:23:11 +0200 Subject: Update application description --- lib/application/application.ml | 20 ++++++++++++++++++-- 1 file 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 … ] *) -- cgit v1.2.3