folds-0.7.3: Beautiful Folding

Safe HaskellTrustworthy
LanguageHaskell98

Data.Fold.Class

Synopsis

Documentation

class Choice p => Scan p where Source #

Minimal complete definition

interspersing

Methods

prefix1 :: a -> p a b -> p a b Source #

prefix1 :: Folding p => a -> p a b -> p a b Source #

postfix1 :: p a b -> a -> p a b Source #

postfix1 :: Folding p => p a b -> a -> p a b Source #

run1 :: a -> p a b -> b Source #

Apply a Folding to a single element of input

run1 :: Folding p => a -> p a b -> b Source #

Apply a Folding to a single element of input

interspersing :: a -> p a b -> p a b Source #

Instances

Scan L Source # 

Methods

prefix1 :: a -> L a b -> L a b Source #

postfix1 :: L a b -> a -> L a b Source #

run1 :: a -> L a b -> b Source #

interspersing :: a -> L a b -> L a b Source #

Scan L' Source # 

Methods

prefix1 :: a -> L' a b -> L' a b Source #

postfix1 :: L' a b -> a -> L' a b Source #

run1 :: a -> L' a b -> b Source #

interspersing :: a -> L' a b -> L' a b Source #

Scan L1 Source # 

Methods

prefix1 :: a -> L1 a b -> L1 a b Source #

postfix1 :: L1 a b -> a -> L1 a b Source #

run1 :: a -> L1 a b -> b Source #

interspersing :: a -> L1 a b -> L1 a b Source #

Scan L1' Source # 

Methods

prefix1 :: a -> L1' a b -> L1' a b Source #

postfix1 :: L1' a b -> a -> L1' a b Source #

run1 :: a -> L1' a b -> b Source #

interspersing :: a -> L1' a b -> L1' a b Source #

Scan M Source # 

Methods

prefix1 :: a -> M a b -> M a b Source #

postfix1 :: M a b -> a -> M a b Source #

run1 :: a -> M a b -> b Source #

interspersing :: a -> M a b -> M a b Source #

Scan M1 Source # 

Methods

prefix1 :: a -> M1 a b -> M1 a b Source #

postfix1 :: M1 a b -> a -> M1 a b Source #

run1 :: a -> M1 a b -> b Source #

interspersing :: a -> M1 a b -> M1 a b Source #

Scan R Source # 

Methods

prefix1 :: a -> R a b -> R a b Source #

postfix1 :: R a b -> a -> R a b Source #

run1 :: a -> R a b -> b Source #

interspersing :: a -> R a b -> R a b Source #

Scan R1 Source # 

Methods

prefix1 :: a -> R1 a b -> R1 a b Source #

postfix1 :: R1 a b -> a -> R1 a b Source #

run1 :: a -> R1 a b -> b Source #

interspersing :: a -> R1 a b -> R1 a b Source #

class Scan p => Folding p where Source #

Minimal complete definition

prefixOf, postfixOf, runOf, filtering

Methods

prefix :: Foldable t => t a -> p a b -> p a b Source #

Partially apply a Folding to some initial input on the left.

prefixOf :: Fold s a -> s -> p a b -> p a b Source #

postfix :: Foldable t => p a b -> t a -> p a b Source #

postfixOf :: Fold s a -> p a b -> s -> p a b Source #

run :: Foldable t => t a -> p a b -> b Source #

Apply a Folding to a container full of input:

>>> run ["hello","world"] $ L id (++) []
"helloworld"
>>> run [1,2,3] $ L id (+) 0
6

runOf :: Fold s a -> s -> p a b -> b Source #

filtering :: (a -> Bool) -> p a b -> p a b Source #

Instances

Folding L Source #

efficient prefix, leaky postfix

Methods

prefix :: Foldable t => t a -> L a b -> L a b Source #

prefixOf :: Fold s a -> s -> L a b -> L a b Source #

postfix :: Foldable t => L a b -> t a -> L a b Source #

postfixOf :: Fold s a -> L a b -> s -> L a b Source #

run :: Foldable t => t a -> L a b -> b Source #

runOf :: Fold s a -> s -> L a b -> b Source #

filtering :: (a -> Bool) -> L a b -> L a b Source #

Folding L' Source #

efficient prefix, leaky postfix

Methods

prefix :: Foldable t => t a -> L' a b -> L' a b Source #

prefixOf :: Fold s a -> s -> L' a b -> L' a b Source #

postfix :: Foldable t => L' a b -> t a -> L' a b Source #

postfixOf :: Fold s a -> L' a b -> s -> L' a b Source #

run :: Foldable t => t a -> L' a b -> b Source #

runOf :: Fold s a -> s -> L' a b -> b Source #

filtering :: (a -> Bool) -> L' a b -> L' a b Source #

Folding M Source #

efficient prefix, efficient postfix

Methods

prefix :: Foldable t => t a -> M a b -> M a b Source #

prefixOf :: Fold s a -> s -> M a b -> M a b Source #

postfix :: Foldable t => M a b -> t a -> M a b Source #

postfixOf :: Fold s a -> M a b -> s -> M a b Source #

run :: Foldable t => t a -> M a b -> b Source #

runOf :: Fold s a -> s -> M a b -> b Source #

filtering :: (a -> Bool) -> M a b -> M a b Source #

Folding R Source #

leaky prefix, efficient postfix

Methods

prefix :: Foldable t => t a -> R a b -> R a b Source #

prefixOf :: Fold s a -> s -> R a b -> R a b Source #

postfix :: Foldable t => R a b -> t a -> R a b Source #

postfixOf :: Fold s a -> R a b -> s -> R a b Source #

run :: Foldable t => t a -> R a b -> b Source #

runOf :: Fold s a -> s -> R a b -> b Source #

filtering :: (a -> Bool) -> R a b -> R a b Source #

beneath :: Profunctor p => Optic p Identity s t a b -> p a b -> p s t Source #

Lift a Folding into a Prism.

This acts like a generalized notion of "costrength", when applied to a Folding, causing it to return the left-most value that fails to match the Prism, or the result of accumulating rewrapped in the Prism if everything matches.

>>> run [Left 1, Left 2, Left 3] $ beneath _Left $ R id (+) 0
Left 6
>>> run [Left 1, Right 2, Right 3] $ beneath _Left $ R id (+) 0
Right 2
beneath :: Prism s t a b -> p a b -> p s t
beneath :: Iso s t a b   -> p a b -> p s t