/usr/share/doc/libghc-hxt-doc/html/src/Data-Tree-NTree-Zipper-TypeDefs.html is in libghc-hxt-doc 9.3.1.4-1.
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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | <?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>src/Data/Tree/NTree/Zipper/TypeDefs.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}</span>
<a name="line-2"></a><span class='hs-comment'>{-# OPTIONS -fno-warn-orphans #-}</span>
<a name="line-3"></a>
<a name="line-4"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-5"></a>
<a name="line-6"></a><span class='hs-comment'>{- |
<a name="line-7"></a> Module : Data.Tree.NTree.Zipper.TypeDefs
<a name="line-8"></a> Copyright : Copyright (C) 2010 Uwe Schmidt
<a name="line-9"></a> License : MIT
<a name="line-10"></a>
<a name="line-11"></a> Maintainer : Uwe Schmidt (uwe\@fh-wedel.de)
<a name="line-12"></a> Stability : stable
<a name="line-13"></a> Portability: portable
<a name="line-14"></a>
<a name="line-15"></a> Implementation of navigateble trees for
<a name="line-16"></a> rose trees. The implementation is done with zippers.
<a name="line-17"></a> A description and introductory tutorial about zippers
<a name="line-18"></a> can be found in <<a href="http://learnyouahaskell.com/zippers">http://learnyouahaskell.com/zippers</a>>
<a name="line-19"></a>-}</span>
<a name="line-20"></a>
<a name="line-21"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-22"></a>
<a name="line-23"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Tree</span><span class='hs-varop'>.</span><span class='hs-conid'>NTree</span><span class='hs-varop'>.</span><span class='hs-conid'>Zipper</span><span class='hs-varop'>.</span><span class='hs-conid'>TypeDefs</span>
<a name="line-24"></a><span class='hs-comment'>{-
<a name="line-25"></a> ( NTZipper
<a name="line-26"></a> , NTree
<a name="line-27"></a> , toNTZipper
<a name="line-28"></a> , fromNTZipper
<a name="line-29"></a> )
<a name="line-30"></a>-}</span>
<a name="line-31"></a><span class='hs-keyword'>where</span>
<a name="line-32"></a>
<a name="line-33"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Tree</span><span class='hs-varop'>.</span><span class='hs-conid'>Class</span>
<a name="line-34"></a>
<a name="line-35"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Tree</span><span class='hs-varop'>.</span><span class='hs-conid'>NavigatableTree</span><span class='hs-varop'>.</span><span class='hs-conid'>Class</span>
<a name="line-36"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Tree</span><span class='hs-varop'>.</span><span class='hs-conid'>NavigatableTree</span><span class='hs-varop'>.</span><span class='hs-conid'>XPathAxis</span> <span class='hs-layout'>(</span> <span class='hs-varid'>childAxis</span> <span class='hs-layout'>)</span>
<a name="line-37"></a>
<a name="line-38"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Tree</span><span class='hs-varop'>.</span><span class='hs-conid'>NTree</span><span class='hs-varop'>.</span><span class='hs-conid'>TypeDefs</span>
<a name="line-39"></a>
<a name="line-40"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-41"></a>
<a name="line-42"></a><span class='hs-comment'>-- | Zipper for rose trees</span>
<a name="line-43"></a><span class='hs-comment'>--</span>
<a name="line-44"></a><span class='hs-comment'>-- A zipper consist of the current tree and the branches on the way back to the root</span>
<a name="line-45"></a>
<a name="line-46"></a><a name="NTZipper"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTZ</span>
<a name="line-47"></a> <span class='hs-layout'>{</span> <span class='hs-varid'>ntree</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTree</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-48"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>context</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTBreadCrumbs</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-49"></a> <span class='hs-layout'>}</span>
<a name="line-50"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Show</span><span class='hs-layout'>)</span>
<a name="line-51"></a>
<a name="line-52"></a><span class='hs-comment'>-- | The list of unzipped nodes from a current tree back to the root</span>
<a name="line-53"></a>
<a name="line-54"></a><a name="NTBreadCrumbs"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>NTBreadCrumbs</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>NTCrumb</span> <span class='hs-varid'>a</span><span class='hs-keyglyph'>]</span>
<a name="line-55"></a>
<a name="line-56"></a><span class='hs-comment'>-- | One unzipped step consists of the left siblings, the node info and the right siblings</span>
<a name="line-57"></a>
<a name="line-58"></a><a name="NTCrumb"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>NTCrumb</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTC</span>
<a name="line-59"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTrees</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-comment'>-- left side</span>
<a name="line-60"></a> <span class='hs-varid'>a</span> <span class='hs-comment'>-- node</span>
<a name="line-61"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTrees</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-comment'>-- right side</span>
<a name="line-62"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Show</span><span class='hs-layout'>)</span>
<a name="line-63"></a>
<a name="line-64"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-65"></a>
<a name="line-66"></a><span class='hs-comment'>-- | Conversion of a rose tree into a navigatable rose tree</span>
<a name="line-67"></a>
<a name="line-68"></a><a name="toNTZipper"></a><span class='hs-definition'>toNTZipper</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTree</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span>
<a name="line-69"></a><span class='hs-definition'>toNTZipper</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t</span> <span class='hs-conid'>[]</span>
<a name="line-70"></a>
<a name="line-71"></a><span class='hs-comment'>{-# INLINE toNTZipper #-}</span>
<a name="line-72"></a>
<a name="line-73"></a><span class='hs-comment'>-- | Conversion of a navigatable rose tree into an ordinary rose tree.</span>
<a name="line-74"></a><span class='hs-comment'>--</span>
<a name="line-75"></a><span class='hs-comment'>-- The context, the parts for moving up to the root are just removed from the tree.</span>
<a name="line-76"></a><span class='hs-comment'>-- So when transforming a navigatable tree by moving around and by changing some nodes,</span>
<a name="line-77"></a><span class='hs-comment'>-- one has to navigate back</span>
<a name="line-78"></a><span class='hs-comment'>-- to the root, else that parts are removed from the result</span>
<a name="line-79"></a>
<a name="line-80"></a><a name="fromNTZipper"></a><span class='hs-definition'>fromNTZipper</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>NTree</span> <span class='hs-varid'>a</span>
<a name="line-81"></a><span class='hs-definition'>fromNTZipper</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ntree</span>
<a name="line-82"></a>
<a name="line-83"></a><span class='hs-comment'>{-# INLINE fromNTZipper #-}</span>
<a name="line-84"></a>
<a name="line-85"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-86"></a>
<a name="line-87"></a><a name="up"></a><span class='hs-definition'>up</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-88"></a><span class='hs-definition'>up</span> <span class='hs-varid'>z</span>
<a name="line-89"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isTop</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-90"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-layout'>(</span><span class='hs-varid'>up1</span> <span class='hs-varid'>t</span> <span class='hs-varid'>bc</span><span class='hs-layout'>)</span> <span class='hs-varid'>bcs</span>
<a name="line-91"></a> <span class='hs-keyword'>where</span>
<a name="line-92"></a> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>z</span>
<a name="line-93"></a>
<a name="line-94"></a><span class='hs-comment'>{-# INLINE up #-}</span>
<a name="line-95"></a>
<a name="line-96"></a><a name="down"></a><span class='hs-definition'>down</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-97"></a><span class='hs-definition'>down</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTree</span> <span class='hs-varid'>n</span> <span class='hs-varid'>cs</span><span class='hs-layout'>)</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-98"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>null</span> <span class='hs-varid'>cs</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-99"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-layout'>(</span><span class='hs-varid'>head</span> <span class='hs-varid'>cs</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-conid'>[]</span> <span class='hs-varid'>n</span> <span class='hs-layout'>(</span><span class='hs-varid'>tail</span> <span class='hs-varid'>cs</span><span class='hs-layout'>)</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-100"></a>
<a name="line-101"></a><span class='hs-comment'>{-# INLINE down #-}</span>
<a name="line-102"></a>
<a name="line-103"></a><a name="toTheRight"></a><span class='hs-definition'>toTheRight</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-104"></a><span class='hs-definition'>toTheRight</span> <span class='hs-varid'>z</span>
<a name="line-105"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isTop</span> <span class='hs-varid'>z</span>
<a name="line-106"></a> <span class='hs-varop'>||</span>
<a name="line-107"></a> <span class='hs-varid'>null</span> <span class='hs-varid'>rs</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-108"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc'</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-109"></a> <span class='hs-keyword'>where</span>
<a name="line-110"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-varid'>t</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>z</span>
<a name="line-111"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bc</span>
<a name="line-112"></a> <span class='hs-varid'>t'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>head</span> <span class='hs-varid'>rs</span>
<a name="line-113"></a> <span class='hs-varid'>bc'</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTC</span> <span class='hs-layout'>(</span><span class='hs-varid'>t</span> <span class='hs-conop'>:</span> <span class='hs-varid'>ls</span><span class='hs-layout'>)</span> <span class='hs-varid'>n</span> <span class='hs-layout'>(</span><span class='hs-varid'>tail</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span>
<a name="line-114"></a>
<a name="line-115"></a><span class='hs-comment'>{-# INLINE toTheRight #-}</span>
<a name="line-116"></a>
<a name="line-117"></a><a name="toTheLeft"></a><span class='hs-definition'>toTheLeft</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-118"></a><span class='hs-definition'>toTheLeft</span> <span class='hs-varid'>z</span>
<a name="line-119"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isTop</span> <span class='hs-varid'>z</span>
<a name="line-120"></a> <span class='hs-varop'>||</span>
<a name="line-121"></a> <span class='hs-varid'>null</span> <span class='hs-varid'>ls</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-122"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc'</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-123"></a> <span class='hs-keyword'>where</span>
<a name="line-124"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-varid'>t</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>z</span>
<a name="line-125"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bc</span>
<a name="line-126"></a> <span class='hs-varid'>t'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>head</span> <span class='hs-varid'>ls</span>
<a name="line-127"></a> <span class='hs-varid'>bc'</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTC</span> <span class='hs-layout'>(</span><span class='hs-varid'>tail</span> <span class='hs-varid'>ls</span><span class='hs-layout'>)</span> <span class='hs-varid'>n</span> <span class='hs-layout'>(</span><span class='hs-varid'>t</span> <span class='hs-conop'>:</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span>
<a name="line-128"></a>
<a name="line-129"></a><span class='hs-comment'>{-# INLINE toTheLeft #-}</span>
<a name="line-130"></a>
<a name="line-131"></a><a name="addToTheLeft"></a><span class='hs-definition'>addToTheLeft</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTree</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-132"></a><span class='hs-definition'>addToTheLeft</span> <span class='hs-varid'>t</span> <span class='hs-varid'>z</span>
<a name="line-133"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isTop</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-134"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-layout'>(</span><span class='hs-varid'>t</span><span class='hs-conop'>:</span><span class='hs-varid'>ls</span><span class='hs-layout'>)</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-135"></a> <span class='hs-keyword'>where</span>
<a name="line-136"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>z</span>
<a name="line-137"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bc</span>
<a name="line-138"></a><span class='hs-comment'>{-# INLINE addToTheLeft #-}</span>
<a name="line-139"></a>
<a name="line-140"></a><a name="addToTheRight"></a><span class='hs-definition'>addToTheRight</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTree</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-141"></a><span class='hs-definition'>addToTheRight</span> <span class='hs-varid'>t</span> <span class='hs-varid'>z</span>
<a name="line-142"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isTop</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-143"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-layout'>(</span><span class='hs-varid'>t</span><span class='hs-conop'>:</span><span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-144"></a> <span class='hs-keyword'>where</span>
<a name="line-145"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>z</span>
<a name="line-146"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bc</span>
<a name="line-147"></a><span class='hs-comment'>{-# INLINE addToTheRight #-}</span>
<a name="line-148"></a>
<a name="line-149"></a><a name="dropFromTheLeft"></a><span class='hs-definition'>dropFromTheLeft</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-150"></a><span class='hs-definition'>dropFromTheLeft</span> <span class='hs-varid'>z</span>
<a name="line-151"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isTop</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-152"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>null</span> <span class='hs-varid'>ls</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-153"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-layout'>(</span><span class='hs-varid'>tail</span> <span class='hs-varid'>ls</span><span class='hs-layout'>)</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-154"></a> <span class='hs-keyword'>where</span>
<a name="line-155"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>z</span>
<a name="line-156"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bc</span>
<a name="line-157"></a><span class='hs-comment'>{-# INLINE dropFromTheLeft #-}</span>
<a name="line-158"></a>
<a name="line-159"></a><a name="dropFromTheRight"></a><span class='hs-definition'>dropFromTheRight</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
<a name="line-160"></a><span class='hs-definition'>dropFromTheRight</span> <span class='hs-varid'>z</span>
<a name="line-161"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isTop</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-162"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>null</span> <span class='hs-varid'>rs</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Nothing</span>
<a name="line-163"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-layout'>(</span><span class='hs-varid'>tail</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span>
<a name="line-164"></a> <span class='hs-keyword'>where</span>
<a name="line-165"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-varid'>t'</span> <span class='hs-layout'>(</span><span class='hs-varid'>bc</span> <span class='hs-conop'>:</span> <span class='hs-varid'>bcs</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>z</span>
<a name="line-166"></a> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bc</span>
<a name="line-167"></a><span class='hs-comment'>{-# INLINE dropFromTheRight #-}</span>
<a name="line-168"></a>
<a name="line-169"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-170"></a>
<a name="line-171"></a><a name="isTop"></a><span class='hs-definition'>isTop</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTZipper</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
<a name="line-172"></a><span class='hs-definition'>isTop</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>null</span> <span class='hs-varop'>.</span> <span class='hs-varid'>context</span>
<a name="line-173"></a>
<a name="line-174"></a><span class='hs-comment'>{-# INLINE isTop #-}</span>
<a name="line-175"></a>
<a name="line-176"></a><a name="up1"></a><span class='hs-definition'>up1</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>NTree</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>NTCrumb</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>NTree</span> <span class='hs-varid'>a</span>
<a name="line-177"></a><span class='hs-definition'>up1</span> <span class='hs-varid'>t</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>ls</span> <span class='hs-varid'>n</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTree</span> <span class='hs-varid'>n</span> <span class='hs-layout'>(</span><span class='hs-varid'>foldl</span> <span class='hs-layout'>(</span><span class='hs-varid'>flip</span> <span class='hs-layout'>(</span><span class='hs-conop'>:</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>t</span> <span class='hs-conop'>:</span> <span class='hs-varid'>rs</span><span class='hs-layout'>)</span> <span class='hs-varid'>ls</span><span class='hs-layout'>)</span>
<a name="line-178"></a>
<a name="line-179"></a><span class='hs-comment'>{-# INLINE up1 #-}</span>
<a name="line-180"></a>
<a name="line-181"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-182"></a>
<a name="line-183"></a><a name="instance%20Functor%20NTZipper"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Functor</span> <span class='hs-conid'>NTZipper</span> <span class='hs-keyword'>where</span>
<a name="line-184"></a> <span class='hs-varid'>fmap</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTZ</span> <span class='hs-varid'>t</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTZ</span> <span class='hs-layout'>(</span><span class='hs-varid'>fmap</span> <span class='hs-varid'>f</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varid'>fmap</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span>
<a name="line-185"></a> <span class='hs-comment'>{-# INLINE fmap #-}</span>
<a name="line-186"></a>
<a name="line-187"></a><a name="instance%20Functor%20NTCrumb"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Functor</span> <span class='hs-conid'>NTCrumb</span> <span class='hs-keyword'>where</span>
<a name="line-188"></a> <span class='hs-varid'>fmap</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-conid'>NTC</span> <span class='hs-varid'>xs</span> <span class='hs-varid'>x</span> <span class='hs-varid'>ys</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>=</span> <span class='hs-conid'>NTC</span> <span class='hs-layout'>(</span><span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varid'>fmap</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>f</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varid'>fmap</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-varid'>ys</span><span class='hs-layout'>)</span>
<a name="line-189"></a> <span class='hs-comment'>{-# INLINE fmap #-}</span>
<a name="line-190"></a>
<a name="line-191"></a><a name="instance%20Tree%20NTZipper"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Tree</span> <span class='hs-conid'>NTZipper</span> <span class='hs-keyword'>where</span>
<a name="line-192"></a> <span class='hs-varid'>mkTree</span> <span class='hs-varid'>n</span> <span class='hs-varid'>cl</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toNTZipper</span> <span class='hs-varop'>.</span> <span class='hs-varid'>mkTree</span> <span class='hs-varid'>n</span> <span class='hs-varop'>$</span> <span class='hs-varid'>map</span> <span class='hs-varid'>ntree</span> <span class='hs-varid'>cl</span>
<a name="line-193"></a>
<a name="line-194"></a> <span class='hs-varid'>getNode</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>getNode</span> <span class='hs-varop'>.</span> <span class='hs-varid'>ntree</span>
<a name="line-195"></a> <span class='hs-comment'>{-# INLINE getNode #-}</span>
<a name="line-196"></a> <span class='hs-varid'>getChildren</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>childAxis</span>
<a name="line-197"></a> <span class='hs-comment'>{-# INLINE getChildren #-}</span>
<a name="line-198"></a>
<a name="line-199"></a> <span class='hs-varid'>changeNode</span> <span class='hs-varid'>cf</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>t</span> <span class='hs-layout'>{</span> <span class='hs-varid'>ntree</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>changeNode</span> <span class='hs-varid'>cf</span> <span class='hs-layout'>(</span><span class='hs-varid'>ntree</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span> <span class='hs-layout'>}</span>
<a name="line-200"></a> <span class='hs-varid'>changeChildren</span> <span class='hs-varid'>cf</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>t</span> <span class='hs-layout'>{</span> <span class='hs-varid'>ntree</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>setChildren</span> <span class='hs-layout'>(</span><span class='hs-varid'>map</span> <span class='hs-varid'>ntree</span> <span class='hs-varop'>.</span> <span class='hs-varid'>cf</span> <span class='hs-varop'>.</span> <span class='hs-varid'>childAxis</span> <span class='hs-varop'>$</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>ntree</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span> <span class='hs-layout'>}</span>
<a name="line-201"></a>
<a name="line-202"></a> <span class='hs-varid'>foldTree</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>foldTree</span> <span class='hs-varid'>f</span> <span class='hs-varop'>.</span> <span class='hs-varid'>ntree</span>
<a name="line-203"></a> <span class='hs-comment'>{-# INLINE foldTree #-}</span>
<a name="line-204"></a>
<a name="line-205"></a><a name="instance%20NavigatableTree%20NTZipper"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>NavigatableTree</span> <span class='hs-conid'>NTZipper</span> <span class='hs-keyword'>where</span>
<a name="line-206"></a> <span class='hs-varid'>mvDown</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>down</span>
<a name="line-207"></a> <span class='hs-comment'>{-# INLINE mvDown #-}</span>
<a name="line-208"></a>
<a name="line-209"></a> <span class='hs-varid'>mvUp</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>up</span>
<a name="line-210"></a> <span class='hs-comment'>{-# INLINE mvUp #-}</span>
<a name="line-211"></a>
<a name="line-212"></a> <span class='hs-varid'>mvLeft</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toTheLeft</span>
<a name="line-213"></a> <span class='hs-comment'>{-# INLINE mvLeft #-}</span>
<a name="line-214"></a>
<a name="line-215"></a> <span class='hs-varid'>mvRight</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toTheRight</span>
<a name="line-216"></a> <span class='hs-comment'>{-# INLINE mvRight #-}</span>
<a name="line-217"></a>
<a name="line-218"></a><a name="instance%20NavigatableTreeToTree%20NTZipper%20NTree"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>NavigatableTreeToTree</span> <span class='hs-conid'>NTZipper</span> <span class='hs-conid'>NTree</span> <span class='hs-keyword'>where</span>
<a name="line-219"></a> <span class='hs-varid'>fromTree</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toNTZipper</span>
<a name="line-220"></a> <span class='hs-comment'>{-# INLINE fromTree #-}</span>
<a name="line-221"></a>
<a name="line-222"></a> <span class='hs-varid'>toTree</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromNTZipper</span>
<a name="line-223"></a> <span class='hs-comment'>{-# INLINE toTree #-}</span>
<a name="line-224"></a>
<a name="line-225"></a><a name="instance%20NavigatableTreeModify%20NTZipper%20NTree"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>NavigatableTreeModify</span> <span class='hs-conid'>NTZipper</span> <span class='hs-conid'>NTree</span> <span class='hs-keyword'>where</span>
<a name="line-226"></a> <span class='hs-varid'>addTreeLeft</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>addToTheLeft</span>
<a name="line-227"></a> <span class='hs-comment'>{-# INLINE addTreeLeft #-}</span>
<a name="line-228"></a>
<a name="line-229"></a> <span class='hs-varid'>addTreeRight</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>addToTheRight</span>
<a name="line-230"></a> <span class='hs-comment'>{-# INLINE addTreeRight #-}</span>
<a name="line-231"></a>
<a name="line-232"></a> <span class='hs-varid'>dropTreeLeft</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropFromTheLeft</span>
<a name="line-233"></a> <span class='hs-comment'>{-# INLINE dropTreeLeft #-}</span>
<a name="line-234"></a>
<a name="line-235"></a> <span class='hs-varid'>dropTreeRight</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropFromTheRight</span>
<a name="line-236"></a> <span class='hs-comment'>{-# INLINE dropTreeRight #-}</span>
<a name="line-237"></a>
<a name="line-238"></a> <span class='hs-varid'>substThisTree</span> <span class='hs-varid'>t</span> <span class='hs-varid'>nt</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>nt</span> <span class='hs-layout'>{</span> <span class='hs-varid'>ntree</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>t</span> <span class='hs-layout'>}</span>
<a name="line-239"></a> <span class='hs-comment'>{-# INLINE substThisTree #-}</span>
<a name="line-240"></a>
<a name="line-241"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
</pre></body>
</html>
|