ListLike-4.7.7: Generalized support for list-like structures
CopyrightCopyright (C) 2007 John Goerzen
LicenseBSD3
MaintainerDavid Fox <dsf@seereason.com>, Andreas Abel
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.ListLike.FoldableLL

Description

Generic tools for data structures that can be folded.

Written by John Goerzen, jgoerzen@complete.org

Synopsis

FoldableLL Class

class FoldableLL full item | full -> item where Source #

This is the primary class for structures that are to be considered foldable. A minimum complete definition provides foldl and foldr.

Instances of FoldableLL can be folded, and can be many and varied.

These functions are used heavily in Data.ListLike.

Minimal complete definition

foldl, foldr

Methods

foldl :: (a -> item -> a) -> a -> full -> a Source #

Left-associative fold

foldl' :: (a -> item -> a) -> a -> full -> a Source #

Strict version of foldl.

foldl1 :: (item -> item -> item) -> full -> item Source #

A variant of foldl with no base case. Requires at least 1 list element.

foldr :: (item -> b -> b) -> b -> full -> b Source #

Right-associative fold

foldr' :: (item -> b -> b) -> b -> full -> b Source #

Strict version of foldr

foldr1 :: (item -> item -> item) -> full -> item Source #

Like foldr, but with no starting value

Instances

Instances details
FoldableLL CharString Char Source # 
Instance details

Defined in Data.ListLike.CharString

Methods

foldl :: (a -> Char -> a) -> a -> CharString -> a Source #

foldl' :: (a -> Char -> a) -> a -> CharString -> a Source #

foldl1 :: (Char -> Char -> Char) -> CharString -> Char Source #

foldr :: (Char -> b -> b) -> b -> CharString -> b Source #

foldr' :: (Char -> b -> b) -> b -> CharString -> b Source #

foldr1 :: (Char -> Char -> Char) -> CharString -> Char Source #

FoldableLL CharStringLazy Char Source # 
Instance details

Defined in Data.ListLike.CharString

Methods

foldl :: (a -> Char -> a) -> a -> CharStringLazy -> a Source #

foldl' :: (a -> Char -> a) -> a -> CharStringLazy -> a Source #

foldl1 :: (Char -> Char -> Char) -> CharStringLazy -> Char Source #

foldr :: (Char -> b -> b) -> b -> CharStringLazy -> b Source #

foldr' :: (Char -> b -> b) -> b -> CharStringLazy -> b Source #

foldr1 :: (Char -> Char -> Char) -> CharStringLazy -> Char Source #

FoldableLL Chars Char Source # 
Instance details

Defined in Data.ListLike.Chars

Methods

foldl :: (a -> Char -> a) -> a -> Chars -> a Source #

foldl' :: (a -> Char -> a) -> a -> Chars -> a Source #

foldl1 :: (Char -> Char -> Char) -> Chars -> Char Source #

foldr :: (Char -> b -> b) -> b -> Chars -> b Source #

foldr' :: (Char -> b -> b) -> b -> Chars -> b Source #

foldr1 :: (Char -> Char -> Char) -> Chars -> Char Source #

FoldableLL ByteString Word8 Source # 
Instance details

Defined in Data.ListLike.Instances

Methods

foldl :: (a -> Word8 -> a) -> a -> ByteString -> a Source #

foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a Source #

foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 Source #

foldr :: (Word8 -> b -> b) -> b -> ByteString -> b Source #

foldr' :: (Word8 -> b -> b) -> b -> ByteString -> b Source #

foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 Source #

FoldableLL ByteString Word8 Source # 
Instance details

Defined in Data.ListLike.Instances

Methods

foldl :: (a -> Word8 -> a) -> a -> ByteString -> a Source #

foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a Source #

foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 Source #

foldr :: (Word8 -> b -> b) -> b -> ByteString -> b Source #

foldr' :: (Word8 -> b -> b) -> b -> ByteString -> b Source #

foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8 Source #

FoldableLL Text Char Source # 
Instance details

Defined in Data.ListLike.Text.Text

Methods

foldl :: (a -> Char -> a) -> a -> Text -> a Source #

foldl' :: (a -> Char -> a) -> a -> Text -> a Source #

foldl1 :: (Char -> Char -> Char) -> Text -> Char Source #

foldr :: (Char -> b -> b) -> b -> Text -> b Source #

foldr' :: (Char -> b -> b) -> b -> Text -> b Source #

foldr1 :: (Char -> Char -> Char) -> Text -> Char Source #

FoldableLL Builder Char Source # 
Instance details

Defined in Data.ListLike.Text.Builder

Methods

foldl :: (a -> Char -> a) -> a -> Builder -> a Source #

foldl' :: (a -> Char -> a) -> a -> Builder -> a Source #

foldl1 :: (Char -> Char -> Char) -> Builder -> Char Source #

foldr :: (Char -> b -> b) -> b -> Builder -> b Source #

foldr' :: (Char -> b -> b) -> b -> Builder -> b Source #

foldr1 :: (Char -> Char -> Char) -> Builder -> Char Source #

FoldableLL Text Char Source # 
Instance details

Defined in Data.ListLike.Text.TextLazy

Methods

foldl :: (a -> Char -> a) -> a -> Text -> a Source #

foldl' :: (a -> Char -> a) -> a -> Text -> a Source #

foldl1 :: (Char -> Char -> Char) -> Text -> Char Source #

foldr :: (Char -> b -> b) -> b -> Text -> b Source #

foldr' :: (Char -> b -> b) -> b -> Text -> b Source #

foldr1 :: (Char -> Char -> Char) -> Text -> Char Source #

FoldableLL (Seq a) a Source # 
Instance details

Defined in Data.ListLike.Instances

Methods

foldl :: (a0 -> a -> a0) -> a0 -> Seq a -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> Seq a -> a0 Source #

foldl1 :: (a -> a -> a) -> Seq a -> a Source #

foldr :: (a -> b -> b) -> b -> Seq a -> b Source #

foldr' :: (a -> b -> b) -> b -> Seq a -> b Source #

foldr1 :: (a -> a -> a) -> Seq a -> a Source #

FoldableLL (DList a) a Source # 
Instance details

Defined in Data.ListLike.DList

Methods

foldl :: (a0 -> a -> a0) -> a0 -> DList a -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> DList a -> a0 Source #

foldl1 :: (a -> a -> a) -> DList a -> a Source #

foldr :: (a -> b -> b) -> b -> DList a -> b Source #

foldr' :: (a -> b -> b) -> b -> DList a -> b Source #

foldr1 :: (a -> a -> a) -> DList a -> a Source #

FoldableLL (FMList a) a Source # 
Instance details

Defined in Data.ListLike.FMList

Methods

foldl :: (a0 -> a -> a0) -> a0 -> FMList a -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> FMList a -> a0 Source #

foldl1 :: (a -> a -> a) -> FMList a -> a Source #

foldr :: (a -> b -> b) -> b -> FMList a -> b Source #

foldr' :: (a -> b -> b) -> b -> FMList a -> b Source #

foldr1 :: (a -> a -> a) -> FMList a -> a Source #

FoldableLL (UTF8 ByteString) Char Source # 
Instance details

Defined in Data.ListLike.UTF8

Methods

foldl :: (a -> Char -> a) -> a -> UTF8 ByteString -> a Source #

foldl' :: (a -> Char -> a) -> a -> UTF8 ByteString -> a Source #

foldl1 :: (Char -> Char -> Char) -> UTF8 ByteString -> Char Source #

foldr :: (Char -> b -> b) -> b -> UTF8 ByteString -> b Source #

foldr' :: (Char -> b -> b) -> b -> UTF8 ByteString -> b Source #

foldr1 :: (Char -> Char -> Char) -> UTF8 ByteString -> Char Source #

FoldableLL (UTF8 ByteString) Char Source # 
Instance details

Defined in Data.ListLike.UTF8

Methods

foldl :: (a -> Char -> a) -> a -> UTF8 ByteString -> a Source #

foldl' :: (a -> Char -> a) -> a -> UTF8 ByteString -> a Source #

foldl1 :: (Char -> Char -> Char) -> UTF8 ByteString -> Char Source #

foldr :: (Char -> b -> b) -> b -> UTF8 ByteString -> b Source #

foldr' :: (Char -> b -> b) -> b -> UTF8 ByteString -> b Source #

foldr1 :: (Char -> Char -> Char) -> UTF8 ByteString -> Char Source #

FoldableLL (Vector a) a Source # 
Instance details

Defined in Data.ListLike.Vector.Vector

Methods

foldl :: (a0 -> a -> a0) -> a0 -> Vector a -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> Vector a -> a0 Source #

foldl1 :: (a -> a -> a) -> Vector a -> a Source #

foldr :: (a -> b -> b) -> b -> Vector a -> b Source #

foldr' :: (a -> b -> b) -> b -> Vector a -> b Source #

foldr1 :: (a -> a -> a) -> Vector a -> a Source #

Storable a => FoldableLL (Vector a) a Source # 
Instance details

Defined in Data.ListLike.Vector.Storable

Methods

foldl :: (a0 -> a -> a0) -> a0 -> Vector a -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> Vector a -> a0 Source #

foldl1 :: (a -> a -> a) -> Vector a -> a Source #

foldr :: (a -> b -> b) -> b -> Vector a -> b Source #

foldr' :: (a -> b -> b) -> b -> Vector a -> b Source #

foldr1 :: (a -> a -> a) -> Vector a -> a Source #

Unbox a => FoldableLL (Vector a) a Source # 
Instance details

Defined in Data.ListLike.Vector.Unboxed

Methods

foldl :: (a0 -> a -> a0) -> a0 -> Vector a -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> Vector a -> a0 Source #

foldl1 :: (a -> a -> a) -> Vector a -> a Source #

foldr :: (a -> b -> b) -> b -> Vector a -> b Source #

foldr' :: (a -> b -> b) -> b -> Vector a -> b Source #

foldr1 :: (a -> a -> a) -> Vector a -> a Source #

FoldableLL [a] a Source # 
Instance details

Defined in Data.ListLike.FoldableLL

Methods

foldl :: (a0 -> a -> a0) -> a0 -> [a] -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> [a] -> a0 Source #

foldl1 :: (a -> a -> a) -> [a] -> a Source #

foldr :: (a -> b -> b) -> b -> [a] -> b Source #

foldr' :: (a -> b -> b) -> b -> [a] -> b Source #

foldr1 :: (a -> a -> a) -> [a] -> a Source #

Vector v a => FoldableLL (v a) a Source # 
Instance details

Defined in Data.ListLike.Vector.Generic

Methods

foldl :: (a0 -> a -> a0) -> a0 -> v a -> a0 Source #

foldl' :: (a0 -> a -> a0) -> a0 -> v a -> a0 Source #

foldl1 :: (a -> a -> a) -> v a -> a Source #

foldr :: (a -> b -> b) -> b -> v a -> b Source #

foldr' :: (a -> b -> b) -> b -> v a -> b Source #

foldr1 :: (a -> a -> a) -> v a -> a Source #

Ix i => FoldableLL (Array i e) e Source # 
Instance details

Defined in Data.ListLike.Instances

Methods

foldl :: (a -> e -> a) -> a -> Array i e -> a Source #

foldl' :: (a -> e -> a) -> a -> Array i e -> a Source #

foldl1 :: (e -> e -> e) -> Array i e -> e Source #

foldr :: (e -> b -> b) -> b -> Array i e -> b Source #

foldr' :: (e -> b -> b) -> b -> Array i e -> b Source #

foldr1 :: (e -> e -> e) -> Array i e -> e Source #

Utilities

fold :: (FoldableLL full item, Monoid item) => full -> item Source #

Combine the elements of a structure using a monoid. fold = foldMap id

foldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> m Source #

Map each element to a monoid, then combine the results

foldM :: (Monad m, FoldableLL full item) => (a -> item -> m a) -> a -> full -> m a Source #

Monadic version of left fold, similar to foldM.

sequence_ :: (Monad m, FoldableLL full (m item)) => full -> m () Source #

Evaluate each action, ignoring the results. Same as mapM_ id.

mapM_ :: (Monad m, FoldableLL full item) => (item -> m b) -> full -> m () Source #

A map in monad space, discarding results.