<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Data.Foldable</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Data-Foldable.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">base-4.3.1.0: Basic libraries</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr></table><p class="caption">Data.Foldable</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Folds </a><ul><li><a href="#g:2">Special biased folds </a></li><li><a href="#g:3">Folding actions </a><ul><li><a href="#g:4">Applicative actions </a></li><li><a href="#g:5">Monadic actions </a></li></ul></li><li><a href="#g:6">Specialized folds </a></li><li><a href="#g:7">Searches </a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Class of data structures that can be folded to a summary value. </p><p>Many of these functions generalize <a href="Prelude.html">Prelude</a>, <a href="Control-Monad.html">Control.Monad</a> and <a href="Data-List.html">Data.List</a> functions of the same names from lists to any <code><a href="Data-Foldable.html#t:Foldable">Foldable</a></code> functor. To avoid ambiguity, either import those modules hiding these names or qualify uses of these function names with an alias for this module. </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">class</span> <a href="#t:Foldable">Foldable</a> t <span class="keyword">where</span><ul class="subs"><li><a href="#v:fold">fold</a> :: <a href="Data-Monoid.html#t:Monoid">Monoid</a> m => t m -> m</li><li><a href="#v:foldMap">foldMap</a> :: <a href="Data-Monoid.html#t:Monoid">Monoid</a> m => (a -> m) -> t a -> m</li><li><a href="#v:foldr">foldr</a> :: (a -> b -> b) -> b -> t a -> b</li><li><a href="#v:foldl">foldl</a> :: (a -> b -> a) -> a -> t b -> a</li><li><a href="#v:foldr1">foldr1</a> :: (a -> a -> a) -> t a -> a</li><li><a href="#v:foldl1">foldl1</a> :: (a -> a -> a) -> t a -> a</li></ul></li><li class="src short"><a href="#v:foldr-39-">foldr'</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> b -> b) -> b -> t a -> b</li><li class="src short"><a href="#v:foldl-39-">foldl'</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> b -> a) -> a -> t b -> a</li><li class="src short"><a href="#v:foldrM">foldrM</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => (a -> b -> m b) -> b -> t a -> m b</li><li class="src short"><a href="#v:foldlM">foldlM</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => (a -> b -> m a) -> a -> t b -> m a</li><li class="src short"><a href="#v:traverse_">traverse_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Applicative">Applicative</a> f) => (a -> f b) -> t a -> f <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:for_">for_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Applicative">Applicative</a> f) => t a -> (a -> f b) -> f <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:sequenceA_">sequenceA_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Applicative">Applicative</a> f) => t (f a) -> f <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:asum">asum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Alternative">Alternative</a> f) => t (f a) -> f a</li><li class="src short"><a href="#v:mapM_">mapM_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => (a -> m b) -> t a -> m <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:forM_">forM_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => t a -> (a -> m b) -> m <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:sequence_">sequence_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => t (m a) -> m <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:msum">msum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:MonadPlus">MonadPlus</a> m) => t (m a) -> m a</li><li class="src short"><a href="#v:toList">toList</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t a -> [a]</li><li class="src short"><a href="#v:concat">concat</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t [a] -> [a]</li><li class="src short"><a href="#v:concatMap">concatMap</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> [b]) -> t a -> [b]</li><li class="src short"><a href="#v:and">and</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t <a href="Data-Bool.html#t:Bool">Bool</a> -> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:or">or</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t <a href="Data-Bool.html#t:Bool">Bool</a> -> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:any">any</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> <a href="Data-Bool.html#t:Bool">Bool</a>) -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:all">all</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> <a href="Data-Bool.html#t:Bool">Bool</a>) -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:sum">sum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Prelude.html#t:Num">Num</a> a) => t a -> a</li><li class="src short"><a href="#v:product">product</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Prelude.html#t:Num">Num</a> a) => t a -> a</li><li class="src short"><a href="#v:maximum">maximum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Ord.html#t:Ord">Ord</a> a) => t a -> a</li><li class="src short"><a href="#v:maximumBy">maximumBy</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> a -> <a href="Data-Ord.html#t:Ordering">Ordering</a>) -> t a -> a</li><li class="src short"><a href="#v:minimum">minimum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Ord.html#t:Ord">Ord</a> a) => t a -> a</li><li class="src short"><a href="#v:minimumBy">minimumBy</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> a -> <a href="Data-Ord.html#t:Ordering">Ordering</a>) -> t a -> a</li><li class="src short"><a href="#v:elem">elem</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Eq.html#t:Eq">Eq</a> a) => a -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:notElem">notElem</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Eq.html#t:Eq">Eq</a> a) => a -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:find">find</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> <a href="Data-Bool.html#t:Bool">Bool</a>) -> t a -> <a href="Data-Maybe.html#t:Maybe">Maybe</a> a</li></ul></div><div id="interface"><h1 id="g:1">Folds </h1><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:Foldable" class="def">Foldable</a> t <span class="keyword">where</span></p><div class="doc"><p>Data structures that can be folded. </p><p>Minimal complete definition: <code><a href="Data-Foldable.html#v:foldMap">foldMap</a></code> or <code><a href="Data-Foldable.html#v:foldr">foldr</a></code>. </p><p>For example, given a data type </p><pre> data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) </pre><p>a suitable instance would be </p><pre> instance Foldable Tree where foldMap f Empty = mempty foldMap f (Leaf x) = f x foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r </pre><p>This is suitable even for abstract types, as the monoid is assumed to satisfy the monoid laws. Alternatively, one could define <code>foldr</code>: </p><pre> instance Foldable Tree where foldr f z Empty = z foldr f z (Leaf x) = f x z foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l </pre></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:fold" class="def">fold</a> :: <a href="Data-Monoid.html#t:Monoid">Monoid</a> m => t m -> m</p><div class="doc"><p>Combine the elements of a structure using a monoid. </p></div><p class="src"><a name="v:foldMap" class="def">foldMap</a> :: <a href="Data-Monoid.html#t:Monoid">Monoid</a> m => (a -> m) -> t a -> m</p><div class="doc"><p>Map each element of the structure to a monoid, and combine the results. </p></div><p class="src"><a name="v:foldr" class="def">foldr</a> :: (a -> b -> b) -> b -> t a -> b</p><div class="doc"><p>Right-associative fold of a structure. </p><pre><code><a href="Data-Foldable.html#v:foldr">foldr</a></code> f z = <code><a href="Data-List.html#v:foldr">foldr</a></code> f z . <code><a href="Data-Foldable.html#v:toList">toList</a></code></pre></div><p class="src"><a name="v:foldl" class="def">foldl</a> :: (a -> b -> a) -> a -> t b -> a</p><div class="doc"><p>Left-associative fold of a structure. </p><pre><code><a href="Data-Foldable.html#v:foldl">foldl</a></code> f z = <code><a href="Data-List.html#v:foldl">foldl</a></code> f z . <code><a href="Data-Foldable.html#v:toList">toList</a></code></pre></div><p class="src"><a name="v:foldr1" class="def">foldr1</a> :: (a -> a -> a) -> t a -> a</p><div class="doc"><p>A variant of <code><a href="Data-Foldable.html#v:foldr">foldr</a></code> that has no base case, and thus may only be applied to non-empty structures. </p><pre><code><a href="Data-Foldable.html#v:foldr1">foldr1</a></code> f = <code><a href="Data-List.html#v:foldr1">foldr1</a></code> f . <code><a href="Data-Foldable.html#v:toList">toList</a></code></pre></div><p class="src"><a name="v:foldl1" class="def">foldl1</a> :: (a -> a -> a) -> t a -> a</p><div class="doc"><p>A variant of <code><a href="Data-Foldable.html#v:foldl">foldl</a></code> that has no base case, and thus may only be applied to non-empty structures. </p><pre><code><a href="Data-Foldable.html#v:foldl1">foldl1</a></code> f = <code><a href="Data-List.html#v:foldl1">foldl1</a></code> f . <code><a href="Data-Foldable.html#v:toList">toList</a></code></pre></div></div><div class="subs instances"><p id="control.i:Foldable" class="caption collapser" onclick="toggleSection('i:Foldable')">Instances</p><div id="section.i:Foldable" class="show"><table><tr><td class="src"><a href="Data-Foldable.html#t:Foldable">Foldable</a> []</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Data-Foldable.html#t:Foldable">Foldable</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> i => <a href="Data-Foldable.html#t:Foldable">Foldable</a> (Array i)</td><td class="doc empty"> </td></tr></table></div></div></div><h2 id="g:2">Special biased folds </h2><div class="top"><p class="src"><a name="v:foldr-39-" class="def">foldr'</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> b -> b) -> b -> t a -> b</p><div class="doc"><p>Fold over the elements of a structure, associating to the right, but strictly. </p></div></div><div class="top"><p class="src"><a name="v:foldl-39-" class="def">foldl'</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> b -> a) -> a -> t b -> a</p><div class="doc"><p>Fold over the elements of a structure, associating to the left, but strictly. </p></div></div><div class="top"><p class="src"><a name="v:foldrM" class="def">foldrM</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => (a -> b -> m b) -> b -> t a -> m b</p><div class="doc"><p>Monadic fold over the elements of a structure, associating to the right, i.e. from right to left. </p></div></div><div class="top"><p class="src"><a name="v:foldlM" class="def">foldlM</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => (a -> b -> m a) -> a -> t b -> m a</p><div class="doc"><p>Monadic fold over the elements of a structure, associating to the left, i.e. from left to right. </p></div></div><h2 id="g:3">Folding actions </h2><h3 id="g:4">Applicative actions </h3><div class="top"><p class="src"><a name="v:traverse_" class="def">traverse_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Applicative">Applicative</a> f) => (a -> f b) -> t a -> f <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></p><div class="doc"><p>Map each element of a structure to an action, evaluate these actions from left to right, and ignore the results. </p></div></div><div class="top"><p class="src"><a name="v:for_" class="def">for_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Applicative">Applicative</a> f) => t a -> (a -> f b) -> f <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></p><div class="doc"><p><code><a href="Data-Foldable.html#v:for_">for_</a></code> is <code><a href="Data-Foldable.html#v:traverse_">traverse_</a></code> with its arguments flipped. </p></div></div><div class="top"><p class="src"><a name="v:sequenceA_" class="def">sequenceA_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Applicative">Applicative</a> f) => t (f a) -> f <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></p><div class="doc"><p>Evaluate each action in the structure from left to right, and ignore the results. </p></div></div><div class="top"><p class="src"><a name="v:asum" class="def">asum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Applicative.html#t:Alternative">Alternative</a> f) => t (f a) -> f a</p><div class="doc"><p>The sum of a collection of actions, generalizing <code><a href="Data-Foldable.html#v:concat">concat</a></code>. </p></div></div><h3 id="g:5">Monadic actions </h3><div class="top"><p class="src"><a name="v:mapM_" class="def">mapM_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => (a -> m b) -> t a -> m <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></p><div class="doc"><p>Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results. </p></div></div><div class="top"><p class="src"><a name="v:forM_" class="def">forM_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => t a -> (a -> m b) -> m <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></p><div class="doc"><p><code><a href="Data-Foldable.html#v:forM_">forM_</a></code> is <code><a href="Data-Foldable.html#v:mapM_">mapM_</a></code> with its arguments flipped. </p></div></div><div class="top"><p class="src"><a name="v:sequence_" class="def">sequence_</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:Monad">Monad</a> m) => t (m a) -> m <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></p><div class="doc"><p>Evaluate each monadic action in the structure from left to right, and ignore the results. </p></div></div><div class="top"><p class="src"><a name="v:msum" class="def">msum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Control-Monad.html#t:MonadPlus">MonadPlus</a> m) => t (m a) -> m a</p><div class="doc"><p>The sum of a collection of actions, generalizing <code><a href="Data-Foldable.html#v:concat">concat</a></code>. </p></div></div><h2 id="g:6">Specialized folds </h2><div class="top"><p class="src"><a name="v:toList" class="def">toList</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t a -> [a]</p><div class="doc"><p>List of elements of a structure. </p></div></div><div class="top"><p class="src"><a name="v:concat" class="def">concat</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t [a] -> [a]</p><div class="doc"><p>The concatenation of all the elements of a container of lists. </p></div></div><div class="top"><p class="src"><a name="v:concatMap" class="def">concatMap</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> [b]) -> t a -> [b]</p><div class="doc"><p>Map a function over all the elements of a container and concatenate the resulting lists. </p></div></div><div class="top"><p class="src"><a name="v:and" class="def">and</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t <a href="Data-Bool.html#t:Bool">Bool</a> -> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><code><a href="Data-Foldable.html#v:and">and</a></code> returns the conjunction of a container of Bools. For the result to be <code><a href="Data-Bool.html#v:True">True</a></code>, the container must be finite; <code><a href="Data-Bool.html#v:False">False</a></code>, however, results from a <code><a href="Data-Bool.html#v:False">False</a></code> value finitely far from the left end. </p></div></div><div class="top"><p class="src"><a name="v:or" class="def">or</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => t <a href="Data-Bool.html#t:Bool">Bool</a> -> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><code><a href="Data-Foldable.html#v:or">or</a></code> returns the disjunction of a container of Bools. For the result to be <code><a href="Data-Bool.html#v:False">False</a></code>, the container must be finite; <code><a href="Data-Bool.html#v:True">True</a></code>, however, results from a <code><a href="Data-Bool.html#v:True">True</a></code> value finitely far from the left end. </p></div></div><div class="top"><p class="src"><a name="v:any" class="def">any</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> <a href="Data-Bool.html#t:Bool">Bool</a>) -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Determines whether any element of the structure satisfies the predicate. </p></div></div><div class="top"><p class="src"><a name="v:all" class="def">all</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> <a href="Data-Bool.html#t:Bool">Bool</a>) -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Determines whether all elements of the structure satisfy the predicate. </p></div></div><div class="top"><p class="src"><a name="v:sum" class="def">sum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Prelude.html#t:Num">Num</a> a) => t a -> a</p><div class="doc"><p>The <code><a href="Data-Foldable.html#v:sum">sum</a></code> function computes the sum of the numbers of a structure. </p></div></div><div class="top"><p class="src"><a name="v:product" class="def">product</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Prelude.html#t:Num">Num</a> a) => t a -> a</p><div class="doc"><p>The <code><a href="Data-Foldable.html#v:product">product</a></code> function computes the product of the numbers of a structure. </p></div></div><div class="top"><p class="src"><a name="v:maximum" class="def">maximum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Ord.html#t:Ord">Ord</a> a) => t a -> a</p><div class="doc"><p>The largest element of a non-empty structure. </p></div></div><div class="top"><p class="src"><a name="v:maximumBy" class="def">maximumBy</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> a -> <a href="Data-Ord.html#t:Ordering">Ordering</a>) -> t a -> a</p><div class="doc"><p>The largest element of a non-empty structure with respect to the given comparison function. </p></div></div><div class="top"><p class="src"><a name="v:minimum" class="def">minimum</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Ord.html#t:Ord">Ord</a> a) => t a -> a</p><div class="doc"><p>The least element of a non-empty structure. </p></div></div><div class="top"><p class="src"><a name="v:minimumBy" class="def">minimumBy</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> a -> <a href="Data-Ord.html#t:Ordering">Ordering</a>) -> t a -> a</p><div class="doc"><p>The least element of a non-empty structure with respect to the given comparison function. </p></div></div><h2 id="g:7">Searches </h2><div class="top"><p class="src"><a name="v:elem" class="def">elem</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Eq.html#t:Eq">Eq</a> a) => a -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Does the element occur in the structure? </p></div></div><div class="top"><p class="src"><a name="v:notElem" class="def">notElem</a> :: (<a href="Data-Foldable.html#t:Foldable">Foldable</a> t, <a href="Data-Eq.html#t:Eq">Eq</a> a) => a -> t a -> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p><code><a href="Data-Foldable.html#v:notElem">notElem</a></code> is the negation of <code><a href="Data-Foldable.html#v:elem">elem</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:find" class="def">find</a> :: <a href="Data-Foldable.html#t:Foldable">Foldable</a> t => (a -> <a href="Data-Bool.html#t:Bool">Bool</a>) -> t a -> <a href="Data-Maybe.html#t:Maybe">Maybe</a> a</p><div class="doc"><p>The <code><a href="Data-Foldable.html#v:find">find</a></code> function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code> if there is no such element. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>