Skip to content

Instantly share code, notes, and snippets.

@prepor
Created December 6, 2016 08:39
Show Gist options
  • Save prepor/ff6541fe9cfb0a18f7f5c59119644dd2 to your computer and use it in GitHub Desktop.
Save prepor/ff6541fe9cfb0a18f7f5c59119644dd2 to your computer and use it in GitHub Desktop.
type state = Init | Started | Stopped
type init_event = InitStart | InitStop
type started_event = StartedStop
type stopped_event = StoppedStart
let init_event () =
List.nth [InitStart; InitStop] (Random.int 1)
let started_event () = StartedStop
let stopped_event () = StoppedStart
let apply = function
| Init -> begin
match init_event () with
| InitStart -> Started
| InitStop -> Stopped end
| Started -> begin
match started_event () with
| StartedStop -> Stopped end
| Stopped -> begin
match stopped_event () with
| StoppedStart -> Started end
let () =
let rec tick s =
tick (apply s) in
tick Init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment