| 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 | None | 
| Language | Haskell2010 | 
Control.Lens.Wither
Contents
Description
See Chris Penner, Composable Filters Using Witherable Optics
Synopsis
- type Wither s t a b = forall (f :: Type -> Type). 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 :: forall (t :: Type -> Type) a b. Witherable t => Wither (t a) (t b) a b
- filtraversed :: forall (t :: Type -> Type) a b. (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 :: Type -> Type -> Type) (f :: Type -> Type). (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 :: Type -> Type). Alternative f => (a -> f b) -> f t
 
Wither
Combinators
cloneWither :: AWither s t a b -> Wither s t a b Source #
withered :: forall (t :: Type -> Type) a b. Witherable t => Wither (t a) (t b) a b Source #
Construct a Wither for a Witherable. 
filtraversed :: forall (t :: Type -> Type) a b. (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 :: Type -> Type -> Type) (f :: Type -> Type). (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 #
Prisms 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 Withers. 
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 | |