aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2017-01-14 01:27:40 +0100
committerGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2017-04-24 23:58:22 +0200
commit6d9e008ffd81bbe927e3442fb0c37269ed25b21f (patch)
tree059ceb889a68c3098d7eeb1b9549999ca8127135 /lib
parent846b74275511bd89c2f3abe19245133050d2199c (diff)
[location] Use Loc.located for constr_expr.
This is the second patch, which is a bit more invasive. We reasoning is similar to the previous patch. Code is not as clean as it could as we would need to convert `glob_constr` to located too, then a few parts could just map the location.
Diffstat (limited to 'lib')
-rw-r--r--lib/loc.ml5
-rw-r--r--lib/loc.mli5
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/loc.ml b/lib/loc.ml
index 39f2d7dfb..8ae8fe25d 100644
--- a/lib/loc.ml
+++ b/lib/loc.ml
@@ -63,6 +63,11 @@ type 'a located = t * 'a
let to_pair x = x
let tag ?loc x = Option.default ghost loc, x
+let with_loc f (loc, x) = f ~loc x
+
+let map f (l,x) = (l, f x)
+let map_with_loc f (loc, x) = (loc, f ~loc x)
+
let located_fold_left f x (_,a) = f x a
let located_iter2 f (_,a) (_,b) = f a b
let down_located f (_,a) = f a
diff --git a/lib/loc.mli b/lib/loc.mli
index fef1d8938..7fc8efaa8 100644
--- a/lib/loc.mli
+++ b/lib/loc.mli
@@ -61,6 +61,11 @@ type 'a located = t * 'a
val to_pair : 'a located -> t * 'a
val tag : ?loc:t -> 'a -> 'a located
+val with_loc : (loc:t -> 'a -> 'b) -> 'a located -> 'b
+
+val map : ('a -> 'b) -> 'a located -> 'b located
+val map_with_loc : (loc:t -> 'a -> 'b) -> 'a located -> 'b located
+
val located_fold_left : ('a -> 'b -> 'a) -> 'a -> 'b located -> 'a
val down_located : ('a -> 'b) -> 'a located -> 'b