Module Seplist

module Seplist: sig .. end
general thing of lists with optional separators

type ('a, 'b) t 
val empty : ('a, 'b) t
val cons_sep : 'a -> ('b, 'a) t -> ('b, 'a) t
val cons_sep_alt : 'a -> ('b, 'a) t -> ('b, 'a) t
cons_sep_alt doesn't add the separator if the list is empty
val cons_entry : 'a -> ('a, 'b) t -> ('a, 'b) t
val is_empty : ('a, 'b) t -> bool
val sing : 'a -> ('a, 'b) t
sing a constructs a seplist with entry a. It does the same as cons_entry a empty.
val hd : ('a, 'b) t -> 'a
gets the first entry, if there is one
val hd_sep : ('a, 'b) t -> 'b
gets the first seperator, if there is one
val tl : ('a, 'b) t -> ('a, 'b) t
Removes the first entry, fails is there is none, or if a separator is first
val tl_alt : ('a, 'b) t -> ('a, 'b) t
Removes the first entry, fails is there is none, removes any separator that precedes the first entry
val tl_sep : ('a, 'b) t -> ('a, 'b) t
Removes the first separator, fails is there is none, or if an entry is first
val append : 'a -> ('b, 'a) t -> ('b, 'a) t -> ('b, 'a) t
append d sl1 sl2 appends the seplists sl1 and sl2. If sl1 ends with a value and sl2 starts with a value, a default separator s is added. If sl1 ends with a separator and sl2 starts with a separator, the seperator of sl2 is dropped.
val flatten : 'a -> ('b, 'a) t list -> ('b, 'a) t
flatten d sll flattens a list of seplists by applying append repeatedly
val to_list : ('a, 'b) t -> 'a list
Makes a normal list, ignoring separators
val to_pair_list : 'a -> ('b, 'a) t -> 'a option * ('b * 'a) list
Makes a normal list of pairs. The first separator is returned separately, an default one added for the last entry, if the lists ends with a value
val from_pair_list : 'a option -> ('b * 'a) list -> 'b option -> ('b, 'a) t
constructs a seplist from a list of pairs. In contrast to from_list, the last separator is kept
val from_pair_list_sym : 'a option -> ('b * 'a) list -> 'b option -> ('a, 'b) t
from_pair_list_sym first_val_opt sep_val_list last_sep_opt constructs a seplist from a list of pairs sep_val_list. In contrast to from_pair_list, the separator is the first component of these pairs. This also means that we now need an optional first value before the list and an optional last separator after the list, whereas from_pair_list has an optional first separator and last value.
val drop_first_sep : ('a, 'b) t -> 'b option * ('a, 'b) t
If sl starts with a seperator, it is dropped and returned, otherwise nothing happens.
val to_sep_list : ('a -> 'b) -> ('c -> 'b) -> ('a, 'c) t -> 'b list
Flattens into a normal list with separators and elements intermixed

type ('a, 'b) optsep =
| Optional
| Require of 'a
| Forbid of ('a -> 'b)
val to_sep_list_first : ('a, 'b) optsep ->
('c -> 'b) -> ('a -> 'b) -> ('c, 'a) t -> 'b list
Flattens into a normal list with separators and elements intermixed, with special control over the first separator. Optional indicates no special treatment (works as to_sep_list), Require adds the given initial separator if there is none, and Forbid removes the initial separator if there is one. In the latter case, the initial separator is processed by the function argument to Forbid
val to_sep_list_last : ('a, 'b) optsep ->
('c -> 'b) -> ('a -> 'b) -> ('c, 'a) t -> 'b list
As to_sep_list_first, but for the last separator
val to_list_map : ('a -> 'b) -> ('a, 'c) t -> 'b list
val iter : ('a -> unit) -> ('a, 'b) t -> unit
val from_list : ('a * 'b) list -> ('a, 'b) t
The from list functions ignore the last separator in the input list
val from_list_prefix : 'a -> bool -> ('b * 'a) list -> ('b, 'a) t
val from_list_suffix : ('a * 'b) list -> 'b -> bool -> ('a, 'b) t
val from_list_default : 'a -> 'b list -> ('b, 'a) t
from_list_default d l constructs a seplist form a list of entries l using the separator d as default separator between all entries.
val length : ('a, 'b) t -> int
val map : ('a -> 'b) -> ('a, 'c) t -> ('b, 'c) t
val map_changed : ('a -> 'a option) -> ('a, 'b) t -> ('a, 'b) t option
Returns None if the function returns None on all of the elements, otherwise returns a list that uses the original element where the function returns None
val map_acc_right : ('a -> 'b -> 'c * 'b) -> 'b -> ('a, 'd) t -> ('c, 'd) t * 'b
Maps with an accumulating parameter. The _right version builds the accumulator right-to-left, and the _left version builds it left-to-right.
val map_acc_left : ('a -> 'b -> 'c * 'b) -> 'b -> ('a, 'd) t -> ('c, 'd) t * 'b
val fold_right : ('a -> 'b -> 'b) -> 'b -> ('a, 'c) t -> 'b
fold right implemented via map_acc_right
val fold_left : ('a -> 'b -> 'b) -> 'b -> ('a, 'c) t -> 'b
fold left implemented via map_acc_left
val for_all : ('a -> bool) -> ('a, 'b) t -> bool
val exists : ('a -> bool) -> ('a, 'b) t -> bool
val find : 'a -> ('b -> bool) -> ('b, 'a) t -> 'b * 'a
val pp : (Format.formatter -> 'a -> unit) ->
(Format.formatter -> 'b -> unit) ->
Format.formatter -> ('a, 'b) t -> unit
val replace_all_seps : ('a -> 'a) -> ('b, 'a) t -> ('b, 'a) t