This file is indexed.

/usr/share/doc/libghc-missingh-doc/html/Data-List-Utils.html is in libghc-missingh-doc 1.3.0.1-5build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!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.List.Utils</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-List-Utils.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Data-List-Utils.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">MissingH-1.3.0.1: Large utility library</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>Copyright (C) 2004-2011 John Goerzen</td></tr><tr><th>License</th><td>BSD3</td></tr><tr><th>Maintainer</th><td>John Goerzen &lt;jgoerzen@complete.org&gt; </td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Data.List.Utils</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Merging</a></li><li><a href="#g:2">Tests</a></li><li><a href="#g:3">Association List Utilities</a><ul><li><a href="#g:4">Association List Conversions</a></li></ul></li><li><a href="#g:5">Conversions</a><ul><li><a href="#g:6">Advanced Conversions</a></li></ul></li><li><a href="#g:7">Fixed-Width and State Monad Utilities</a></li><li><a href="#g:8">Miscellaneous</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module provides various helpful utilities for dealing with lists.</p><p>Written by John Goerzen, jgoerzen@complete.org</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"><a href="#v:merge">merge</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ord">Ord</a> a =&gt; [a] -&gt; [a] -&gt; [a]</li><li class="src short"><a href="#v:mergeBy">mergeBy</a> :: (a -&gt; a -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ordering">Ordering</a>) -&gt; [a] -&gt; [a] -&gt; [a]</li><li class="src short"><a href="#v:startswith">startswith</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:endswith">endswith</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:contains">contains</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hasAny">hasAny</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:addToAL">addToAL</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> key =&gt; [(key, elt)] -&gt; key -&gt; elt -&gt; [(key, elt)]</li><li class="src short"><a href="#v:delFromAL">delFromAL</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> key =&gt; [(key, a)] -&gt; key -&gt; [(key, a)]</li><li class="src short"><a href="#v:flipAL">flipAL</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> key, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> val) =&gt; [(key, val)] -&gt; [(val, [key])]</li><li class="src short"><a href="#v:keysAL">keysAL</a> :: [(key, a)] -&gt; [key]</li><li class="src short"><a href="#v:valuesAL">valuesAL</a> :: [(a, value)] -&gt; [value]</li><li class="src short"><a href="#v:hasKeyAL">hasKeyAL</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [(a, b)] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:strFromAL">strFromAL</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> b) =&gt; [(a, b)] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:strToAL">strToAL</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Read.html#t:Read">Read</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Read.html#t:Read">Read</a> b) =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; [(a, b)]</li><li class="src short"><a href="#v:split">split</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; [[a]]</li><li class="src short"><a href="#v:join">join</a> :: [a] -&gt; [[a]] -&gt; [a]</li><li class="src short"><a href="#v:replace">replace</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; [a] -&gt; [a]</li><li class="src short"><a href="#v:genericJoin">genericJoin</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> a =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:takeWhileList">takeWhileList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; [a]</li><li class="src short"><a href="#v:dropWhileList">dropWhileList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; [a]</li><li class="src short"><a href="#v:spanList">spanList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; ([a], [a])</li><li class="src short"><a href="#v:breakList">breakList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; ([a], [a])</li><li class="src short"><span class="keyword">newtype</span> <a href="#t:WholeFunc">WholeFunc</a> a b = <a href="#v:WholeFunc">WholeFunc</a> ([a] -&gt; (<a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a> a b, [a], [b]))</li><li class="src short"><a href="#v:wholeMap">wholeMap</a> :: <a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a> a b -&gt; [a] -&gt; [b]</li><li class="src short"><a href="#v:fixedWidth">fixedWidth</a> :: [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a>] -&gt; <a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a> a [a]</li><li class="src short"><a href="#v:grab">grab</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Lazy.html#t:State">State</a> [a] [a]</li><li class="src short"><a href="#v:countElem">countElem</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:elemRIndex">elemRIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:alwaysElemRIndex">alwaysElemRIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:seqList">seqList</a> :: [a] -&gt; [a]</li><li class="src short"><a href="#v:subIndex">subIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:uniq">uniq</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a]</li></ul></div><div id="interface"><h1 id="g:1">Merging</h1><div class="top"><p class="src"><a name="v:merge" class="def">merge</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ord">Ord</a> a =&gt; [a] -&gt; [a] -&gt; [a] <a href="src/Data-List-Utils.html#merge" class="link">Source</a></p><div class="doc"><p>Merge two sorted lists into a single, sorted whole.</p><p>Example:</p><pre>merge [1,3,5] [1,2,4,6] -&gt; [1,1,2,3,4,5,6]</pre><p>QuickCheck test property:</p><p>prop_merge xs ys =
    merge (sort xs) (sort ys) == sort (xs ++ ys)
          where types = xs :: [Int]</p></div></div><div class="top"><p class="src"><a name="v:mergeBy" class="def">mergeBy</a> :: (a -&gt; a -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Ord.html#t:Ordering">Ordering</a>) -&gt; [a] -&gt; [a] -&gt; [a] <a href="src/Data-List-Utils.html#mergeBy" class="link">Source</a></p><div class="doc"><p>Merge two sorted lists using into a single, sorted whole,
allowing the programmer to specify the comparison function.</p><p>QuickCheck test property:</p><p>prop_mergeBy xs ys =
    mergeBy cmp (sortBy cmp xs) (sortBy cmp ys) == sortBy cmp (xs ++ ys)
          where types = xs :: [ (Int, Int) ]
                cmp (x1,_) (x2,_) = compare x1 x2</p></div></div><h1 id="g:2">Tests</h1><div class="top"><p class="src"><a name="v:startswith" class="def">startswith</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Data-List-Utils.html#startswith" class="link">Source</a></p><div class="doc"><p>Returns true if the given list starts with the specified elements;
false otherwise.  (This is an alias for &quot;Data.List.isPrefixOf&quot;.)</p><p>Example:</p><pre>startswith &quot;He&quot; &quot;Hello&quot; -&gt; True</pre></div></div><div class="top"><p class="src"><a name="v:endswith" class="def">endswith</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Data-List-Utils.html#endswith" class="link">Source</a></p><div class="doc"><p>Returns true if the given list ends with the specified elements;
false otherwise.  (This is an alias for &quot;Data.List.isSuffixOf&quot;.)</p><p>Example:</p><pre>endswith &quot;lo&quot; &quot;Hello&quot; -&gt; True</pre></div></div><div class="top"><p class="src"><a name="v:contains" class="def">contains</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Data-List-Utils.html#contains" class="link">Source</a></p><div class="doc"><div class="warning"><p>Deprecated: Use Data.List.isInfixOf, will be removed in MissingH 1.1.0</p></div><p>Returns true if the given parameter is a sublist of the given list;
false otherwise.</p><p>Example:</p><pre>contains &quot;Haskell&quot; &quot;I really like Haskell.&quot; -&gt; True
contains &quot;Haskell&quot; &quot;OCaml is great.&quot; -&gt; False</pre><p>This function was submitted to GHC and was applied as
<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/GHC-OldList.html#v:isInfixOf">isInfixOf</a></code>.  This function therefore is deprecated and will
be removed in future versions.</p></div></div><div class="top"><p class="src"><a name="v:hasAny" class="def">hasAny</a> <a href="src/Data-List-Utils.html#hasAny" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">=&gt; [a]</td><td class="doc"><p>List of elements to look for</p></td></tr><tr><td class="src">-&gt; [a]</td><td class="doc"><p>List to search</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc"><p>Result</p></td></tr></table></div><div class="doc"><p>Returns true if the given list contains any of the elements in the search
list. </p></div></div><h1 id="g:3">Association List Utilities</h1><div class="doc"><p>These functions are designed to augment the
                     association list functions in <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-List.html">Data.List</a> and
                     provide an interface similar to <a href="Data-FiniteMap.html">Data.FiniteMap</a> or
                     <a href="file:///usr/share/doc/ghc-doc/html/libraries/containers-0.5.6.2/Data-Map.html">Data.Map</a>
                     for association lists. </p></div><div class="top"><p class="src"><a name="v:addToAL" class="def">addToAL</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> key =&gt; [(key, elt)] -&gt; key -&gt; elt -&gt; [(key, elt)] <a href="src/Data-List-Utils.html#addToAL" class="link">Source</a></p><div class="doc"><p>Adds the specified (key, value) pair to the given list, removing any
existing pair with the same key already present. </p></div></div><div class="top"><p class="src"><a name="v:delFromAL" class="def">delFromAL</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> key =&gt; [(key, a)] -&gt; key -&gt; [(key, a)] <a href="src/Data-List-Utils.html#delFromAL" class="link">Source</a></p><div class="doc"><p>Removes all (key, value) pairs from the given list where the key
matches the given one. </p></div></div><div class="top"><p class="src"><a name="v:flipAL" class="def">flipAL</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> key, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> val) =&gt; [(key, val)] -&gt; [(val, [key])] <a href="src/Data-List-Utils.html#flipAL" class="link">Source</a></p><div class="doc"><p>Flips an association list.  Converts (key1, val), (key2, val) pairs
to (val, [key1, key2]). </p></div></div><div class="top"><p class="src"><a name="v:keysAL" class="def">keysAL</a> :: [(key, a)] -&gt; [key] <a href="src/Data-List-Utils.html#keysAL" class="link">Source</a></p><div class="doc"><p>Returns the keys that comprise the (key, value) pairs of the given AL.</p><p>Same as:</p><pre>map fst</pre></div></div><div class="top"><p class="src"><a name="v:valuesAL" class="def">valuesAL</a> :: [(a, value)] -&gt; [value] <a href="src/Data-List-Utils.html#valuesAL" class="link">Source</a></p><div class="doc"><p>Returns the values the comprise the (key, value) pairs of the given
AL.</p><p>Same as:</p><pre>map snd</pre></div></div><div class="top"><p class="src"><a name="v:hasKeyAL" class="def">hasKeyAL</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [(a, b)] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Data-List-Utils.html#hasKeyAL" class="link">Source</a></p><div class="doc"><p>Indicates whether or not the given key is in the AL. </p></div></div><h2 id="g:4">Association List Conversions</h2><div class="top"><p class="src"><a name="v:strFromAL" class="def">strFromAL</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> b) =&gt; [(a, b)] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> <a href="src/Data-List-Utils.html#strFromAL" class="link">Source</a></p><div class="doc"><p>Converts an association list to a string.  The string will have
one pair per line, with the key and value both represented as a Haskell string.</p><p>This function is designed to work with [(String, String)] association lists,
but may work with other types as well. </p></div></div><div class="top"><p class="src"><a name="v:strToAL" class="def">strToAL</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Read.html#t:Read">Read</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Read.html#t:Read">Read</a> b) =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; [(a, b)] <a href="src/Data-List-Utils.html#strToAL" class="link">Source</a></p><div class="doc"><p>The inverse of <code><a href="Data-List-Utils.html#v:strFromAL">strFromAL</a></code>, this function reads a string and outputs the
appropriate association list. </p><p>Like <code><a href="Data-List-Utils.html#v:strFromAL">strFromAL</a></code>, this is designed to work with [(String, String)] association
lists but may also work with other objects with simple representations.</p></div></div><h1 id="g:5">Conversions</h1><div class="top"><p class="src"><a name="v:split" class="def">split</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; [[a]] <a href="src/Data-List-Utils.html#split" class="link">Source</a></p><div class="doc"><p>Given a delimiter and a list (or string), split into components.</p><p>Example:</p><pre>split &quot;,&quot; &quot;foo,bar,,baz,&quot; -&gt; [&quot;foo&quot;, &quot;bar&quot;, &quot;&quot;, &quot;baz&quot;, &quot;&quot;]</pre><pre>split &quot;ba&quot; &quot;,foo,bar,,baz,&quot; -&gt; [&quot;,foo,&quot;,&quot;r,,&quot;,&quot;z,&quot;]</pre></div></div><div class="top"><p class="src"><a name="v:join" class="def">join</a> :: [a] -&gt; [[a]] -&gt; [a] <a href="src/Data-List-Utils.html#join" class="link">Source</a></p><div class="doc"><p>Given a delimiter and a list of items (or strings), join the items
by using the delimiter.</p><p>Example:</p><pre>join &quot;|&quot; [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;] -&gt; &quot;foo|bar|baz&quot;</pre></div></div><div class="top"><p class="src"><a name="v:replace" class="def">replace</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; [a] -&gt; [a] <a href="src/Data-List-Utils.html#replace" class="link">Source</a></p><div class="doc"><p>Given a list and a replacement list, replaces each occurance of the search
list with the replacement list in the operation list.</p><p>Example:</p><pre>replace &quot;,&quot; &quot;.&quot; &quot;127,0,0,1&quot; -&gt; &quot;127.0.0.1&quot;</pre><p>This could logically be thought of as:</p><pre>replace old new l = join new . split old $ l</pre></div></div><div class="top"><p class="src"><a name="v:genericJoin" class="def">genericJoin</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a> a =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> <a href="src/Data-List-Utils.html#genericJoin" class="link">Source</a></p><div class="doc"><p>Like <code><a href="Data-List-Utils.html#v:join">join</a></code>, but works with a list of anything showable, converting
it to a String.</p><p>Examples:</p><pre>genericJoin &quot;, &quot; [1, 2, 3, 4] -&gt; &quot;1, 2, 3, 4&quot;
genericJoin &quot;|&quot; [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;] -&gt; &quot;\&quot;foo\&quot;|\&quot;bar\&quot;|\&quot;baz\&quot;&quot;</pre></div></div><div class="top"><p class="src"><a name="v:takeWhileList" class="def">takeWhileList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; [a] <a href="src/Data-List-Utils.html#takeWhileList" class="link">Source</a></p><div class="doc"><p>Similar to Data.List.takeWhile, takes elements while the func is true.
The function is given the remainder of the list to examine. </p></div></div><div class="top"><p class="src"><a name="v:dropWhileList" class="def">dropWhileList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; [a] <a href="src/Data-List-Utils.html#dropWhileList" class="link">Source</a></p><div class="doc"><p>Similar to Data.List.dropWhile, drops elements while the func is true.
The function is given the remainder of the list to examine. </p></div></div><div class="top"><p class="src"><a name="v:spanList" class="def">spanList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; ([a], [a]) <a href="src/Data-List-Utils.html#spanList" class="link">Source</a></p><div class="doc"><p>Similar to Data.List.span, but performs the test on the entire remaining
list instead of just one element. </p><p><code>spanList p xs</code> is the same as <code>(takeWhileList p xs, dropWhileList p xs)</code> </p></div></div><div class="top"><p class="src"><a name="v:breakList" class="def">breakList</a> :: ([a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a>) -&gt; [a] -&gt; ([a], [a]) <a href="src/Data-List-Utils.html#breakList" class="link">Source</a></p><div class="doc"><p>Similar to Data.List.break, but performs the test on the entire remaining
list instead of just one element.</p></div></div><h2 id="g:6">Advanced Conversions</h2><div class="top"><p class="src"><span class="keyword">newtype</span> <a name="t:WholeFunc" class="def">WholeFunc</a> a b <a href="src/Data-List-Utils.html#WholeFunc" class="link">Source</a></p><div class="doc"><p>The type used for functions for <code><a href="Data-List-Utils.html#v:wholeMap">wholeMap</a></code>.  See <code><a href="Data-List-Utils.html#v:wholeMap">wholeMap</a></code> for details.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:WholeFunc" class="def">WholeFunc</a> ([a] -&gt; (<a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a> a b, [a], [b]))</td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:wholeMap" class="def">wholeMap</a> :: <a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a> a b -&gt; [a] -&gt; [b] <a href="src/Data-List-Utils.html#wholeMap" class="link">Source</a></p><div class="doc"><p>This is an enhanced version of the concatMap or map functions in 
Data.List.</p><p>Unlike those functions, this one:</p><ul><li>Can consume a varying number of elements from the input list during
   each iteration</li><li>Can arbitrarily decide when to stop processing data</li><li>Can return a varying number of elements to insert into the output list</li><li>Can actually switch processing functions mid-stream</li><li>Is not even restricted to processing the input list intact</li></ul><p>The function used by wholeMap, of type <code><a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a></code>, is repeatedly called
with the input list.  The function returns three things: the function
to call for the next iteration (if any), what remains of the input list,
and the list of output elements generated during this iteration.  The return
value of <code><a href="Data-List-Utils.html#v:wholeMap">wholeMap</a></code> is the concatenation of the output element lists from
all iterations.</p><p>Processing stops when the remaining input list is empty.  An example
of a <code><a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a></code> is <code><a href="Data-List-Utils.html#v:fixedWidth">fixedWidth</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:fixedWidth" class="def">fixedWidth</a> :: [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a>] -&gt; <a href="Data-List-Utils.html#t:WholeFunc">WholeFunc</a> a [a] <a href="src/Data-List-Utils.html#fixedWidth" class="link">Source</a></p><div class="doc"><p>A parser designed to process fixed-width input fields.  Use it with
<code><a href="Data-List-Utils.html#v:wholeMap">wholeMap</a></code>.</p><p>The Int list passed to this function is the list of the field widths desired
from the input.  The result is a list of those widths, if possible.  If any
of the input remains after processing this list, it is added on as the final
element in the result list.  If the input is less than the sum of the requested
widths, then the result list will be short the appropriate number of elements,
and its final element may be shorter than requested.</p><p>Examples:</p><pre>wholeMap (fixedWidth [1, 2, 3]) &quot;1234567890&quot;
 --&gt; [&quot;1&quot;,&quot;23&quot;,&quot;456&quot;,&quot;7890&quot;]
wholeMap (fixedWidth (repeat 2)) &quot;123456789&quot;
 --&gt; [&quot;12&quot;,&quot;34&quot;,&quot;56&quot;,&quot;78&quot;,&quot;9&quot;]
wholeMap (fixedWidth []) &quot;123456789&quot;
 --&gt; [&quot;123456789&quot;]
wholeMap (fixedWidth [5, 3, 6, 1]) &quot;Hello, This is a test.&quot;
 --&gt; [&quot;Hello&quot;,&quot;, T&quot;,&quot;his is&quot;,&quot; &quot;,&quot;a test.&quot;]</pre></div></div><h1 id="g:7">Fixed-Width and State Monad Utilities</h1><div class="top"><p class="src"><a name="v:grab" class="def">grab</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Lazy.html#t:State">State</a> [a] [a] <a href="src/Data-List-Utils.html#grab" class="link">Source</a></p><div class="doc"><p>Helps you pick out fixed-width components from a list.</p><p>Example:</p><pre>conv :: String -&gt; (String,String)
conv = runState $
        do f3 &lt;- grab 3
           n2 &lt;- grab 2
           return $ f3 ++ &quot;,&quot; ++ n2

main = print $ conv &quot;TestIng&quot;</pre><p>Prints:</p><pre>(&quot;Tes,tI&quot;,&quot;ng&quot;)</pre></div></div><h1 id="g:8">Miscellaneous</h1><div class="top"><p class="src"><a name="v:countElem" class="def">countElem</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> <a href="src/Data-List-Utils.html#countElem" class="link">Source</a></p><div class="doc"><p>Returns a count of the number of times the given element occured in the
given list. </p></div></div><div class="top"><p class="src"><a name="v:elemRIndex" class="def">elemRIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> <a href="src/Data-List-Utils.html#elemRIndex" class="link">Source</a></p><div class="doc"><p>Returns the rightmost index of the given element in the
given list. </p></div></div><div class="top"><p class="src"><a name="v:alwaysElemRIndex" class="def">alwaysElemRIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; a -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> <a href="src/Data-List-Utils.html#alwaysElemRIndex" class="link">Source</a></p><div class="doc"><p>Like elemRIndex, but returns -1 if there is nothing
found. </p></div></div><div class="top"><p class="src"><a name="v:seqList" class="def">seqList</a> :: [a] -&gt; [a] <a href="src/Data-List-Utils.html#seqList" class="link">Source</a></p><div class="doc"><p>Forces the evaluation of the entire list. </p></div></div><div class="top"><p class="src"><a name="v:subIndex" class="def">subIndex</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> <a href="src/Data-List-Utils.html#subIndex" class="link">Source</a></p><div class="doc"><p>Similar to Data.List.elemIndex.  Instead of looking for one element in a
list, this function looks for the first occurance of a sublist in the list,
and returns the index of the first element of that occurance.  If there is no
such list, returns Nothing.</p><p>If the list to look for is the empty list, will return Just 0 regardless
of the content of the list to search.</p><p>Examples:</p><pre>subIndex &quot;foo&quot; &quot;asdfoobar&quot; -&gt; Just 3
subIndex &quot;foo&quot; [] -&gt; Nothing
subIndex &quot;&quot; [] -&gt; Just 0
subIndex &quot;&quot; &quot;asdf&quot; -&gt; Just 0
subIndex &quot;test&quot; &quot;asdftestbartest&quot; -&gt; Just 4
subIndex [(1::Int), 2] [0, 5, 3, 2, 1, 2, 4] -&gt; Just 4</pre></div></div><div class="top"><p class="src"><a name="v:uniq" class="def">uniq</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; [a] -&gt; [a] <a href="src/Data-List-Utils.html#uniq" class="link">Source</a></p><div class="doc"><p>Given a list, returns a new list with all duplicate elements removed.
For example:</p><pre>uniq &quot;Mississippi&quot; -&gt; &quot;Misp&quot;</pre><p>You should not rely on this function necessarily preserving order, though
the current implementation happens to.</p><p>This function is not compatible with infinite lists.</p><p>This is presently an alias for Data.List.nub</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>