distributors-0.1.0.2: Unifying Parsers, Printers & Grammars
Copyright(C) 2025 - Eitan Chatav
LicenseBSD-style (see the file LICENSE)
MaintainerEitan Chatav <eitan.chatav@gmail.com>
Stabilityprovisional
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Lens.Wither

Description

Synopsis

Wither

type Wither s t a b = forall f. Alternative f => (a -> f b) -> s -> f t Source #

Withers extends Traversals by filtering.

Every one of the following is a Wither.

type AWither s t a b = (a -> Altar a b b) -> s -> Altar a b t Source #

If you see AWither in a signature for a function, the function is expecting a Wither.

Combinators

cloneWither :: AWither s t a b -> Wither s t a b Source #

Clone AWither so that you can reuse the same monomorphically typed Wither for different purposes.

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 #

Witheroids generalize Withers. Every Prism is a Witheroid.

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

newtype Altar a b t Source #

This is used to characterize Withers.

Constructors

Altar 

Fields

Instances

Instances details
Alternative (Altar a b) Source # 
Instance details

Defined in Control.Lens.Wither

Methods

empty :: Altar a b a0 #

(<|>) :: Altar a b a0 -> Altar a b a0 -> Altar a b a0 #

some :: Altar a b a0 -> Altar a b [a0] #

many :: Altar a b a0 -> Altar a b [a0] #

Applicative (Altar a b) Source # 
Instance details

Defined in Control.Lens.Wither

Methods

pure :: a0 -> Altar a b a0 #

(<*>) :: Altar a b (a0 -> b0) -> Altar a b a0 -> Altar a b b0 #

liftA2 :: (a0 -> b0 -> c) -> Altar a b a0 -> Altar a b b0 -> Altar a b c #

(*>) :: Altar a b a0 -> Altar a b b0 -> Altar a b b0 #

(<*) :: Altar a b a0 -> Altar a b b0 -> Altar a b a0 #

Functor (Altar a b) Source # 
Instance details

Defined in Control.Lens.Wither

Methods

fmap :: (a0 -> b0) -> Altar a b a0 -> Altar a b b0 #

(<$) :: a0 -> Altar a b b0 -> Altar a b a0 #

Sellable (->) Altar Source # 
Instance details

Defined in Control.Lens.Wither

Methods

sell :: a -> Altar a b b #