Programming game semantics: Concurrent MiniOCaml
This webpage is an implementation of a translation from Concurrent Mini-OCaml to event structures. In the textarea below, you can enter some concurrent OCaml code and explore the resulting event structure.
- Supported OCaml constructs: All the functional part (functions, sum types, products, records). No named/optional arguments. For datatypes, only integers, strings and sum types. (In particular: no float). There is no polymorphism support: please constraint the types of your term to ensure that there are no universal quantification.
- Functions available: The OCaml code is interpreted
without access to any of the standard library
(even Pervasives). We provide the following "standard library"
(* Type of integer references *) type var = {get: unit -> int; set: int -> unit} (* Create a reference *) val var : string -> int -> var (* Spawns a computation, returns a waiter function: [spawn f] spawns [f()] in the background which returns when the call to f does. *) val spawn : (unit -> 'a) -> unit -> 'a (* Reference access *) val ( ! ) : var -> int val ( := ) : var -> int -> unit (* Computation that never converges *) val bottom : unit -> 'a
The semantics is different from the usual OCaml semantics. Everything that can be evaluated in parallel will be evaluated in parallel (tuples, applications).
- Conflict is a blue dotted line.
- Red events are Context events and green events Program events; stars (*) are internal events
- The event structure is computed incrementally:
Underlined text can be clicked to trigger the next step of
the computation. More precisely, certain areas in
Player moves (in green) are underlined and can be clicked.
- Program calls are underlined: This means the program has call an external function. Clicking on Call simulates the context terminating this function call.
- Program closures using in return values or arguments are also underlined. Clicking them simulates calling this closure.
- This has only been tested with Chromium and Firefox
- When using types on the interface which are not simple (product, arrow, constants), then the interface to provide arguments might not function as intended, in particular it might ask you to enter a complete value of that type, instead of a constructor (as in the sense of the submission).
- It is possible to use polymorphic functions, but the same problem applies: the interface to input values will work but ignore the type
- There might be stack overflows in the examples with references. This is hard to predict, and when having stack overflows, it might be necessary to try again or even to reopen the tabs. It seems to work better on Chromium.
Input code
Results: