package ppx_here
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=63a2424148d6120f02ff4f744cf4a827e5faaeea7ce62982f84e3b689169e19d
md5=085a4f25cc665aac76bbcf6a22033fca
Description
Part of the Jane Street's PPX rewriters collection.
Published: 22 Mar 2017
README
title: ppx_here parent: ../README.md
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_kernel.Std.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 filename given to the compiler (or overriden by line directive) is a relative path, then ppx_here
rewrites it into an absolute path, unless a flag -dirname root
is given, in which case relative filenames are made relative to that root
filename instead. root
can be a relative path.
The goal of this behavior is to
avoid ambiguity: there are many files called
server.ml
,common.ml
orconfig.ml
in a treewhen
-dirname
is passed, avoid being overly specific by giving a path that only exists on your machine, by allowing the build system to specify where the source file is, relative to the root of the project
Dependencies (5)
-
ocaml-migrate-parsetree
>= "0.4" & < "2.0.0"
-
ppx_driver
= "v0.9.0"
-
ppx_core
>= "v0.9" & < "v0.10"
-
jbuilder
>= "1.0+beta4" & < "1.0+beta8"
-
ocaml
>= "4.03.0"
Dev Dependencies
None
Used by (19)
-
cohttp-eio
>= "6.0.0~beta2"
-
conduit-async
= "2.3.0" | >= "4.0.0"
- dap
- h1_parser
- http
-
obeam
= "0.1.0"
- oci
-
ppx_assert
= "v0.9.0"
-
ppx_bap
< "v0.14.0"
-
ppx_bin_prot
= "v0.9.0"
-
ppx_expect
= "v0.9.0"
-
ppx_fail
= "v0.9.0"
-
ppx_jane
= "v0.9.0"
-
ppx_sexp_message
= "v0.9.0"
-
ppx_sexp_value
= "v0.9.0"
- timmy
-
timmy-jsoo
>= "1.1.5"
- timmy-lwt
-
toplevel_expect_test
>= "v0.9.1" & < "v0.10.0"
Conflicts
None