forked from ocaml/odoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
26 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
type 'a t = { entry : 'a; children : 'a forest } | ||
type 'a t = { node : 'a; children : 'a forest } | ||
and 'a forest = 'a t list | ||
|
||
let leaf entry = { entry; children = [] } | ||
let leaf node = { node; children = [] } | ||
|
||
let rec fold_t fun_ acc { entry; children } = | ||
let acc = fun_ acc entry in | ||
let rec fold_t fun_ acc { node; children } = | ||
let acc = fun_ acc node in | ||
fold_f fun_ acc children | ||
|
||
and fold_f fun_ acc f = List.fold_left (fold_t fun_) acc f | ||
|
||
let rec iter_t fun_ { entry; children } = | ||
let () = fun_ entry in | ||
let rec iter_t fun_ { node; children } = | ||
let () = fun_ node in | ||
iter_f fun_ children | ||
|
||
and iter_f fun_ f = List.iter (iter_t fun_) f | ||
|
||
let rec map_t fun_ { entry; children } = | ||
let entry = fun_ entry in | ||
let rec map_t fun_ { node; children } = | ||
let node = fun_ node in | ||
let children = map_f fun_ children in | ||
{ entry; children } | ||
{ node; children } | ||
|
||
and map_f fun_ f = List.map (map_t fun_) f | ||
|
||
let rec filter_map_t fun_ { entry; children } = | ||
match fun_ entry with | ||
let rec filter_map_t fun_ { node; children } = | ||
match fun_ node with | ||
| None -> None | ||
| Some entry -> | ||
| Some node -> | ||
let children = filter_map_f fun_ children in | ||
Some { entry; children } | ||
Some { node; children } | ||
|
||
and filter_map_f fun_ f = List.filter_map (filter_map_t fun_) f |