Add some helpers to String_with_loc

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-07-07 08:58:38 +07:00
parent 54ff98b36d
commit 8ef6af2675
2 changed files with 17 additions and 0 deletions

View File

@ -208,6 +208,15 @@ module Var = struct
match destruct t with
| Single s -> s
| Pair (k, v) -> k ^ ":" ^ v
let to_string = string_of_var
let fail v ~f = Loc.fail (loc v) "%s" (f (to_string v))
let sexp_of_t t = Sexp.atom (to_string t)
let rename t ~new_name =
{ t with name = new_name }
end
let partial_expand

View File

@ -49,6 +49,8 @@ end
module Var : sig
type t
val sexp_of_t : t -> Sexp.t
val loc : t -> Loc.t
val full_name : t -> string
@ -57,6 +59,12 @@ module Var : sig
| Pair of string * string
val destruct : t -> kind
val fail : t -> f:(string -> string) -> _
val to_string : t -> string
val rename : t -> new_name:string -> t
end
val expand