From fe167ebb24c02486b80ccb8b8684a121dae00d60 Mon Sep 17 00:00:00 2001 From: ยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค Date: Thu, 11 Dec 2025 10:35:34 +0000 Subject: move Non_empty_list to Utils --- lib/util.ml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/util.ml') diff --git a/lib/util.ml b/lib/util.ml index 30b8fef..985fc43 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -194,3 +194,19 @@ module URI = struct Jsont.string |> Jsont.map ~kind: "URI" ~dec: Uri.of_string ~enc: Uri.to_string end + +module Non_empty_list = struct + type 'a t = + ('a * 'a list) + [@@deriving show, eq, qcheck] + + let to_list (x, xs) = x :: xs + + let of_list = function + | [] -> None + | x :: xs -> Some (x, xs) + + let map f (x, xs) = (f x, List.map f xs) + let fold_left f acc (x, xs) = List.fold_left f acc (x :: xs) + let fold_right f acc (x, xs) = List.fold_right f acc (x :: xs) +end -- cgit v1.2.3