Title: Theory / Unimportant / CS / Programming / oCaml / Manual{ / 10 Top level;;
Tags: récupéré computer_to_instruction fromCommandLine hasNotNewEffectReturnsMeaning omitted seen_description
On every note of this deck, unless a note says otherwise:
Page: https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html
Language: ocaml
Chapter: 10

Instruction: ;;
Effect: Terminates an input

Instruction: bar
Effect: execute the script contained in bar and exit
Context: command line
Variables: bar file not ending in .cmo or .cma

Instruction: bar
Effect: load the objects bar in the interpreter immediately after the options are processed
Variables: bar file ending in .cmo or .cma

Instruction: ocaml
Effect: starts ocaml toplevel. Reads file .ocamlinit (in current directory, otherwise in home) if it exists and run it.

Instruction: eof
Effect: halts the program

Instruction: C-c
Effect: parsing, compilation or evaluation of the current phrase is interrupted

Instruction: #! on first line
Effect: Line is ignored

Instruction: omitted
Section: 1

Question: Which module can be used ?
Answer: Modules stated with #load
Page: https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html
Chapter: 10
Section: 3
Context: ocaml
Answer2: Modules given as parameter to ocaml command
Answer3: Standard modules
Answer4: module linked with this toplevel if it was created with ocamlmktop

Instruction: ocamlmktop foo bar_1 ... bar_n
Effect: Create a toplevel with modules bar_i linked
Section: 5

Effect: The output is named foo
Section: 5.1
Abbreviation: -o foo

Fla: -I foo
Effect: Add the given directory to the list of directories searched for compiled object code file
Page: https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html
Prefix: ocaml
Chapter: 10
Section: 5.1

Fla: -custom
Effect: Link in “custom runtime” mode.
Page: https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html
Prefix: ocaml
Chapter: 10
Section: 5.1

Fla: -ccopt foo
Effect: Pass the given option to the C compiler and linker, when linking in “custom runtime” mode.
Page: https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html
Prefix: ocaml
Chapter: 10
Section: 5.1

Fla: -cclib foo
Effect: Pass the -llibname option to the C linker when linking in “custom runtime” mode.
Page: https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html
Prefix: ocaml
Chapter: 10
Section: 5.1

Instruction: #help;;
Effect: Prints a list of all available directives, with corresponding argument type if appropriate.
Section: General

Instruction: #quit;;
Effect: Exit the toplevel loop and terminate the ocaml command.
Section: General

Instruction: #cd "dir-name";;
Effect: Change the current working directory.
Section: Loading codes

Instruction: #directory "dir-name";;
Effect: Add the given directory to the list of directories searched for source and compiled files.
Section: Loading codes

Instruction: #remove_directory "dir-name";;
Effect: Remove the given directory from the list of directories searched for source and compiled files. Do nothing if the list does not contain the given directory.
Section: Loading codes

Instruction: #load "file-name";;
Effect: Load in memory a bytecode object file (.cmo file) or library file (.cma file) produced by the batch compiler ocamlc.
Section: Loading codes

Instruction: #load_rec "file-name";;
Effect: Load in memory a bytecode object file (.cmo file) or library file (.cma file) produced by the batch compiler ocamlc. When loading an object file that depends on other modules which have not been loaded yet, the .cmo files for these modules are searched and loaded as well, recursively. The loading order is not specified.
Section: Loading codes

Instruction: #use "file-name";;
Effect: Read, compile and execute source phrases from the given file. This is textual inclusion: phrases are processed just as if they were typed on standard input. The reading of the file stops at the first error encountered.
Section: Loading codes

Instruction: #mod_use "file-name";;
Effect: Similar to #use but also wrap the code into a top-level module of the same name as capitalized file name without extensions, following semantics of the compiler.
Section: Loading codes

Instruction: #show_class class-path;;
Effect: Print the signature of the corresponding class.
Section: Environment queries

Instruction: #show_class_type class-path;;
Effect: Print the signature of the corresponding class type.
Section: Environment queries

Instruction: #show_exception ident;;
Effect: Print the signature of the corresponding identifier.
Section: Environment queries

Instruction: #show_module module-path;;
Effect: Print the signature of the corresponding module.
Section: Environment queries

Instruction: #show_module_type modtype-path;;
Effect: Print the signature of the corresponding module type.
Section: Environment queries

Instruction: #show_type typeconstr;;
Effect: Print the signature of the corresponding module type.
Section: Environment queries

Instruction: #show_val value-path;;
Effect: Print the signature of the corresponding value.
Section: Environment queries

Instruction: #show ident;;
Effect: Print the signatures of components with name ident in all the above categories.
Section: Environment queries

Instruction: #print_depth n;;
Effect: Limit the printing of values to a maximal depth of n. The parts of values whose depth exceeds n are printed as ... (ellipsis).
Section: Pretty-printing

Instruction: #print_length n;;
Effect: Limit the number of value nodes printed to at most n. Remaining parts of values are printed as ... (ellipsis).
Section: Pretty-printing

Instruction: #remove_printer printer-name;;
Effect: Remove the named function from the table of toplevel printers.
Section: Pretty-printing

Instruction: #trace function-name;;
Effect: After executing this directive, all calls to the function named function-name will be “traced”. That is, the argument and the result are displayed for each call, as well as the exceptions escaping out of the function, raised either by the function itself or by another function it calls. If the function is curried, each argument is printed as it is passed to the function.
Section: Tracing

Instruction: #untrace function-name;;
Effect: Stop tracing the given function.
Section: Tracing

Instruction: #untrace_all;;
Effect: Stop tracing all functions traced so far.
Section: Tracing

Instruction: #labels bool;;
Effect: Ignore labels in function types if argument is false, or switch back to default behaviour (commuting style) if argument is true.
Section: Compiler options

Instruction: #ppx "file-name";;
Effect: After parsing, pipe the abstract syntax tree through the preprocessor command.
Section: Compiler options

Instruction: #principal bool;;
Effect: If the argument is true, check information paths during type-checking, to make sure that all types are derived in a principal way. If the argument is false, do not check information paths.
Section: Compiler options

Instruction: #rectypes;;
Effect: Allow arbitrary recursive types during type-checking. Note: once enabled, this option cannot be disabled because that would lead to unsoundness of the type system.
Section: Compiler options

Instruction: #warn_error "warning-list";;
Effect: Treat as errors the warnings enabled by the argument and as normal warnings the warnings disabled by the argument.
Section: Compiler options

Instruction: #warnings "warning-list";;
Effect: Enable or disable warnings according to the argument.
Section: Compiler options

Instruction: #install_printer printer-name;;
Effect: This directive registers the function named printer-name (a value path) as a printer for values whose types match the argument type of the function. That is, the toplevel loop will call printer-name when it has such a value to print. The printing function printer-name should have type Format.formatter -> t -> unit, where t is the type for the values to be printed, and should output its textual representation for the value of type t on the given formatter, using the functions provided by the Format library. For backward compatibility, printer-name can also have type t -> unit and should then output on the standard formatter, but this usage is deprecated.
Section: 2 Pretty-printing