Quick StartTryGuideAPICommunityBlogGitHub

Standard Library

Below is the API for the OCaml standard library. It's directly copied over from the OCaml Manual, formatted to the Reason syntax and styled accordingly. The API docs are work-in-progress; we'll be polishing these gradually!

If you're targeting JavaScript, the API docs for BuckleScript includes all of below, plus JS-specific APIs.

Module Location

module Location: sig .. end
An arbitrary value of type t; describes an empty ghost range.

type t = {
   loc_start : Lexing.position;
   loc_end : Lexing.position;
   loc_ghost : bool;
let none: t;
An arbitrary value of type t; describes an empty ghost range.
let in_file: string => t;
Return an empty ghost range located in a given file.
let init: (Lexing.lexbuf, string) => unit;
Set the file name and line number of the lexbuf to be the start of the named file.
let curr: Lexing.lexbuf => t;
Get the location of the current token from the lexbuf.
let symbol_rloc: unit => t;
let symbol_gloc: unit => t;
let rhs_loc: int => t;
rhs_loc n returns the location of the symbol at position n, starting at 1, in the current parser rule.
let input_name: Pervasives.ref(string);
let input_lexbuf: Pervasives.ref(option(Lexing.lexbuf));
let get_pos_info: Lexing.position => (string, int, int);
let print_loc: (Format.formatter, t) => unit;
let print_error: (Format.formatter, t) => unit;
let print_error_cur_file: Format.formatter => unit;
let print_warning: (t, Format.formatter, Warnings.t) => unit;
let formatter_for_warnings: Pervasives.ref(Format.formatter);
let prerr_warning: (t, Warnings.t) => unit;
let echo_eof: unit => unit;
let reset: unit => unit;
let warning_printer: Pervasives.ref(((t, Format.formatter, Warnings.t) => unit));
Hook for intercepting warnings.
let default_warning_printer: (t, Format.formatter, Warnings.t) => unit;
Original warning printer for use in hooks.
let highlight_locations: (Format.formatter, list(t)) => bool;
type 'a loc = {
   txt : 'a;
   loc : t;
let mknoloc: 'a => loc('a);
let mkloc: ('a, t) => loc('a);
let print: (Format.formatter, t) => unit;
let print_filename: (Format.formatter, string) => unit;
let absolute_path: string => string;
let show_filename: string => string;
In -absname mode, return the absolute path for this filename. Otherwise, returns the filename unchanged.
let absname: Pervasives.ref(bool);
type error = {
   loc : t;
   msg : string;
   sub : error list;
   if_highlight : string;
exception Error(error);
let error: (~loc: t=?, ~sub: list(error)=?, ~if_highlight: string=?, string) => error;
let errorf:
    ~loc: t=?,
    ~sub: list(error)=?,
    ~if_highlight: string=?,
    Pervasives.format4('a, unit, string, error)
  ) =>
let raise_errorf:
    ~loc: t=?,
    ~sub: list(error)=?,
    ~if_highlight: string=?,
    Pervasives.format4('a, unit, string, 'b)
  ) =>
let error_of_printer: (t, (Format.formatter, 'a) => unit, 'a) => error;
let error_of_printer_file: ((Format.formatter, 'a) => unit, 'a) => error;
let error_of_exn: exn => option(error);
let register_error_of_exn: (exn => option(error)) => unit;
let report_error: (Format.formatter, error) => unit;
let error_reporter: Pervasives.ref(((Format.formatter, error) => unit));
Hook for intercepting error reports.
let default_error_reporter: (Format.formatter, error) => unit;
Original error reporter for use in hooks.
let report_exception: (Format.formatter, exn) => unit;