util: separated the monadic traverse into a utility module
This commit is contained in:
9
lib/compiler/util.ml
Normal file
9
lib/compiler/util.ml
Normal file
@@ -0,0 +1,9 @@
|
||||
let ( let* ) = Result.bind
|
||||
|
||||
let traverse f l =
|
||||
let rec aux acc = function
|
||||
| x :: xs ->
|
||||
let* result = f x in
|
||||
aux (result :: acc) xs
|
||||
| [] -> Ok (List.rev acc) in
|
||||
aux [] l
|
||||
Reference in New Issue
Block a user