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
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
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
(Executing shift (fun k -> k 0) at the toplevel
results in a failure.)
Currently, #open directive is not working.
- The type of built-in library functions might be wrong.
- Operator precedence in a type expression is sometimes awkward.
One requires parentheses in:
int / int -> (int * int) / int.
We are developing OchaCaml on:
It is reported that OchaCaml runs in the following environments:
MacOSX 10.6 - 10.9 (64bit, Intel).
Any reports (bugs, the environments you could or could not run
OchaCaml, comments) are welcome!
MacOSX 10.4 (32bit, PowerPC)
- Debian Squeeze for amd64 on VirtualBox
- Ubuntu 11.04 i386 on VirtualBox
(but not on Ubuntu 10.04)
- Cygwin 1.7.9-1
If you are using homebrew, you can install ochacaml simply by:
brew install ymyzk/ymyzk/ochacaml
Caml Light 0.75.
- Expand it:
tar xpfvz cl75unix.tar.gz
- Download the latest release of
(Or see all the versions in the download directory.)
- Expand it:
tar xpfvz OchaCaml.tar.gz
- Apply patch:
patch -p0 < OchaCaml/OchaCaml.diff
- Go to src directory:
- For Cygwin only: Delete two files:
rm camlrun camlyacc
- For Cygwin only: Insert two const
into line 50 of runtime/sys.c to read:
extern const char * const sys_errlist ;
- If sed complains illegal byte sequence,
set the environment variable LANG to ja_JP.eucJP.
- If error occurs, try edit line 12 of
Makefile as follows:
If compilation of arg.mli fails, add
-fno-strict-aliasing to OPTS.
(cf. this page.)
- If gcc complains
"unrecognized option '-no-cpp-precomp'", remove the option
- We do not recommend to run make install, because
OchaCaml is still under heavy development.
Instead, use the following shell script (also in the distribution)
to launch OchaCaml residing in the src directory.
- Adjust the third line of OchaCaml/ochacaml to your
- Launch OchaCaml by executing OchaCaml/ochacaml.
One can also install the shell script ochacaml to an
Other Implementations of Shift/Reset
Masuko, M., and K. Asai
"Caml Light + shift/reset = Caml Shift,"
Theory and Practice of Delimited Continuations (TPDC 2011),
pp. 33-46 (May 2011).
- Masuko, M., and K. Asai
"Direct Implementation of Shift and Reset in the MinCaml Compiler,"
Proceedings of the 2009 ACM SIGPLAN Workshop on ML,
pp. 49-60 (September 2009).
- Asai, K. and Y. Kameyama
"Polymorphic Delimited Continuations,"
In Z. Shao editor,
5th Asian Symposium on Programming Languages and Systems (APLAS 2007),
pp. 239-254 (November 2007).
Appendix: Quick Difference between Caml Light and OCaml
Caml Light manual.
- 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
- type synonyms
type t = ... is used to define variant and record types only.
To define a type synonym, use type t == ... instead.
This document was translated from LATEX by