package utop
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=f1a5380f9220212747b36e4d9c3e4eed40f2cc24d641a1c4db282842c2a44ccc
    
    
  sha512=123e7df641883d02a2a343b1e257496cddeb459e429022e487c6eec2a049f74ab59dd3ad00c24d282e3ab3609278e7cb800a18d4523bbd56ed5bde400bfcacec
    
    
  doc/utop/UTop/index.html
Module UTop
UTop configuration.
val keywords : Set.Make(String).t refThe set of OCaml keywords.
val get_ui : unit -> uiReturns the user interface in use.
If true (the default) identifiers starting with a '_' will be hidden from the output. i.e. the following phrase won't produces any output:
  let _x = 1This is for hidding variables created by code generators for internal use. It can also be set/unset by the command line options -hide-reserved and -show-reserved.
Returns the value of hide_reserved.
Modifies hide_reserved.
If true (not the default) expressions entered in the toplevel are automatically bound, for example:
  # 3 + 4;;
  _0 : int = 7
  # _0 + 10;;
  _1 : int = 17Returns the value of create_implicits.
Modifies create_implicits.
If false (the default) messages from findlib are hidden. This is only effective with findlib >= 1.4.
Returns the value of topfind_verbose.
Modifies topfind_verbose.
List of messages logged by findlib since the beginning of the session. This requires findlib >= 1.4.
Returns the value of show_box.
Modifies show_box.
val set_margin_function : (LTerm_geom.size -> int option) -> unitMargin of the standard and error formatters as a function of the screen size.
The default is:
  fun size -> Some (min 80 size.cols)The phrase terminator. It is ";;" by default and ";" when you use revised syntax.
Returns the value of phrase_terminator.
Modifies phrase_terminator.
If true (the default) toplevel lwt expressions are automatically run with Lwt_main.run. i.e. if you type:
  Lwt_io.printl "Hello, world"this will be replaced by:
  Lwt_main.run (Lwt_io.printl "Hello, world")Returns the value of auto_run_lwt.
Modifies auto_run_lwt.
If true (the default) toplevel Async expressions are automatically run with in a separate thread with Thread_safe.block_on_async_exn. i.e. if you type:
  after (Time.Span.of_s 1.0)this will be replaced by:
  Thread_safe.block_on_async_exn (fun () -> after (Time.Span.of_s 1.0))Returns the value of auto_run_async.
Modifies auto_run_async.
val end_and_accept_current_phrase : LTerm_read_line.actionAction that add the phrase terminator at the end of the current phrase and accepts it. For instance to avoid typing ;;, add this to your ~/.config/utop/init.ml:
  #require "lambda-term";;
  LTerm_read_line.bind
    [ { control = false; meta = false; shift = false; code = Enter } ]
    [ UTop.end_and_accept_current_phrase ]History
val history : LTerm_history.tThe history used by utop. You can configure limits using the LTerm_history module.
For example if you want to limit the history to 1000 line, add these lines to your ~/.config/utop/init.ml file:
  #require "lambda-term";;
  LTerm_history.set_max_entries UTop.history 1000;;val history_file_name : string option refName of the history file. If None, no history will be loaded or saved.
val history_file_max_size : int option refMaximum size of the history file. If None (the default) the maximum size of history will be used.
val history_file_max_entries : int option refMaximum entries to store in the history file. If None (the default) the maximum number of entries if history will be used.
val stashable_session_history : UTop_history.tA history consisting of inputs and resulting values or errors of the current session. Because stashing is supposed to produce a valid OCaml file which will behave roughly the same as the console, it is best if this history never gets truncated. While this will certainly lead to a slight memory leaking problem, UTop sessions are rarely long enough to make it a serious issue.
Console specific configuration
val profile : profile React.signalThe color profile. It defaults to Dark. This is used by the default prompt to choose colors.
val set_profile : profile -> unitSets the color profile.
val size : LTerm_geom.size React.signalThe current size of the terminal. This is used only in the console UI.
val key_sequence : LTerm_key.t list React.signalThe current key sequence entered by the user. This is used only in the console UI.
val time : float refThe time of the beginning of the current command.
val prompt : LTerm_text.t React.signal refThe prompt.
Edit mode configuration
val edit_mode : LTerm_editor.mode refThe edit mode.
Hooks
val new_command_hooks : (unit -> unit) LTerm_dlist.tFunctions called before each new command.
at_new_command f adds f to the hooks executed before each new commands.
Parsing
Type of a string-location. It is composed of a start and stop offsets (in bytes).
type 'a result = - | Value of 'a(*- The function succeeded and returned this value. *)
- | Error of location list * string(*- The function failed. Arguments are a list of locations to highlight in the source and an error message. *)
Result of a function processing a programx.
val parse_use_file_default : 
  string ->
  bool ->
  Parsetree.toplevel_phrase list resultThe default parser for toplevel regions. It uses the standard ocaml parser.
parse_toplevel_phrase is the function used to parse a phrase typed in the toplevel.
Its arguments are:
- input: the string to parse
- eos_is_error
If eos_is_error is true and the parser reach the end of input, then Parse_failure should be returned.
If eos_is_error is false and the parser reach the end of input, the exception Need_more must be thrown.
Except for Need_more, the function must not raise any exception.
val parse_toplevel_phrase_default : 
  string ->
  bool ->
  Parsetree.toplevel_phrase resultThe default parser for toplevel phrases. It uses the standard ocaml parser.
val parse_default : (Lexing.lexbuf -> 'a) -> string -> bool -> 'a resultThe default parser. It uses the standard ocaml parser.
The name you must use in location to let ocaml know that it is from the toplevel.
val lexbuf_of_string : bool ref -> string -> Lexing.lexbuflexbuf_of_string eof str is the same as Lexing.from_string str except that if the lexer reach the end of str then eof is set to true.
Helpers
val get_message : (Format.formatter -> 'a -> unit) -> 'a -> stringget_message printer x applies printer on x and returns everything it prints as a string.
val get_ocaml_error_message : exn -> location * stringget_ocaml_error_message exn returns the location and error message for the exception exn which must be an exception from the compiler.
val check_phrase : Parsetree.toplevel_phrase -> (location list * string) optioncheck_phrase phrase checks that phrase can be executed without typing or compilation errors. It returns None if phrase is OK and an error message otherwise.
If the result is None it is guaranteed that Toploop.execute_phrase won't raise any exception.
val collect_formatters : 
  Buffer.t ->
  Format.formatter list ->
  (unit -> 'a) ->
  'acollect_formatters buf pps f executes f and redirect everything it prints on pps to buf.
val discard_formatters : Format.formatter list -> (unit -> 'a) -> 'adiscard_formatters pps f executes f, dropping everything it prints on pps.