diff --git a/CSM.ml b/CSM.ml index 1865041a..b493994e 100644 --- a/CSM.ml +++ b/CSM.ml @@ -37,8 +37,6 @@ type 'state t = { and 'a sm = 'a t -and 'event sink = 'event -> unit - and 'a transition = | TransitionTo of 'a | TransitionStay @@ -166,7 +164,7 @@ let filter st p = Weak.set a 0 (Some st'); register_while st (fun _ new_state -> - if p + if p new_state then begin match Weak.get a 0 with | None -> false | Some st' -> diff --git a/CSM.mli b/CSM.mli index 6485e38a..64fc693b 100644 --- a/CSM.mli +++ b/CSM.mli @@ -36,9 +36,6 @@ type 'state t (** State machine, whose states are of the type 'state, and that changes state upon events of the type 'event. *) -type 'event sink - (** Something that reacts to events of type 'events *) - type 'a transition = | TransitionTo of 'a | TransitionStay @@ -48,7 +45,7 @@ type 'a transition = val create : ?root:bool -> init:'state -> trans:('state -> 'event -> 'state transition) -> - 'state t * 'event sink + 'state t * ('event -> unit) (** Creation of a state machine with an initial state and a given transition function. [root] specifies whether the FSM should be a GC root and stay alive (default false). @@ -77,15 +74,10 @@ val register_while : 'state t -> ('state -> 'state -> bool) -> unit val register : 'state t -> ('state -> 'state -> unit) -> unit (** Register the given callback forever. *) -val connect : 'a t -> 'a sink -> unit +val connect : 'a t -> ('a -> unit) -> unit (** [connect st sink] connects state changes of [st] to the sink. The sink is given only the new state of [st]. *) -val send : 'event sink -> 'event -> unit - (** Trigger an event. This function will not return until no transitions - remain for processing, which means it can take an arbitrary amount of time to - run. *) - (** {2 Combinators} *) val map : 'a t -> ('a -> 'b) -> 'b t