ppx_here

Expands [%here] into its location
README

A ppx rewriter that defines an extension node whose value is its source position.

Syntax

ppx_here rewrites the extension [%here] in expressions, by
replacing it by a value of type Source_code_position.t
(i.e. Lexing.position) corresponding to the current position. It
respects line number directives.

For instance:

let _ =
  print_endline [%here].Lexing.pos_fname

becomes:

let _ =
  print_endline
    {
      Lexing.pos_fname = ppx/ppx_here/test/test.ml";
      pos_lnum = 2;
      pos_cnum = 26;
      pos_bol = 8;
    }.Lexing.pos_fname

Usage

This is normally used so exceptions can contain better positions. An example is
Core.Option.value_exn, which takes an optional position so that if you have a
stack trace, you can get still the origin of the exception.

It can also be used in cases where stack traces are useless (for instance in monads with a
complicated control flow).

Command line flag

If the flag -dirname <dir> is given, relative filenames are made
relative to <dir>. <dir> can be a relative path.

<dir> can be chosen as the path from the root of the repository to
the directory of the source, to make filenames unique within the
repository (which avoids ambiguities as there can be many files called
server.ml, common.ml or config.ml).

Install
Published
21 Mar 2022
Sources
ppx_here-v0.15.0.tar.gz
sha256=c5bc027c938a4893267c12e5ded6d7391b89851cf69094154ad9d824c3e0cadf
Dependencies
ppxlib
>= "0.23.0"
dune
>= "2.0.0"
base
>= "v0.15" & < "v0.16"
ocaml
>= "4.08.0"
Reverse Dependencies
conduit-async
= "2.3.0" | >= "4.0.0"
nuscr
>= "2.1.0"
obeam
>= "0.1.0"
pa_ppx
< "0.07"
ppx_assert
>= "v0.15.0"
ppx_bap
< "v0.14.0"
ppx_bin_prot
>= "v0.15.0"
ppx_expect
>= "v0.15.0"
ppx_jane
>= "v0.15.0"
ppx_let
>= "v0.15.0"
ppx_log
>= "v0.15.0"
ppx_sexp_message
>= "v0.15.0"
ppx_sexp_value
>= "v0.15.0"
toplevel_backend
>= "v0.15.0"