quiver-groups-0.1.0.1: Group and chunk values within a Quiver

Copyright(c) Ivan Lazar Miljenovic
LicenseMIT
MaintainerIvan.Miljenovic@gmail.com
Safe HaskellNone
LanguageHaskell2010

Control.Quiver.Group

Description

 

Synopsis

Documentation

spaccum Source #

Arguments

:: (a -> p)

Create the initial partial accumulation p.

-> (p -> a -> Either p (g, Maybe a))

Attempt to add a new value to a partial accumulation; returns either an updated partial accumulation or else a completed accumulation g as well as optionally the initial value (if it was not added to the completed accumulation).

-> (p -> Maybe g)

Attempt to convert the final partial accumulation to a complete accumulation. If this function returns Nothing then the final partial accumulation is returned using spfailed.

-> SP a g f p 

Accumulate values within a Quiver.

spaccum' :: Functor f => (a -> p) -> (p -> a -> Either p (g, Maybe a)) -> (p -> g) -> SP a g f () Source #

As with spaccum but the finalisation function always succeeds

spgroup :: (Eq a, Functor f) => SP a [a] f () Source #

Collect consecutive equal elements together.

spgroupBy :: Functor f => (a -> a -> Bool) -> SP a [a] f () Source #

Collect consecutive elements together that satisfy the provided function.

spchunks :: Functor f => Int -> SP a [a] f () Source #

Collect the elements into lists of the specified size (though the last such may be shorter).

A size that is <= 0 will return spcomplete (that is, no outputs will be produced).