aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel
diff options
context:
space:
mode:
authorGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2017-02-23 03:48:50 +0100
committerGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2017-03-14 22:19:25 +0100
commit7601ddc3500cae2da39883b339951205be19c41d (patch)
treec586741e5e3202848deae3da5ae879af27c3d6d1 /kernel
parent581b8d52fe93d666045d4878a1b48dad916451ec (diff)
[safe_string] library/nameops
We add a more convenient API to create identifiers from mutable strings. We cannot solve the `String.copy` deprecation problem until we enable `-safe-string`.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/names.ml5
-rw-r--r--kernel/names.mli1
2 files changed, 6 insertions, 0 deletions
diff --git a/kernel/names.ml b/kernel/names.ml
index 1f138581c..831b6ad46 100644
--- a/kernel/names.ml
+++ b/kernel/names.ml
@@ -50,6 +50,11 @@ struct
| None -> true
| Some _ -> false
+ let of_bytes s =
+ let s = Bytes.to_string s in
+ check_soft s;
+ String.hcons s
+
let of_string s =
let () = check_soft s in
let s = String.copy s in
diff --git a/kernel/names.mli b/kernel/names.mli
index 6b0a80625..be9b9422b 100644
--- a/kernel/names.mli
+++ b/kernel/names.mli
@@ -43,6 +43,7 @@ sig
(** Check that a string may be converted to an identifier.
@raise Unicode.Unsupported if the provided string contains unsupported UTF-8 characters. *)
+ val of_bytes : bytes -> t
val of_string : string -> t
(** Converts a string into an identifier.
@raise UserError if the string is not valid, or echo a warning if it contains invalid identifier characters.