summaryrefslogtreecommitdiff
path: root/src/vytree.mli
blob: 448aa8497fe2be83d706cf261fb56763940526f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
type 'a t [@@deriving yojson]

exception Empty_path
exception Duplicate_child
exception Nonexistent_path
exception Insert_error of string

type position = Before of string | After of string | Lexical | End | Default

val make : 'a -> string -> 'a t
val make_full : 'a -> string -> ('a t) list -> 'a t

val name_of_node : 'a t -> string
val data_of_node : 'a t -> 'a
val children_of_node : 'a t -> 'a t list

val find : 'a t -> string -> 'a t option

val adopt : 'a t -> 'a t -> 'a t

val replace : 'a t -> 'a t -> 'a t
[@@alert exn "Not_found"]

val insert : ?position:position -> ?children:('a t list) -> 'a t -> string list -> 'a -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Not_found possible if position Before/After"]
[@@alert exn "Vytree.Duplicate_child"]
[@@alert exn "Vytree.Insert_error"]

val insert_maybe : ?position:position -> 'a t -> string list -> 'a -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Not_found possible if position Before/After"]
[@@alert exn "Vytree.Insert_error"]

val insert_or_update : ?position:position -> 'a t -> string list -> 'a -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Not_found possible if position Before/After"]
[@@alert exn "Vytree.Insert_error"]

val insert_multi_level : ?position:position -> 'a -> 'a t -> string list -> string list -> 'a -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Not_found possible if position Before/After"]
[@@alert exn "Vytree.Duplicate_child possible if path_remaining not complement"]
[@@alert exn "Vytree.Insert_error possible if path_done existence not guaranteed"]

val merge_children : ('a -> 'a -> 'a) -> (string -> string -> int) -> 'a t -> 'a t

val delete : 'a t -> string list -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]

val update : 'a t -> string list -> 'a -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]

val rename : 'a t -> string list -> string -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Not_found"]
[@@alert exn "Vytree.Nonexistent_path"]

val list_children : 'a t -> string list

val get : 'a t -> string list -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]

val get_existent_path : 'a t -> string list -> string list

val get_data : 'a t -> string list -> 'a
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]

val exists : 'a t -> string list -> bool
[@@alert exn "Vytree.Empty_path"]

val children_of_path : 'a t -> string list -> string list
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]

val sorted_children_of_node : (string -> string -> int) -> 'a t -> ('a t) list

val sort_children : (string -> string -> int) -> 'a t -> 'a t

val copy : 'a t -> string list -> string list -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]
[@@alert exn "Vytree.Insert_error"]

val move : 'a t -> string list -> position -> 'a t
[@@alert exn "Vytree.Empty_path"]
[@@alert exn "Vytree.Nonexistent_path"]
[@@alert exn "Not_found possible if position Before/After"]
[@@alert exn "Vytree.Insert_error"]

val is_terminal_path : 'a t -> string list -> bool
[@@alert exn "Vytree.Empty_path"]

val fold_tree_with_path: (string list * 'acc -> 'b t -> string list * 'acc) -> string list * 'acc -> 'b t -> 'acc

val fold_tree_with_path_and_list: ((string list * bool list) * 'acc -> 'b t ->
    (string list * bool list) * 'acc) -> (string list * bool list) * 'acc -> 'b t -> 'acc