OchaCaml: shift/reset-extension of Caml Light

September 16, 2017

What is OchaCaml

OchaCaml is a Caml Light system extended with delimited control operators, shift and reset. It supports the let-polymorphic type system with answer type modification.

Added Features

reset (fun () -> M)
Delimit the context of M.
shift (fun k -> M)
Clear the current delimited continuation, bind it to k, and execute M. The captured continuation k becomes answer-type polymorphic in M. If the argument of shift is not textually a function, the captured continuation becomes monomorphic.
S / A -> T / B
This is a type of a function from S to T whose answer types changes from A to B when executed. When a function is pure (i.e., its answer types are polymorphic), it is written as S -> T.
#answer "none" (default)
Suppress displaying answer types. A non-pure function type S / A -> T / B is written as S => T.
#answer "all"
Display all the answer types.
No control effects at the toplevel
The toplevel expressions must be pure. It is prohibited to execute shift without enclosing reset. (Executing shift (fun k -> k 0) at the toplevel results in a failure.)



We are developing OchaCaml on: It is reported that OchaCaml runs in the following environments: Any reports (bugs, the environments you could or could not run OchaCaml, comments) are welcome!


If you are using homebrew, you can install ochacaml simply by:
brew install ymyzk/ymyzk/ochacaml

Other Implementations of Shift/Reset



Appendix: Quick Difference between Caml Light and OCaml

Every definition requires ";;" at the end.
load "file.ml"
Load a file file.ml. Double quotation is required. One can omit the extension .ml.
To access a variable var in a file (a module) module.ml, one connects the module name and a variable name with a double underscore __.
It is a predefined keyword that turns an infix operator into a prefix operator.
type synonyms
type t = ... is used to define variant and record types only. To define a type synonym, use type t == ... instead.
cf. Online Caml Light manual.

This document was translated from LATEX by HEVEA.