Module Base.Source_code_positionSource

One typically obtains a Source_code_position.t using a [%here] expression, which is implemented by the ppx_here preprocessor.

Sourcetype t = Lexing.position = {
  1. pos_fname : string;
  2. pos_lnum : int;
  3. pos_bol : int;
  4. pos_cnum : int;
}

See INRIA's OCaml documentation for a description of these fields.

sexp_of_t uses the form "FILE:LINE:COL", and does not have a corresponding of_sexp.

include Ppx_hash_lib.Hashable.S with type t := t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval sexp_of_t__stack : t @ local -> Sexplib0.Sexp.t @ local
include Comparable.S__local__portable with type t := t
include Comparisons.S__local with type t := t
include Comparisons.Infix with type t := t
Sourceval (>=) : t -> t -> bool
Sourceval (<=) : t -> t -> bool
Sourceval (=) : t -> t -> bool
Sourceval (>) : t -> t -> bool
Sourceval (<) : t -> t -> bool
Sourceval (<>) : t -> t -> bool
Sourceval equal : t -> t -> bool
Sourceval compare : t -> t -> int

compare t1 t2 returns 0 if t1 is equal to t2, a negative integer if t1 is less than t2, and a positive integer if t1 is greater than t2.

Sourceval min : t -> t -> t
Sourceval max : t -> t -> t
Sourceval ascending : t -> t -> int @@ portable

ascending is identical to compare. descending x y = ascending y x. These are intended to be mnemonic when used like List.sort ~compare:ascending and List.sort ~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.

Sourceval descending : t -> t -> int @@ portable
Sourceval between : t -> low:t -> high:t -> bool @@ portable

between t ~low ~high means low <= t <= high

Sourceval clamp_exn : t -> min:t -> max:t -> t @@ portable

clamp_exn t ~min ~max returns t', the closest value to t such that between t' ~low:min ~high:max is true.

Raises if not (min <= max).

Sourceval clamp : t -> min:t -> max:t -> t Or_error.t @@ portable
include Comparator.S__portable with type t := t
Sourcetype comparator_witness : value mod portable
Sourceval to_string : t -> string @@ portable

to_string t converts t to the form "FILE:LINE:COL".

Sourceval of_pos : (string * int * int * int) -> t @@ portable

of_pos Stdlib.__POS__ is like [%here] but without using ppx.

Sourceval here_or_there : here:lexing_position -> t option -> t @@ portable

here_or_there (Some there) returns there. here_or_there None returns ~here, which may be defined implicitly on compilers supporting [%call_pos].

Sourceval is_dummy : t @ local -> bool @@ portable

is_dummy pos returns true if pos is equal to Stdlib.Lexing.dummy_pos.

Stdlib.Lexing.dummy_pos is a position guaranteed to be different from any valid position.