ocaml - The OCaml interactive toplevel
ocaml [ options ] [ object-files ] [ script-file ]
The ocaml(1) command is the toplevel system for OCaml, that permits interactive use of the OCaml system through a read-eval-print loop. In this mode, the system repeatedly reads OCaml phrases from the input, then typechecks, compiles and evaluates them, then prints the inferred type and result value, if any. The system prints a # (sharp) prompt before reading each phrase. A toplevel phrase can span several lines. It is terminated by ;; (a double-semicolon). The syntax of toplevel phrases is as follows. The toplevel system is started by the command ocaml(1). Phrases are read on standard input, results are printed on standard output, errors on standard error. End-of-file on standard input terminates ocaml(1). If one or more object-files (ending in .cmo or .cma) are given, they are loaded silently before starting the toplevel. If a script-file is given, phrases are read silently from the file, errors printed on standard error. ocaml(1) exits after the execution of the last phrase.
The following command-line options are recognized by ocaml(1). -absname Show absolute filenames in error messages. -I directory Add the given directory to the list of directories searched for source and compiled files. By default, the current directory is searched first, then the standard library directory. Directories added with -I are searched after the current directory, in the order in which they were given on the command line, but before the standard library directory. If the given directory starts with +, it is taken relative to the standard library directory. For instance, -I +compiler-libs adds the subdirectory compiler-libs of the standard library to the search path. Directories can also be added to the search path once the toplevel is running with the #directory directive. -init file Load the given file instead of the default initialization file. The default file is .ocamlinit in the current directory if it exists, otherwise .ocamlinit in the user's home directory. -labels Labels are not ignored in types, labels may be used in applications, and labelled parameters can be given in any order. This is the default. -no-app-funct Deactivates the applicative behaviour of functors. With this option, each functor application generates new types in its result and applying the same functor twice to the same argument yields two incompatible structures. -noassert Do not compile assertion checks. Note that the special form assert false is always compiled because it is typed specially. -nolabels Ignore non-optional labels in types. Labels cannot be used in applications, and parameter order becomes strict. -noprompt Do not display any prompt when waiting for input. -nopromptcont Do not display the secondary prompt when waiting for continuation lines in multi-line inputs. This should be used e.g. when running ocaml(1) in an emacs(1) window. -nostdlib Do not include the standard library directory in the list of directories searched for source and compiled files. -open module Opens the given module before starting the toplevel. If several -open options are given, they are processed in order, just as if the statements open! module1;; ... open! moduleN;; were input. -ppx command After parsing, pipe the abstract syntax tree through the preprocessor command. The module Ast_mapper(3) implements the external interface of a preprocessor. -principal Check information path during type-checking, to make sure that all types are derived in a principal way. When using labelled arguments and/or polymorphic methods, this flag is required to ensure future versions of the compiler will be able to infer types correctly, even if internal algorithms change. All programs accepted in -principal mode are also accepted in the default mode with equivalent types, but different binary signatures, and this may slow down type checking; yet it is a good idea to use it once before publishing source code. -rectypes Allow arbitrary recursive types during type-checking. By default, only recursive types where the recursion goes through an object type are supported. -safe-string Enforce the separation between types string and bytes, thereby making strings read-only. This will become the default in a future version of OCaml. -short-paths When a type is visible under several module-paths, use the shortest one when printing the type's name in inferred interfaces and error and warning messages. -stdin Read the standard input as a script file rather than starting an interactive session. -strict-sequence Force the left-hand part of each sequence to have type unit. -unsafe Turn bound checking off on array and string accesses (the v.(i)ands.[i] constructs). Programs compiled with -unsafe are therefore slightly faster, but unsafe: anything can happen if the program accesses an array or string outside of its bounds. -unsafe-string Identify the types string and bytes, thereby making strings writable. For reasons of backward compatibility, this is the default setting for the moment, but this will change in a future version of OCaml. -version Print version string and exit. -vnum Print short version number and exit. -w warning-list Enable or disable warnings according to the argument warning- list. See ocamlc(1) for the syntax of the warning-list argument. -warn-error warning-list Mark as fatal the warnings described by the argument warning-list. Note that a warning is not triggered (and does not trigger an error) if it is disabled by the -w option. See ocamlc(1) for the syntax of the warning-list argument. -warn-help Show the description of all available warning numbers. - file Use file as a script file name, even when it starts with a hyphen (-). -help or --help Display a short usage summary and exit.
LC_CTYPE If set to iso_8859_1, accented characters (from the ISO Latin-1 character set) in string and character literals are printed as is; otherwise, they are printed as decimal escape sequences. TERM When printing error messages, the toplevel system attempts to underline visually the location of the error. It consults the TERM variable to determines the type of output terminal and look up its capabilities in the terminal database.
ocamlc(1), ocamlopt(1), ocamlrun(1). The OCaml user's manual, chapter "The toplevel system". OCAML(1)
Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.
Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.
Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.
Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.
The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.
Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.
Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.
Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.