/usr/share/doc/libghc-uniplate-doc/html/Data-Generics-Uniplate.html is in libghc-uniplate-doc 1.6.12-6build4.
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 | <!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.Generics.Uniplate</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Data-Generics-Uniplate.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Data-Generics-Uniplate.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">uniplate-1.6.12: Help writing simple, concise and fast generic operations.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Data.Generics.Uniplate</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">The Class</a></li><li><a href="#g:2">The Operations</a><ul><li><a href="#g:3">Queries</a></li><li><a href="#g:4">Transformations</a></li><li><a href="#g:5">Others</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p><em>DEPRECATED</em> Use <a href="Data-Generics-Uniplate-Operations.html">Data.Generics.Uniplate.Operations</a> instead.</p><p>This is the main Uniplate module, which defines all the essential operations
in a Haskell 98 compatible manner.</p><p>Most functions have an example of a possible use for the function.
To illustate, I have used the <code>Expr</code> type as below:</p><pre>data Expr = Val Int
| Neg Expr
| Add Expr Expr</pre></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">type</span> <a href="#t:UniplateType">UniplateType</a> on = on -> ([on], [on] -> on)</li><li class="src short"><span class="keyword">class</span> <a href="#t:Uniplate">Uniplate</a> on <span class="keyword">where</span><ul class="subs"></ul></li><li class="src short"><a href="#v:universe">universe</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [on]</li><li class="src short"><a href="#v:children">children</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [on]</li><li class="src short"><a href="#v:transform">transform</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> on) -> on -> on</li><li class="src short"><a href="#v:transformM">transformM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on) => (on -> m on) -> on -> m on</li><li class="src short"><a href="#v:rewrite">rewrite</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> on) -> on -> on</li><li class="src short"><a href="#v:rewriteM">rewriteM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on) => (on -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> on)) -> on -> m on</li><li class="src short"><a href="#v:descend">descend</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> on) -> on -> on</li><li class="src short"><a href="#v:descendM">descendM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on) => (on -> m on) -> on -> m on</li><li class="src short"><a href="#v:contexts">contexts</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [(on, on -> on)]</li><li class="src short"><a href="#v:holes">holes</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [(on, on -> on)]</li><li class="src short"><a href="#v:para">para</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> [r] -> r) -> on -> r</li></ul></div><div id="interface"><h1 id="g:1">The Class</h1><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:UniplateType" class="def">UniplateType</a> on = on -> ([on], [on] -> on) <a href="src/Data-Generics-Uniplate.html#UniplateType" class="link">Source</a> <a href="#t:UniplateType" class="selflink">#</a></p><div class="doc"><p>The type of replacing all the children of a node</p><p>Taking a value, the function should return all the immediate children
of the same type, and a function to replace them.</p></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a id="t:Uniplate" class="def">Uniplate</a> on <span class="keyword">where</span> <a href="src/Data-Generics-Uniplate.html#Uniplate" class="link">Source</a> <a href="#t:Uniplate" class="selflink">#</a></p><div class="doc"><p>The standard Uniplate class, all operations require this</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="Data-Generics-Uniplate.html#v:uniplate">uniplate</a></p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a id="v:uniplate" class="def">uniplate</a> :: <a href="Data-Generics-Uniplate.html#t:UniplateType">UniplateType</a> on <a href="src/Data-Generics-Uniplate.html#uniplate" class="link">Source</a> <a href="#v:uniplate" class="selflink">#</a></p><div class="doc"><p>The underlying method in the class</p><pre>uniplate (Add (Val 1) (Neg (Val 2))) = ([Val 1, Neg (Val 2)], \[a,b] -> Add a b)
uniplate (Val 1) = ([] , \[] -> Val 1 )</pre></div></div></div><h1 id="g:2">The Operations</h1><h2 id="g:3">Queries</h2><div class="top"><p class="src"><a id="v:universe" class="def">universe</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [on] <a href="src/Data-Generics-Uniplate.html#universe" class="link">Source</a> <a href="#v:universe" class="selflink">#</a></p><div class="doc"><p>Get all the children of a node, including itself and all children.</p><pre>universe (Add (Val 1) (Neg (Val 2))) =
[Add (Val 1) (Neg (Val 2)), Val 1, Neg (Val 2), Val 2]</pre><p>This method is often combined with a list comprehension, for example:</p><pre>vals x = [i | Val i <- universe x]</pre></div></div><div class="top"><p class="src"><a id="v:children" class="def">children</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [on] <a href="src/Data-Generics-Uniplate.html#children" class="link">Source</a> <a href="#v:children" class="selflink">#</a></p><div class="doc"><p>Get the direct children of a node. Usually using <code><a href="Data-Generics-Uniplate.html#v:universe">universe</a></code> is more appropriate.</p><pre>children = fst . <code><a href="Data-Generics-Uniplate.html#v:uniplate">uniplate</a></code></pre></div></div><h2 id="g:4">Transformations</h2><div class="top"><p class="src"><a id="v:transform" class="def">transform</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> on) -> on -> on <a href="src/Data-Generics-Uniplate.html#transform" class="link">Source</a> <a href="#v:transform" class="selflink">#</a></p><div class="doc"><p>Transform every element in the tree, in a bottom-up manner.</p><p>For example, replacing negative literals with literals:</p><pre>negLits = transform f
where f (Neg (Lit i)) = Lit (negate i)
f x = x</pre></div></div><div class="top"><p class="src"><a id="v:transformM" class="def">transformM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on) => (on -> m on) -> on -> m on <a href="src/Data-Generics-Uniplate.html#transformM" class="link">Source</a> <a href="#v:transformM" class="selflink">#</a></p><div class="doc"><p>Monadic variant of <code><a href="Data-Generics-Uniplate.html#v:transform">transform</a></code></p></div></div><div class="top"><p class="src"><a id="v:rewrite" class="def">rewrite</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> on) -> on -> on <a href="src/Data-Generics-Uniplate.html#rewrite" class="link">Source</a> <a href="#v:rewrite" class="selflink">#</a></p><div class="doc"><p>Rewrite by applying a rule everywhere you can. Ensures that the rule cannot
be applied anywhere in the result:</p><pre>propRewrite r x = all (isNothing . r) (universe (rewrite r x))</pre><p>Usually <code><a href="Data-Generics-Uniplate.html#v:transform">transform</a></code> is more appropriate, but <code><a href="Data-Generics-Uniplate.html#v:rewrite">rewrite</a></code> can give better
compositionality. Given two single transformations <code>f</code> and <code>g</code>, you can
construct <code>f <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#v:mplus">mplus</a></code> g</code> which performs both rewrites until a fixed point.</p></div></div><div class="top"><p class="src"><a id="v:rewriteM" class="def">rewriteM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on) => (on -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> on)) -> on -> m on <a href="src/Data-Generics-Uniplate.html#rewriteM" class="link">Source</a> <a href="#v:rewriteM" class="selflink">#</a></p><div class="doc"><p>Monadic variant of <code><a href="Data-Generics-Uniplate.html#v:rewrite">rewrite</a></code></p></div></div><div class="top"><p class="src"><a id="v:descend" class="def">descend</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> on) -> on -> on <a href="src/Data-Generics-Uniplate.html#descend" class="link">Source</a> <a href="#v:descend" class="selflink">#</a></p><div class="doc"><p>Perform a transformation on all the immediate children, then combine them back.
This operation allows additional information to be passed downwards, and can be
used to provide a top-down transformation.</p></div></div><div class="top"><p class="src"><a id="v:descendM" class="def">descendM</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on) => (on -> m on) -> on -> m on <a href="src/Data-Generics-Uniplate.html#descendM" class="link">Source</a> <a href="#v:descendM" class="selflink">#</a></p><div class="doc"><p>Monadic variant of <code><a href="Data-Generics-Uniplate.html#v:descend">descend</a></code> </p></div></div><h2 id="g:5">Others</h2><div class="top"><p class="src"><a id="v:contexts" class="def">contexts</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [(on, on -> on)] <a href="src/Data-Generics-Uniplate.html#contexts" class="link">Source</a> <a href="#v:contexts" class="selflink">#</a></p><div class="doc"><p>Return all the contexts and holes.</p><pre>propUniverse x = universe x == map fst (contexts x)
propId x = all (== x) [b a | (a,b) <- contexts x]</pre></div></div><div class="top"><p class="src"><a id="v:holes" class="def">holes</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => on -> [(on, on -> on)] <a href="src/Data-Generics-Uniplate.html#holes" class="link">Source</a> <a href="#v:holes" class="selflink">#</a></p><div class="doc"><p>The one depth version of <code><a href="Data-Generics-Uniplate.html#v:contexts">contexts</a></code></p><pre>propChildren x = children x == map fst (holes x)
propId x = all (== x) [b a | (a,b) <- holes x]</pre></div></div><div class="top"><p class="src"><a id="v:para" class="def">para</a> :: <a href="Data-Generics-Uniplate.html#t:Uniplate">Uniplate</a> on => (on -> [r] -> r) -> on -> r <a href="src/Data-Generics-Uniplate.html#para" class="link">Source</a> <a href="#v:para" class="selflink">#</a></p><div class="doc"><p>Perform a fold-like computation on each value,
technically a paramorphism</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>
|