Module Loko.List

val iterator : ('a Stdlib.List.t, 'a) Iterator.t

List iterator.

val builder : ('a, 'a Stdlib.List.t) Builder.t

List builder.

val hd : ('F Stdlib.List.t, 'F, 'F, 'F Stdlib.List.t) optic

A prism that focuses on the first removable element of a list.

# L.view_opt L.List.hd []
- : 'a option = None

# L.view L.List.hd [ 3; 1; 4 ]
- : int = 3

# L.over L.List.hd ( ~- ) [ 3; 1; 4 ]
- : int list = [-3; 1; 4]

# L.remove L.List.hd [ 3; 1; 4 ]
- : int list = [1; 4]
val tl : ('F Stdlib.List.t, 'F Stdlib.List.t, 'F Stdlib.List.t, 'F Stdlib.List.t) optic

A prism that focuses on the removable tail of a list.

# L.view_opt L.List.tl []
- : 'a list option = None

# L.view L.List.tl [ 3; 1; 4 ]
- : int list = [1; 4]

# L.over L.List.tl List.rev [ 3; 1; 4 ]
- : int list = [3; 4; 1]

# L.remove L.List.tl [ 3; 1; 4 ]
- : int list = [3]
val map : ('S, 'F, 'G, 'T) optic -> ('S Stdlib.List.t, 'F Stdlib.List.t, 'G Stdlib.List.t, 'T Stdlib.List.t) optic

An isomorphism between lists.

val elems : ('F Stdlib.List.t, 'F, 'G, 'G Stdlib.List.t) optic

A traversal over the removable elements of a list.

val as_array : ('F Stdlib.List.t, 'F array, 'G array, 'G Stdlib.List.t) optic

Isomorphism between lists and arrays.

val as_option : ('F Stdlib.List.t, 'F option, 'G option, 'G Stdlib.List.t) optic

Isomorphism between singleton lists and options.

# L.view L.List.as_option [ "more"; "than"; "one" ]
- : string option = None

# L.view L.List.as_option [ "exactly one" ]
- : string option = Some "exactly one"

# L.view L.List.as_option []
- : 'a option = None
val as_rev : ('F Stdlib.List.t, 'F Stdlib.List.t, 'G Stdlib.List.t, 'G Stdlib.List.t) optic

An isomorphism whose focus is reverse of the list.

# L.over L.List.as_rev (List.cons 4) [ 3; 1 ]
- : int list = [3; 1; 4]
val partition : ('F -> bool) -> ('F Stdlib.List.t, 'F Stdlib.List.t * 'F Stdlib.List.t, 'G Stdlib.List.t * 'G Stdlib.List.t, 'G Stdlib.List.t) optic

An isomorphism that partitions a list into sublists of passes and fails.

# L.view (L.List.partition (fun x -> x <= 2)) [ 3; 1; 4; 2; 5 ]
- : int list * int list = ([1; 2], [3; 4; 5])
val filter : ('F -> bool) -> ('F Stdlib.List.t, 'F Stdlib.List.t, 'F Stdlib.List.t, 'F Stdlib.List.t) optic

A lens that focuses on sublist of passes.

# L.view (L.List.filter (fun x -> x <= 2)) [ 3; 1; 4; 2; 5 ]
- : int list = [1; 2]
val reject : ('F -> bool) -> ('F Stdlib.List.t, 'F Stdlib.List.t, 'F Stdlib.List.t, 'F Stdlib.List.t) optic

A lens that focuses on sublist of fails.

# L.view (L.List.reject (fun x -> x <= 2)) [ 3; 1; 4; 2; 5 ]
- : int list = [3; 4; 5]