base -Data.List  

<p><code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21base%29%20module%3A%28%21Data.List%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f xs</code> is the list obtained by applying <code>f</code> to each element of <code>xs</code>, i.e.,</p><pre>map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]</pre>

base -GHC.OldList  

<p><code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21base%29%20module%3A%28%21GHC.OldList%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f xs</code> is the list obtained by applying <code>f</code> to each element of <code>xs</code>, i.e.,</p><pre>map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]</pre>

base -Prelude  

<p><code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21base%29%20module%3A%28%21Prelude%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f xs</code> is the list obtained by applying <code>f</code> to each element of <code>xs</code>, i.e.,</p><pre>map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]</pre>
map :: (Char -> Char) -> ByteString -> ByteString

bytestring -Data.ByteString.Char8  

<p><em>O(n)</em> <code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%20module%3A%28%21Data.ByteString.Char8%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f xs</code> is the ByteString obtained by applying <code>f</code> to each element of <code>xs</code></p>
map :: (Char -> Char) -> ByteString -> ByteString

bytestring -Data.ByteString.Lazy.Char8  

<p><em>O(n)</em> <code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%20module%3A%28%21Data.ByteString.Lazy.Char8%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f xs</code> is the ByteString obtained by applying <code>f</code> to each element of <code>xs</code></p>
map :: (Word8 -> Word8) -> ByteString -> ByteString

bytestring -Data.ByteString.Lazy  

<p><em>O(n)</em> <code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%20module%3A%28%21Data.ByteString.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f xs</code> is the ByteString obtained by applying <code>f</code> to each element of <code>xs</code>.</p>
map :: (Word8 -> Word8) -> ByteString -> ByteString

bytestring -Data.ByteString  

<p><em>O(n)</em> <code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%20module%3A%28%21Data.ByteString%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21bytestring%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f xs</code> is the ByteString obtained by applying <code>f</code> to each element of <code>xs</code>.</p>
map :: (a -> b) -> IntMap a -> IntMap b

containers -Data.IntMap.Lazy  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: (a -> b) -> IntMap a -> IntMap b

containers -Data.IntMap.Strict  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: (Key -> Key) -> IntSet -> IntSet

containers -Data.IntSet  

<p><em>O(n*min(n,W))</em>. <code><code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.IntSet%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> f s</code> is the set obtained by applying <code>f</code> to each element of <code>s</code>.</p><p>It's worth noting that the size of the result may be smaller if, for some <code>(x,y)</code>, <code>x /= y && f x == f y</code></p>
map :: (a -> b) -> Map k a -> Map k b

containers -Data.Map.Lazy  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: (a -> b) -> Map k a -> Map k b

containers -Data.Map.Strict  

<p><em>O(n)</em>. Map a function over all values in the map.</p><pre>map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]</pre>
map :: Ord b => (a -> b) -> Set a -> Set b

containers -Data.Set  

<p><em>O(n*log n)</em>. <code><code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%20module%3A%28%21Data.Set%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21containers%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> f s</code> is the set obtained by applying <code>f</code> to each element of <code>s</code>.</p><p>It's worth noting that the size of the result may be smaller if, for some <code>(x,y)</code>, <code>x /= y && f x == f y</code></p>
map :: (Char -> Char) -> Stream Char -> Stream Char

text -Data.Text.Internal.Fusion.Common  

<p><em>O(n)</em> <code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21text%29%20module%3A%28%21Data.Text.Internal.Fusion.Common%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21text%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f </code>xs is the Stream Char obtained by applying <code>f</code> to each element of <code>xs</code>.</p>
map :: (Char -> Char) -> Text -> Text

text -Data.Text.Lazy  

<p><em>O(n)</em> <code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21text%29%20module%3A%28%21Data.Text.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21text%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f</code> <code>t</code> is the <code><a href="/?query=%28%28name%3A%28%21Text%29%20package%3A%28%21text%29%20module%3A%28%21Data.Text.Lazy%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Text%29%20package%3A%28%21text%29%29%5E10.0%29%20OR%20name%3A%28%21Text%29">Text</a></code> obtained by applying <code>f</code> to each element of <code>t</code>. Subject to fusion. Performs replacement on invalid scalar values.</p>
map :: (Char -> Char) -> Text -> Text

text -Data.Text  

<p><em>O(n)</em> <code><a href="/?query=%28%28name%3A%28%21map%29%20package%3A%28%21text%29%20module%3A%28%21Data.Text%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21map%29%20package%3A%28%21text%29%29%5E10.0%29%20OR%20name%3A%28%21map%29">map</a></code> <code>f</code> <code>t</code> is the <code><a href="/?query=%28%28name%3A%28%21Text%29%20package%3A%28%21text%29%20module%3A%28%21Data.Text%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Text%29%20package%3A%28%21text%29%29%5E10.0%29%20OR%20name%3A%28%21Text%29">Text</a></code> obtained by applying <code>f</code> to each element of <code>t</code>. Subject to fusion. Performs replacement on invalid scalar values.</p>

uniplate -Data.Generics.Uniplate.Data.Instances  

<div class="doc"><p>In some cases, <code><a href="/?query=%28%28name%3A%28%21Data%29%20package%3A%28%21base%29%20module%3A%28%21Data.Data%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21Data%29">Data</a></code> instances for abstract types are incorrect, and fail to work correctly with Uniplate. This module defines three helper types (<code><a href="/?query=%28%28name%3A%28%21Hide%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Hide%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Hide%29">Hide</a></code>, <code><a href="/?query=%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Trigger%29">Trigger</a></code> and <code><a href="/?query=%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Invariant%29">Invariant</a></code>) to assist when writing instances for abstract types. The <code><a href="/?query=%28%28name%3A%28%21Hide%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Hide%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Hide%29">Hide</a></code> type is useful when you want to mark some part of your data type as being ignored by <a href="/?query=%28%28name%3A%28%21Data.Generics.Uniplate.Data%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data.Generics.Uniplate.Data%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Data.Generics.Uniplate.Data%29">Data.Generics.Uniplate.Data</a> (and any other <code><a href="/?query=%28%28name%3A%28%21Data%29%20package%3A%28%21base%29%20module%3A%28%21Data.Data%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21Data%29">Data</a></code> based generics libraries, such as <code>syb</code>). </p><p>Using the helper types, this module defines wrappers for types in the <code>containers</code> package, namely <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code>, <code><a href="/?query=%28%28name%3A%28%21Set%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Set%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Set%29">Set</a></code>, <code><a href="/?query=%28%28name%3A%28%21IntMap%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21IntMap%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21IntMap%29">IntMap</a></code> and <code><a href="/?query=%28%28name%3A%28%21IntSet%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21IntSet%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21IntSet%29">IntSet</a></code>. The standard <code>containers</code> <code><a href="/?query=%28%28name%3A%28%21Data%29%20package%3A%28%21base%29%20module%3A%28%21Data.Data%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Data%29%20package%3A%28%21base%29%29%5E10.0%29%20OR%20name%3A%28%21Data%29">Data</a></code> instances all treat the types as abstract, but the wrapper types allow you to traverse within the data types, ensuring the necessary invariants are maintained. In particular, if you do not modify the keys reconstruct will be <em>O(n)</em> instead of <em>O(n log n)</em>. </p><p>As an example of how to implement your own abstract type wrappers, the <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> data type is defined as: </p><pre> newtype Map k v = Map (<code><a href="/?query=%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Invariant%29">Invariant</a></code> (<code><a href="/?query=%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Trigger%29">Trigger</a></code> [k], <code><a href="/?query=%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Trigger%29">Trigger</a></code> [v], Hide (Map.Map k v))) deriving (Data, Typeable) </pre><p>The <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> type is defined as an <code><a href="/?query=%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Invariant%29">Invariant</a></code> of three components - the keys, the values, and the underlying <code>Map</code>. We use <code><a href="/?query=%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Invariant%29">Invariant</a></code> to ensure that the keys<em>values</em>map always remain in sync. We use <code><a href="/?query=%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Trigger%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Trigger%29">Trigger</a></code> on the keys and values to ensure that whenever the keys or values change we rebuild the <code>Map</code>, but if they don't, we reuse the previous <code>Map</code>. The <code><a href="/?query=%28%28name%3A%28%21fromMap%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21fromMap%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21fromMap%29">fromMap</a></code> function is implemented by pattern matching on the <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> type: </p><pre> <code><a href="/?query=%28%28name%3A%28%21fromMap%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21fromMap%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21fromMap%29">fromMap</a></code> (<code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> (<code><a href="/?query=%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Invariant%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Invariant%29">Invariant</a></code> _ (_,_,<code><a href="/?query=%28%28name%3A%28%21Hide%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Hide%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Hide%29">Hide</a></code> x))) = x </pre><p>The <code><a href="/?query=%28%28name%3A%28%21toMap%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21toMap%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21toMap%29">toMap</a></code> function is slightly harder, as we need to come up with an invariant restoring function: </p><pre> toMap :: Ord k => Map.Map k v -> Map k v toMap x = Map $ Invariant inv $ create x where create x = (Trigger False ks, Trigger False vs, Hide x) where (ks,vs) = unzip $ Map.toAscList x inv (ks,vs,x) | trigger ks = create $ Map.fromList $ zip (fromTrigger ks) (fromTrigger vs) | trigger vs = create $ Map.fromDistinctAscList $ zip (fromTrigger ks) (fromTrigger vs) | otherwise = (ks,vs,x) </pre><p>The <code>create</code> function creates a value from a <code>Map</code>, getting the correct keys and values. The <code>inv</code> function looks at the triggers on the keys/values. If the keys trigger has been tripped, then we reconstruct the <code>Map</code> using <code>fromList</code>. If the values trigger has been tripped, but they keys trigger has not, we can use <code>fromDistinctAscList</code>, reducing the complexity of constructing the <code>Map</code>. If nothing has changed we can reuse the previous value. </p><p>The end result is that all Uniplate (or <code>syb</code>) traversals over <code><a href="/?query=%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%20module%3A%28%21Data.Generics.Uniplate.Data.Instances%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21Map%29%20package%3A%28%21uniplate%29%29%5E10.0%29%20OR%20name%3A%28%21Map%29">Map</a></code> result in a valid value, which has had all appropriate transformations applied. </p></div>
map :: (a -> b) -> NonEmpty a -> NonEmpty b

semigroups -Data.List.NonEmpty  

<p>Map a function over a <code><a href="/?query=%28%28name%3A%28%21NonEmpty%29%20package%3A%28%21semigroups%29%20module%3A%28%21Data.List.NonEmpty%29%29%5E100.0%29%20OR%20%28%28name%3A%28%21NonEmpty%29%20package%3A%28%21semigroups%29%29%5E10.0%29%20OR%20name%3A%28%21NonEmpty%29">NonEmpty</a></code> stream.</p>
map :: (v1 -> v2) -> HashMap k v1 -> HashMap k v2

unordered-containers -Data.HashMap.Lazy  

<p><em>O(n)</em> Transform this map by applying a function to every value.</p>
map :: (v1 -> v2) -> HashMap k v1 -> HashMap k v2

unordered-containers -Data.HashMap.Strict  

<p><em>O(n)</em> Transform this map by applying a function to every value.</p>