Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
OchaCaml: shift/reset-extension of Caml Light
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.)
Limitations
-
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.
Environments
We are developing OchaCaml on:
-
MacOSX 10.6 - 10.9 (64bit, Intel).
It is reported that OchaCaml runs in the following environments:
-
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
Any reports (bugs, the environments you could or could not run
OchaCaml, comments) are welcome!
Download/Compile
If you are using homebrew, you can install ochacaml simply by:
brew install ymyzk/ymyzk/ochacaml
Otherwise:
-
Download
Caml Light 0.75.
- Expand it:
tar xpfvz cl75unix.tar.gz
- Download the latest release of
OchaCaml.
(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:
cd cl75/src
- 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 [];
- Compile:
make configure
make world
- 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
from OPTS.
- 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
environment.
- Launch OchaCaml by executing OchaCaml/ochacaml.
One can also install the shell script ochacaml to an
appropriate place.
Other Implementations of Shift/Reset
Papers
-
Masuko, M., and K. Asai
"Caml Light + shift/reset = Caml Shift,"
Theory and Practice of Delimited Continuations (TPDC 2011),
pp. 33-46 (May 2011).
abstract,
pdf.
- 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).
ACM DL.
- Asai, K. and Y. Kameyama
"Polymorphic Delimited Continuations,"
In Z. Shao editor,
5th Asian Symposium on Programming Languages and Systems (APLAS 2007),
LNCS 4807,
pp. 239-254 (November 2007).
Members
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.
- module__var
-
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 __.
- prefix
-
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.