diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-10-24 02:52:21 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-10-24 03:35:41 +0000 |
| commit | 2f9e0c580645fe797e71b6183cb69475915da55b (patch) | |
| tree | 50e4d5de4c3a440b2f35057776975cf6fa4f74a5 | |
| parent | 1ab69bfb730ebad450024918a43580e4aeb0d56d (diff) | |
| download | RNT-2f9e0c580645fe797e71b6183cb69475915da55b.tar.gz RNT-2f9e0c580645fe797e71b6183cb69475915da55b.zip | |
Steal a `concat_map` implementation from Karuta
| -rw-r--r-- | lib/Utilities.ml | 4 | ||||
| -rw-r--r-- | lib/Utilities.mli | 1 |
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 |
