From ca289b2f43a5b097c4ec20308c1661a0c404399c Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 11 Aug 2026 11:25:56 +0200 Subject: kernel: Slug and Lang validated private strings Both parse through a smart constructor returning result, and both hand-write t_of_sexp so a malformed value in a data file is rejected at load rather than silently accepted -- deriving the converter would have bypassed validation. --- lib/kernel/slug.mli | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/kernel/slug.mli (limited to 'lib/kernel/slug.mli') diff --git a/lib/kernel/slug.mli b/lib/kernel/slug.mli new file mode 100644 index 0000000..0081e2b --- /dev/null +++ b/lib/kernel/slug.mli @@ -0,0 +1,16 @@ +(** Stable celebration identifiers: non-empty [a-z0-9-], no leading or trailing + hyphen. Also serve as lectionary keys. *) +type t = private string + +val of_string : string -> (t, string) result + +(** For literals in code and tests. Raises [Invalid_argument] on a bad slug. *) +val of_string_exn : string -> t + +val to_string : t -> string +val compare : t -> t -> int +val equal : t -> t -> bool + +(** Validating; raises [Of_sexp_error] on a malformed slug. *) +val t_of_sexp : Sexplib0.Sexp.t -> t +val sexp_of_t : t -> Sexplib0.Sexp.t -- cgit v1.3