1OCAML(1)                    General Commands Manual                   OCAML(1)
2
3
4

NAME

6       ocaml - The OCaml interactive toplevel
7
8

SYNOPSIS

10       ocaml [ options ] [ object-files ] [ script-file ]
11

DESCRIPTION

13       The  ocaml(1)  command  is  the toplevel system for OCaml, that permits
14       interactive use of the OCaml system through a read-eval-print loop.  In
15       this  mode,  the  system repeatedly reads OCaml phrases from the input,
16       then typechecks, compiles and evaluates them, then prints the  inferred
17       type  and  result  value,  if  any. The system prints a # (hash) prompt
18       before reading each phrase.
19
20       A toplevel phrase can span several lines. It is  terminated  by  ;;  (a
21       double-semicolon). The syntax of toplevel phrases is as follows.
22
23       The  toplevel  system  is started by the command ocaml(1).  Phrases are
24       read on standard input, results are printed on standard output,  errors
25       on standard error. End-of-file on standard input terminates ocaml(1).
26
27       If  one  or  more object-files (ending in .cmo or .cma) are given, they
28       are loaded silently before starting the toplevel.
29
30       If a script-file is given, phrases are read  silently  from  the  file,
31       errors  printed  on standard error.  ocaml(1) exits after the execution
32       of the last phrase.
33
34

OPTIONS

36       The following command-line options are recognized by ocaml(1).
37
38       -absname
39              Show absolute filenames in error messages.
40
41       -I directory
42              Add the given directory to the list of directories searched  for
43              source  and compiled files. By default, the current directory is
44              searched first, then the standard library directory. Directories
45              added  with  -I are searched after the current directory, in the
46              order in which they were given on the command line,  but  before
47              the standard library directory.
48
49              If  the  given  directory starts with +, it is taken relative to
50              the standard library directory. For instance,  -I +compiler-libs
51              adds  the  subdirectory compiler-libs of the standard library to
52              the search path.
53
54              Directories can also be  added  to  the  search  path  once  the
55              toplevel is running with the #directory directive.
56
57       -init file
58              Load  the given file instead of the default initialization file.
59              See the "Initialization file" section below.
60
61       -labels
62              Labels are not ignored in types, labels may be used in  applica‐
63              tions,  and labelled parameters can be given in any order.  This
64              is the default.
65
66       -no-app-funct
67              Deactivates the applicative behaviour  of  functors.  With  this
68              option,  each  functor  application  generates  new types in its
69              result and applying the same functor twice to the same  argument
70              yields two incompatible structures.
71
72       -noassert
73              Do  not  compile  assertion  checks.  Note that the special form
74              assert false is always compiled because it is typed specially.
75
76       -noinit
77              Do not load any initialization file.   See  the  "Initialization
78              file" section below.
79
80       -nolabels
81              Ignore  non-optional  labels  in types. Labels cannot be used in
82              applications, and parameter order becomes strict.
83
84       -noprompt
85              Do not display any prompt when waiting for input.
86
87       -nopromptcont
88              Do not display the secondary prompt when waiting  for  continua‐
89              tion  lines in multi-line inputs.  This should be used e.g. when
90              running ocaml(1) in an emacs(1) window.
91
92       -nostdlib
93              Do not include the standard library directory  in  the  list  of
94              directories searched for source and compiled files.
95
96       -open module
97              Opens  the given module before starting the toplevel. If several
98              -open options are given, they are processed in order, just as if
99              the statements open! module1;; ... open! moduleN;; were input.
100
101       -plugin plugin
102              Dynamically  load  the  code of the given plugin (a .cmo or .cma
103              file) in the toplevel.
104
105       -ppx command
106              After parsing, pipe the abstract syntax tree  through  the  pre‐
107              processor  command.   The  module  Ast_mapper(3)  implements the
108              external interface of a preprocessor.
109
110       -principal
111              Check information path during type-checking, to make  sure  that
112              all  types  are derived in a principal way.  When using labelled
113              arguments and/or polymorphic methods, this flag is  required  to
114              ensure  future  versions  of  the compiler will be able to infer
115              types correctly, even if internal algorithms change.   All  pro‐
116              grams  accepted  in  -principal  mode  are  also accepted in the
117              default mode with equivalent types, but different binary  signa‐
118              tures,  and  this  may slow down type checking; yet it is a good
119              idea to use it once before publishing source code.
120
121       -rectypes
122              Allow  arbitrary  recursive  types  during  type-checking.    By
123              default,  only  recursive types where the recursion goes through
124              an object type are supported.
125
126       -safe-string
127              Enforce the separation between types  string and bytes,  thereby
128              making  strings  read-only.  This  will  become the default in a
129              future version of OCaml.
130
131       -short-paths
132              When a type is  visible  under  several  module-paths,  use  the
133              shortest  one  when  printing the type's name in inferred inter‐
134              faces and error and warning messages.
135
136       -stdin Read the standard input as a script file rather than starting an
137              interactive session.
138
139       -strict-sequence
140              Force the left-hand part of each sequence to have type unit.
141
142       -unboxed-types
143              When  a  type is unboxable (i.e. a record with a single argument
144              or a concrete datatype with a single constructor  of  one  argu‐
145              ment) it will be unboxed unless annotated with [@@ocaml.boxed].
146
147       -no-unboxed-types
148              When a type is unboxable  it will be boxed unless annotated with
149              [@@ocaml.unboxed].  This is the default.
150
151       -unsafe
152              Turn bound checking  off  on  array  and  string  accesses  (the
153              v.(i)ands.[i]  constructs).  Programs  compiled with -unsafe are
154              therefore slightly faster, but unsafe: anything  can  happen  if
155              the program accesses an array or string outside of its bounds.
156
157       -unsafe-string
158              Identify  the  types  string and bytes,  thereby  making strings
159              writable. For reasons of backward  compatibility,  this  is  the
160              default setting for the moment, but this will change in a future
161              version of OCaml.
162
163       -version
164              Print version string and exit.
165
166       -vnum  Print short version number and exit.
167
168       -no-version
169              Do not print the version banner at startup.
170
171       -w warning-list
172              Enable or disable warnings according to  the  argument  warning-
173              list.   See  ocamlc(1)  for the syntax of the warning-list argu‐
174              ment.
175
176       -warn-error warning-list
177              Mark as fatal the  warnings  described  by  the  argument  warn‐
178              ing-list.   Note  that  a warning is not triggered (and does not
179              trigger an error) if it is  disabled  by  the  -w  option.   See
180              ocamlc(1) for the syntax of the warning-list argument.
181
182       -warn-help
183              Show the description of all available warning numbers.
184
185       - file Use  file  as  a  script  file  name, even when it starts with a
186              hyphen (-).
187
188       -help or --help
189              Display a short usage summary and exit.
190
191

INITIALIZATION FILE

193       When ocaml(1) is invoked, it will read phrases from  an  initialization
194       file  before giving control to the user. The default file is .ocamlinit
195       in the current directory if it  exists,  otherwise  .ocamlinit  in  the
196       user's  home directory. You can specify a different initialization file
197       by using the -init file option, and  disable  initialization  files  by
198       using the -noinit option.
199
200       Note  that  you  can also use the #use directive to read phrases from a
201       file.
202
203

ENVIRONMENT VARIABLES

205       LC_CTYPE
206              If set to iso_8859_1, accented characters (from the ISO  Latin-1
207              character  set)  in string and character literals are printed as
208              is; otherwise, they are printed as decimal escape sequences.
209
210       TERM   When printing error messages, the toplevel  system  attempts  to
211              underline  visually  the  location of the error. It consults the
212              TERM variable to determines the type of output terminal and look
213              up its capabilities in the terminal database.
214
215

SEE ALSO

217       ocamlc(1), ocamlopt(1), ocamlrun(1).
218       The OCaml user's manual, chapter "The toplevel system".
219
220
221
222                                                                      OCAML(1)
Impressum