fclabels-1.1.7: First class accessor labels.

Safe HaskellSafe-Inferred

Data.Label.Maybe

Synopsis

Documentation

type :~> f a = MaybeLens f aSource

Lens type for situations in which the accessor functions can fail. This is useful, for example, when accessing fields in datatypes with multiple constructors.

lens :: (f -> Maybe a) -> (a -> f -> Maybe f) -> f :~> aSource

Create a lens that can fail from a getter and a setter that can themselves potentially fail.

get :: (f :~> a) -> f -> Maybe aSource

Getter for a lens that can fail. When the field to which the lens points is not accessible the getter returns Nothing.

set :: (f :~> a) -> a -> f -> Maybe fSource

Setter for a lens that can fail. When the field to which the lens points is not accessible this function returns Nothing.

set' :: (f :~> a) -> a -> f -> fSource

Like set but return behaves like the identity function when the field could not be set.

modify :: (f :~> a) -> (a -> a) -> f -> Maybe fSource

Modifier for a lens that can fail. When the field to which the lens points is not accessible this function returns Nothing.

modify' :: (f :~> a) -> (a -> a) -> f -> fSource

Like modify but return behaves like the identity function when the field could not be set.

embed :: Lens (->) f (Maybe a) -> f :~> aSource

Embed a pure lens that points to a Maybe field into a lens that might fail.