Copyright | (C) 2025 - Eitan Chatav |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Eitan Chatav <eitan.chatav@gmail.com> |
Stability | provisional |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Control.Lens.Wither
Contents
Description
See Chris Penner, Composable Filters Using Witherable Optics
Synopsis
- type Wither s t a b = forall f. Alternative f => (a -> f b) -> s -> f t
- type AWither s t a b = (a -> Altar a b b) -> s -> Altar a b t
- cloneWither :: AWither s t a b -> Wither s t a b
- withered :: Witherable t => Wither (t a) (t b) a b
- filtraversed :: (Filterable t, Traversable t) => Wither (t a) (t b) a b
- filterOf :: Alternative m => Wither s t a a -> (a -> Bool) -> s -> m t
- type Witheroid s t a b = forall p f. (Choice p, Alternative f) => p a (f b) -> p s (f t)
- witherPrism :: APrism s t a b -> Witheroid s t a b
- newtype Altar a b t = Altar {
- runAltar :: forall f. Alternative f => (a -> f b) -> f t
Wither
type Wither s t a b = forall f. Alternative f => (a -> f b) -> s -> f t Source #
Combinators
cloneWither :: AWither s t a b -> Wither s t a b Source #
withered :: Witherable t => Wither (t a) (t b) a b Source #
Construct a Wither
for a Witherable
.
filtraversed :: (Filterable t, Traversable t) => Wither (t a) (t b) a b Source #
withered = filtraversed
filterOf :: Alternative m => Wither s t a a -> (a -> Bool) -> s -> m t Source #
Filter a traversed structure based on a predicate.
Witheroid
type Witheroid s t a b = forall p f. (Choice p, Alternative f) => p a (f b) -> p s (f t) Source #
witherPrism :: APrism s t a b -> Witheroid s t a b Source #
Prism
s already capture the idea of success and failure,
but they simply skip the traversal if the prism doesn't match.
Lift prisms into withers such that they'll fail in a way that wither can catch.
Altar
This is used to characterize Wither
s.
Constructors
Altar | |
Fields
|
Instances
Alternative (Altar a b) Source # | |
Applicative (Altar a b) Source # | |
Defined in Control.Lens.Wither | |
Functor (Altar a b) Source # | |
Sellable (->) Altar Source # | |
Defined in Control.Lens.Wither |