HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleListLike-4.7.8.4Haskell2010

Data.ListLike.FoldableLL

Generic tools for data structures that can be folded.

Written by John Goerzen, jgoerzen@complete.org

  • 1 class
  • 5 values
  • PackageListLike-4.7.8.4
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFoldableLL.hs

FoldableLL Class

1 declaration
classclass FoldableLL full item | full -> item where
#

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.

Methods

  • foldl :: (a -> item -> a) -> a -> full -> a

    Left-associative fold

  • foldl' :: (a -> item -> a) -> a -> full -> a

    Strict version of foldl.

  • foldl1 :: (item -> item -> item) -> full -> item

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

  • foldr :: (item -> b -> b) -> b -> full -> b

    Right-associative fold

  • foldr' :: (item -> b -> b) -> b -> full -> b

    Strict version of foldr

  • foldr1 :: (item -> item -> item) -> full -> item

    Like foldr, but with no starting value

Instances19FoldableLL, …

Utilities

5 declarations
valuefoldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> m
#

Map each element to a monoid, then combine the results

valuefoldM
  1. :: (Monad m, FoldableLL full item)
  2. => a -> item -> m a
  3. -> a
  4. -> full
  5. -> m a
#

Monadic version of left fold, similar to foldM.

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

A map in monad space, discarding results.