Safe Haskell | Safe-Infered |
---|
- type :~> f a = MaybeLens f a
- lens :: (f -> Maybe a) -> (a -> f -> Maybe f) -> f :~> a
- get :: (f :~> a) -> f -> Maybe a
- set :: (f :~> a) -> a -> f -> Maybe f
- set' :: (f :~> a) -> a -> f -> f
- modify :: (f :~> a) -> (a -> a) -> f -> Maybe f
- modify' :: (f :~> a) -> (a -> a) -> f -> f
- embed :: Lens (->) f (Maybe a) -> f :~> a
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
.