aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-10-24 02:52:21 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-10-24 03:35:41 +0000
commit2f9e0c580645fe797e71b6183cb69475915da55b (patch)
tree50e4d5de4c3a440b2f35057776975cf6fa4f74a5 /lib
parent1ab69bfb730ebad450024918a43580e4aeb0d56d (diff)
downloadRNT-2f9e0c580645fe797e71b6183cb69475915da55b.tar.gz
RNT-2f9e0c580645fe797e71b6183cb69475915da55b.zip
Steal a `concat_map` implementation from Karuta
Diffstat (limited to '')
-rw-r--r--lib/Utilities.ml4
-rw-r--r--lib/Utilities.mli1
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/Utilities.ml b/lib/Utilities.ml
index 8b6b08e..dcf4417 100644
--- a/lib/Utilities.ml
+++ b/lib/Utilities.ml
@@ -92,6 +92,10 @@ module FingerTree = struct
(fun acc elem ->
match f elem with None -> acc | Some result -> BatFingerTree.snoc acc result)
BatFingerTree.empty
+
+ let concat_map f =
+ BatFingerTree.fold_left (fun acc elem -> BatFingerTree.append acc @@ f elem) BatFingerTree.empty
+
end
module Atomic = struct
diff --git a/lib/Utilities.mli b/lib/Utilities.mli
index f220b08..7d41e20 100644
--- a/lib/Utilities.mli
+++ b/lib/Utilities.mli
@@ -36,6 +36,7 @@ module FingerTree : sig
val foldm_left : ('a -> 'b -> ('a, 'e) result) -> 'a -> 'b BatFingerTree.t -> ('a, 'e) result
val join : string BatFingerTree.t -> string -> string
val filter_map : ('a -> 'b option) -> 'a BatFingerTree.t -> 'b BatFingerTree.t
+ val concat_map : ('a -> ('b BatFingerTree.t, 'e) result) -> 'a BatFingerTree.t -> ('b BatFingerTree.t, 'e) result
end
module Fun : sig