Loko.List
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.
let None = L.view_opt L.List.hd []
let 3 = L.view L.List.hd [3; 1; 4]
let [-3; 1; 4] = L.over L.List.hd (~-) [3; 1; 4]
let [1; 4] = L.remove L.List.hd [3; 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.
let None = L.view_opt L.List.tl []
let [1; 4] = L.view L.List.tl [3; 1; 4]
let [3; 4; 1] = L.over L.List.tl List.rev [3; 1; 4]
let [3] = L.remove L.List.tl [3; 1; 4]
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 to_array : ( 'F Stdlib.List.t, 'F array, 'G array, 'G Stdlib.List.t ) optic
Isomorphism between lists and arrays.
val to_option :
( 'F Stdlib.List.t, 'F option, 'G option, 'G Stdlib.List.t ) optic
Isomorphism between singleton lists and options.
let None = L.view L.List.to_option ["more"; "than"; "one"]
let Some "exactly one" = L.view L.List.to_option ["exactly one"]
let None = L.view L.List.to_option []
val 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.
let [3; 1; 4] = L.over L.List.rev (List.cons 4) [3; 1]
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.
let ([1; 2], [3; 4; 5]) =
L.view (L.List.partition (fun x -> x <= 2)) [3; 1; 4; 2; 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.
let [1; 2] = L.view (L.List.filter (fun x -> x <= 2)) [3; 1; 4; 2; 5]
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.
let [3; 4; 5] = L.view (L.List.reject (fun x -> x <= 2)) [3; 1; 4; 2; 5]