/usr/share/doc/libghc-uniplate-doc/html/src/Data-Generics-SYB.html is in libghc-uniplate-doc 1.6.11-2build1.
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>Data/Generics/SYB.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-|
<a name="line-2"></a> SYB compatibility layer. This module serves as a drop-in
<a name="line-3"></a> replacement in some situations for some of the SYB operations.
<a name="line-4"></a> Users should also import "Data.Generics.Uniplate.Data".
<a name="line-5"></a>
<a name="line-6"></a> SYB is described in the paper: \"Scrap your boilerplate: a practical design
<a name="line-7"></a> pattern for generic programming\" by Ralf Lammel and Simon
<a name="line-8"></a> Peyton Jones.
<a name="line-9"></a>
<a name="line-10"></a> * <<a href="http://www.cs.vu.nl/boilerplate/">http://www.cs.vu.nl/boilerplate/</a>>
<a name="line-11"></a>
<a name="line-12"></a> * <<a href="http://doi.acm.org/10.1145/604174.604179">http://doi.acm.org/10.1145/604174.604179</a>>
<a name="line-13"></a>
<a name="line-14"></a> * <<a href="http://www.cs.vu.nl/boilerplate/tldi03.pdf">http://www.cs.vu.nl/boilerplate/tldi03.pdf</a>>
<a name="line-15"></a>-}</span>
<a name="line-16"></a>
<a name="line-17"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Generics</span><span class='hs-varop'>.</span><span class='hs-conid'>SYB</span> <span class='hs-keyword'>where</span>
<a name="line-18"></a>
<a name="line-19"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Generics</span><span class='hs-varop'>.</span><span class='hs-conid'>Uniplate</span><span class='hs-varop'>.</span><span class='hs-conid'>Operations</span>
<a name="line-20"></a>
<a name="line-21"></a><a name="gmapT"></a><span class='hs-comment'>-- | @gmapT == 'descend'@</span>
<a name="line-22"></a><span class='hs-definition'>gmapT</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Uniplate</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span>
<a name="line-23"></a><span class='hs-definition'>gmapT</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>descend</span>
<a name="line-24"></a>
<a name="line-25"></a>
<a name="line-26"></a><a name="gmapQl"></a><span class='hs-comment'>-- | Use 'children' and 'foldl'</span>
<a name="line-27"></a><span class='hs-definition'>gmapQl</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Uniplate</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r'</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r'</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span>
<a name="line-28"></a><span class='hs-definition'>gmapQl</span> <span class='hs-varid'>combine</span> <span class='hs-varid'>zero</span> <span class='hs-varid'>op</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>foldl</span> <span class='hs-varid'>combine</span> <span class='hs-varid'>zero</span> <span class='hs-varop'>.</span> <span class='hs-varid'>map</span> <span class='hs-varid'>op</span> <span class='hs-varop'>.</span> <span class='hs-varid'>children</span>
<a name="line-29"></a>
<a name="line-30"></a>
<a name="line-31"></a><a name="gmapQr"></a><span class='hs-comment'>-- | Use 'children' and 'foldr'</span>
<a name="line-32"></a><span class='hs-definition'>gmapQr</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Uniplate</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>r'</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r'</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span>
<a name="line-33"></a><span class='hs-definition'>gmapQr</span> <span class='hs-varid'>combine</span> <span class='hs-varid'>zero</span> <span class='hs-varid'>op</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>foldr</span> <span class='hs-varid'>combine</span> <span class='hs-varid'>zero</span> <span class='hs-varop'>.</span> <span class='hs-varid'>map</span> <span class='hs-varid'>op</span> <span class='hs-varop'>.</span> <span class='hs-varid'>children</span>
<a name="line-34"></a>
<a name="line-35"></a>
<a name="line-36"></a><a name="gmapQ"></a><span class='hs-comment'>-- | Use 'children'</span>
<a name="line-37"></a><span class='hs-definition'>gmapQ</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Uniplate</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>u</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>u</span><span class='hs-keyglyph'>]</span>
<a name="line-38"></a><span class='hs-definition'>gmapQ</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>map</span> <span class='hs-varid'>f</span> <span class='hs-varop'>.</span> <span class='hs-varid'>children</span>
<a name="line-39"></a>
<a name="line-40"></a>
<a name="line-41"></a><a name="gmapQi"></a><span class='hs-comment'>-- | Use 'children' and '!!'</span>
<a name="line-42"></a><span class='hs-definition'>gmapQi</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Uniplate</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Int</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>u</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>u</span>
<a name="line-43"></a><span class='hs-definition'>gmapQi</span> <span class='hs-varid'>i</span> <span class='hs-varid'>f</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>gmapQ</span> <span class='hs-varid'>f</span> <span class='hs-varid'>x</span> <span class='hs-varop'>!!</span> <span class='hs-varid'>i</span>
<a name="line-44"></a>
<a name="line-45"></a>
<a name="line-46"></a><a name="gmapM"></a><span class='hs-comment'>-- | @gmapM == 'descendM'@</span>
<a name="line-47"></a><span class='hs-definition'>gmapM</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Uniplate</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span>
<a name="line-48"></a><span class='hs-definition'>gmapM</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>descendM</span>
<a name="line-49"></a>
<a name="line-50"></a>
<a name="line-51"></a>
<a name="line-52"></a><a name="mkT"></a><span class='hs-comment'>-- | @mkT == 'id'@</span>
<a name="line-53"></a><span class='hs-definition'>mkT</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-54"></a><span class='hs-definition'>mkT</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>id</span>
<a name="line-55"></a>
<a name="line-56"></a>
<a name="line-57"></a><a name="everywhere"></a><span class='hs-comment'>-- | @everywhere == 'transformBi'@</span>
<a name="line-58"></a><span class='hs-definition'>everywhere</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Biplate</span> <span class='hs-varid'>b</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>b</span>
<a name="line-59"></a><span class='hs-definition'>everywhere</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>transformBi</span>
<a name="line-60"></a>
<a name="line-61"></a>
<a name="line-62"></a><a name="mkM"></a><span class='hs-comment'>-- | @mkM == id@</span>
<a name="line-63"></a><span class='hs-definition'>mkM</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span>
<a name="line-64"></a><span class='hs-definition'>mkM</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>id</span>
<a name="line-65"></a>
<a name="line-66"></a>
<a name="line-67"></a><a name="everywhereM"></a><span class='hs-comment'>-- | @everywhereM == 'transformBiM'@</span>
<a name="line-68"></a><span class='hs-definition'>everywhereM</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Biplate</span> <span class='hs-varid'>b</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>b</span>
<a name="line-69"></a><span class='hs-definition'>everywhereM</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>transformBiM</span>
<a name="line-70"></a>
<a name="line-71"></a>
<a name="line-72"></a>
<a name="line-73"></a><a name="mkQ"></a><span class='hs-comment'>-- | Only for use with 'everything'</span>
<a name="line-74"></a><span class='hs-definition'>mkQ</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>r</span><span class='hs-layout'>,</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span><span class='hs-layout'>)</span>
<a name="line-75"></a><span class='hs-definition'>mkQ</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>(,)</span>
<a name="line-76"></a>
<a name="line-77"></a>
<a name="line-78"></a><a name="everything"></a><span class='hs-comment'>-- | Use 'universe' or 'universeBi', perhaps followed by a fold.</span>
<a name="line-79"></a><span class='hs-comment'>--</span>
<a name="line-80"></a><span class='hs-comment'>-- Not an exact equivalent to the SYB @everything@, as the</span>
<a name="line-81"></a><span class='hs-comment'>-- operators may be applied in different orders.</span>
<a name="line-82"></a><span class='hs-definition'>everything</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Biplate</span> <span class='hs-varid'>b</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=></span> <span class='hs-layout'>(</span><span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>r</span><span class='hs-layout'>,</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>r</span>
<a name="line-83"></a><span class='hs-definition'>everything</span> <span class='hs-varid'>combine</span> <span class='hs-layout'>(</span><span class='hs-varid'>nil</span><span class='hs-layout'>,</span> <span class='hs-varid'>op</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>foldl</span> <span class='hs-varid'>combine</span> <span class='hs-varid'>nil</span> <span class='hs-varop'>.</span> <span class='hs-varid'>map</span> <span class='hs-varid'>op</span> <span class='hs-varop'>.</span> <span class='hs-varid'>universeBi</span>
</pre></body>
</html>
|