diff options
author | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-01-18 15:46:23 +0100 |
---|---|---|
committer | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-04-25 00:28:53 +0200 |
commit | e8a6467545c2814c9418889201e8be19c0cef201 (patch) | |
tree | 7f513d854b76b02f52f98ee0e87052c376175a0f /lib/loc.mli | |
parent | 30d3515546cf244837c6340b6b87c5f51e68cbf4 (diff) |
[location] Make location optional in Loc.located
This completes the Loc.ghost removal, the idea is to gear the API
towards optional, but uniform, location handling.
We don't print <unknown> anymore in the case there is no location.
This is what the test suite expects.
The old printing logic for located items was a bit inconsistent as
it sometimes printed <unknown> and other times it printed nothing as
the caller checked for `is_ghost` upstream.
Diffstat (limited to 'lib/loc.mli')
-rw-r--r-- | lib/loc.mli | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/loc.mli b/lib/loc.mli index 82792613c..6de6c584d 100644 --- a/lib/loc.mli +++ b/lib/loc.mli @@ -33,13 +33,11 @@ val make_loc : int * int -> t (** Make a location out of its start and end position *) val internal_ghost : t -val is_ghost : t -> bool + (** Test whether the location is meaningful *) val merge : t -> t -> t - -val merge_opt : t option -> t -> t -val opt_merge : t -> t option -> t +val merge_opt : t option -> t option -> t option (** {5 Located exceptions} *) @@ -54,20 +52,20 @@ val raise : ?loc:t -> exn -> 'a (** {5 Objects with location information } *) -type 'a located = t * 'a +type 'a located = t option * 'a (** Embed a location in a type *) (** Warning, this API is experimental *) -val to_pair : 'a located -> t * 'a +val to_pair : 'a located -> t option * 'a val tag : ?loc:t -> 'a -> 'a located val obj : 'a located -> 'a -val with_loc : (loc:t -> 'a -> 'b) -> 'a located -> 'b +val with_loc : (?loc:t -> 'a -> 'b) -> 'a located -> 'b val with_unloc : ('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 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 |