package dolmen
Source file path.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39(* This file is free software, part of dolmen. See file "LICENSE" for more information. *) (** Names *) (** {2 Type definition} *) type path = string list type t = | Local of { name : string; } | Absolute of { path : path; name : string; } let print fmt = function | Local { name; } -> Format.fprintf fmt "%s" name | Absolute { path = []; name; } -> Format.fprintf fmt "%s" name | Absolute { path; name; } -> let pp_sep fmt () = Format.fprintf fmt "." in Format.fprintf fmt "%a.%a" (Format.pp_print_list ~pp_sep Format.pp_print_string) path Format.pp_print_string name let local name = Local { name; } let global name = Absolute { path = []; name; } let absolute path name = Absolute { path; name; } let rename f = function | Local { name; } -> local (f name) | Absolute { path; name; } -> absolute path (f name)