package lens
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=558db9807f04bf7afd6760b63960d9547597d9b69b15b60e5ddbbb69eee84fcb
md5=857d2ab648c5d65837dad0ace14a5ad6
doc/lens/Lens/index.html
Module Lens
Functional lenses.
Based on F# implementation in FSharpx (see src/FSharpx.Core/Lens.fs for the original implementation)
Lens type definition
val modify : ('a, 'b) t -> ('b -> 'b) -> 'a -> 'aUpdates a value through a lens
Combinators
Pairs three lenses
Selects a lens checking a predicate.
cond pred lensTrue lensFalse: pred is applied to source. If true, lensTrue is selected. If false, lensFalse is selected.
State monad integration
val get_state : ('a, 'b) t -> 'a -> 'b * 'aGets a value from the state monad.
val put_state : ('a, 'b) t -> 'b -> 'a -> unit * 'aPuts a value in the state monad.
val modify_state : ('a, 'b) t -> ('b -> 'b) -> 'a -> unit * 'aModifies a value in the state monad.
Stock lenses
val ignore : ('a, unit) tTrivial lens
val id : ('a, 'a) tIdentity lens
val first : ('a * 'b, 'a) tGets/sets the first element in a pair
val second : ('a * 'b, 'b) tGets/sets the second element in a pair
val head : ('a list, 'a) tGets/sets the first element in a list
val tail : ('a list, 'a list) tGets/sets the tail of a list
val for_assoc : 'a -> (('a * 'b) list, 'b option) tLens for a particular key in an associative list
val for_array : int -> ('a array, 'a) tLens for a particular position in an array
val for_list : int -> ('a list, 'a) tLens for a particular position in a list
val option_get : ('a option, 'a) tLens for extracting the value from an option type (same as Option.get)
List combinators
Isomorphism
Applies an isomorphism to the value viewed through a lens
module Infix : sig ... endInfix operators
module StateInfix : sig ... endInfix operators for the state monad