Copyright | (c) Carl Howells 2021-2022 |
---|---|
License | MIT |
Maintainer | chowells79@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- withered :: (Applicative f, Witherable t) => (a -> Withering f b) -> t a -> f (t b)
- unwithered :: Functor f => (a -> f b) -> a -> Withering f b
- rewithered :: (Applicative f, Witherable t) => (a -> Withering f b) -> t a -> Withering f (t b)
- decayed :: Applicative f => pafb -> s -> Withering f t
- guarded :: Applicative f => (a -> Bool) -> (a -> Withering f b) -> a -> Withering f b
- filterOf :: ((a -> Withering Identity a) -> s -> Identity s) -> (a -> Bool) -> s -> s
- mapMaybeOf :: ((a -> Withering Identity b) -> s -> Identity t) -> (a -> Maybe b) -> s -> t
- witherOf :: ((a -> Withering f b) -> s -> f t) -> (a -> f (Maybe b)) -> s -> f t
Documentation
withered :: (Applicative f, Witherable t) => (a -> Withering f b) -> t a -> f (t b) Source #
A variant on traverse
that allows the targets to be filtered
out of the Witherable
structure. Note that this introduces a
change in types down the lens composition chain, which means that
it is not a a valid optic at all. The use of Withering
in the
changed type also means that standard lens combinators don't fit
To address these issues, you can use unwithered
to strip the
Withering
type back out. This allows the composed optic to be
used with standard combinators from lens. In addition, the sequence
will act like a type-restricted version
of withered
. unwithered
traverse
for all lawful instances of Witherable
.
In some sense, this is a catch
-like combinator. This marks the
point where removing elements stops propagating and actually
modifies the structure being focused.
unwithered :: Functor f => (a -> f b) -> a -> Withering f b Source #
Restore types in a lens composition chain that has had
Withering
introduced. Makes no changes to what elements are
focused on.
rewithered :: (Applicative f, Witherable t) => (a -> Withering f b) -> t a -> Withering f (t b) Source #
A variant of withered for when you're already working in a Withering chain and want to change what structure elements are being removed from.
rewithered
=unwithered
.withered
decayed :: Applicative f => pafb -> s -> Withering f t Source #
The trivial optic in a Withering chain that removes everything.
The arguments are unused.
guarded :: Applicative f => (a -> Bool) -> (a -> Withering f b) -> a -> Withering f b Source #
Remove elements from the current Withering
context if they
don't match the predicate. This is similar in concept to filtered
from lens. The major that instead of merely removing non-matching
targets from the traversal, it removes those targets (and their
parents up to the next withered
combinator) from the data
structure entirely.
filterOf :: ((a -> Withering Identity a) -> s -> Identity s) -> (a -> Bool) -> s -> s infix 2 Source #
Remove elements matched by a specific Withering
context if they
don't match a predicate.