/usr/share/doc/libghc-numbers-doc/html/src/Data-Number-Symbolic.html is in libghc-numbers-doc 3000.2.0.1-4.
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 | <?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/Number/Symbolic.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>-- | Symbolic number, i.e., these are not numbers at all, but just build</span>
<a name="line-2"></a><span class='hs-comment'>-- a representation of the expressions.</span>
<a name="line-3"></a><span class='hs-comment'>-- This implementation is incomplete in that it allows comnstruction,</span>
<a name="line-4"></a><span class='hs-comment'>-- but not deconstruction of the expressions. It's mainly useful for</span>
<a name="line-5"></a><span class='hs-comment'>-- debugging.</span>
<a name="line-6"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Number</span><span class='hs-varop'>.</span><span class='hs-conid'>Symbolic</span><span class='hs-layout'>(</span><span class='hs-conid'>Sym</span><span class='hs-layout'>,</span> <span class='hs-varid'>var</span><span class='hs-layout'>,</span> <span class='hs-varid'>con</span><span class='hs-layout'>,</span> <span class='hs-varid'>subst</span><span class='hs-layout'>,</span> <span class='hs-varid'>unSym</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-7"></a>
<a name="line-8"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Char</span><span class='hs-layout'>(</span><span class='hs-varid'>isAlpha</span><span class='hs-layout'>)</span>
<a name="line-9"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Maybe</span><span class='hs-layout'>(</span><span class='hs-varid'>fromMaybe</span><span class='hs-layout'>)</span>
<a name="line-10"></a>
<a name="line-11"></a><a name="Sym"></a><span class='hs-comment'>-- | Symbolic numbers over some base type for the literals.</span>
<a name="line-12"></a><a name="Sym"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>App</span> <span class='hs-conid'>String</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'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-keyglyph'>]</span>
<a name="line-13"></a>
<a name="line-14"></a><a name="instance%20Eq%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Eq</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Eq</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-15"></a> <span class='hs-conid'>Con</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-conid'>Con</span> <span class='hs-varid'>x'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>x'</span>
<a name="line-16"></a> <span class='hs-conid'>App</span> <span class='hs-varid'>f</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>xs</span> <span class='hs-varop'>==</span> <span class='hs-conid'>App</span> <span class='hs-varid'>f'</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>xs'</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</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-varop'>==</span> <span class='hs-layout'>(</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-17"></a> <span class='hs-keyword'>_</span> <span class='hs-varop'>==</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
<a name="line-18"></a>
<a name="line-19"></a><a name="instance%20Ord%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Ord</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Ord</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-20"></a> <span class='hs-conid'>Con</span> <span class='hs-varid'>x</span> <span class='hs-varop'>`compare`</span> <span class='hs-conid'>Con</span> <span class='hs-varid'>x'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span> <span class='hs-varop'>`compare`</span> <span class='hs-varid'>x'</span>
<a name="line-21"></a> <span class='hs-conid'>Con</span> <span class='hs-keyword'>_</span> <span class='hs-varop'>`compare`</span> <span class='hs-conid'>App</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>LT</span>
<a name="line-22"></a> <span class='hs-conid'>App</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-varop'>`compare`</span> <span class='hs-conid'>Con</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>GT</span>
<a name="line-23"></a> <span class='hs-conid'>App</span> <span class='hs-varid'>f</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>xs</span> <span class='hs-varop'>`compare`</span> <span class='hs-conid'>App</span> <span class='hs-varid'>f'</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>xs'</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</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-varop'>`compare`</span> <span class='hs-layout'>(</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-24"></a>
<a name="line-25"></a><a name="var"></a><span class='hs-comment'>-- | Create a variable.</span>
<a name="line-26"></a><span class='hs-definition'>var</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span>
<a name="line-27"></a><span class='hs-definition'>var</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>App</span> <span class='hs-varid'>s</span> <span class='hs-varid'>undefined</span> <span class='hs-conid'>[]</span>
<a name="line-28"></a>
<a name="line-29"></a><a name="con"></a><span class='hs-comment'>-- | Create a constant (useful when it is not a literal).</span>
<a name="line-30"></a><span class='hs-definition'>con</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span>
<a name="line-31"></a><span class='hs-definition'>con</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span>
<a name="line-32"></a>
<a name="line-33"></a><a name="subst"></a><span class='hs-comment'>-- | The expression @subst x v e@ substitutes the expression @v@ for each</span>
<a name="line-34"></a><span class='hs-comment'>-- occurence of the variable @x@ in @e@.</span>
<a name="line-35"></a><span class='hs-definition'>subst</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Num</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Eq</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span>
<a name="line-36"></a><span class='hs-definition'>subst</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>e</span><span class='hs-keyglyph'>@</span><span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>e</span>
<a name="line-37"></a><span class='hs-definition'>subst</span> <span class='hs-varid'>x</span> <span class='hs-varid'>v</span> <span class='hs-varid'>e</span><span class='hs-keyglyph'>@</span><span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-varid'>x'</span> <span class='hs-keyword'>_</span> <span class='hs-conid'>[]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>x'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>v</span>
<a name="line-38"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>e</span>
<a name="line-39"></a><span class='hs-definition'>subst</span> <span class='hs-varid'>x</span> <span class='hs-varid'>v</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-varid'>s</span> <span class='hs-varid'>f</span> <span class='hs-varid'>es</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-40"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-varid'>subst</span> <span class='hs-varid'>x</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span> <span class='hs-varid'>es</span> <span class='hs-keyword'>of</span>
<a name="line-41"></a> <span class='hs-keyglyph'>[</span><span class='hs-varid'>e</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>unOp</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-varid'>s</span> <span class='hs-varid'>e</span>
<a name="line-42"></a> <span class='hs-keyglyph'>[</span><span class='hs-varid'>e1</span><span class='hs-layout'>,</span><span class='hs-varid'>e2</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>binOp</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-layout'>,</span><span class='hs-varid'>y</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-varid'>e1</span> <span class='hs-varid'>s</span> <span class='hs-varid'>e2</span>
<a name="line-43"></a> <span class='hs-varid'>es'</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>App</span> <span class='hs-varid'>s</span> <span class='hs-varid'>f</span> <span class='hs-varid'>es'</span>
<a name="line-44"></a>
<a name="line-45"></a><a name="unSym"></a><span class='hs-comment'>-- Turn a symbolic number into a regular one if it is a constant,</span>
<a name="line-46"></a><span class='hs-comment'>-- otherwise generate an error.</span>
<a name="line-47"></a><span class='hs-definition'>unSym</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Show</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>a</span>
<a name="line-48"></a><span class='hs-definition'>unSym</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>c</span>
<a name="line-49"></a><span class='hs-definition'>unSym</span> <span class='hs-varid'>e</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-varop'>$</span> <span class='hs-str'>"unSym called: "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>e</span>
<a name="line-50"></a>
<a name="line-51"></a><a name="instance%20Show%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Show</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Show</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-52"></a> <span class='hs-varid'>showsPrec</span> <span class='hs-varid'>p</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>showsPrec</span> <span class='hs-varid'>p</span> <span class='hs-varid'>c</span>
<a name="line-53"></a> <span class='hs-varid'>showsPrec</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-varid'>s</span> <span class='hs-keyword'>_</span> <span class='hs-conid'>[]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>showString</span> <span class='hs-varid'>s</span>
<a name="line-54"></a> <span class='hs-varid'>showsPrec</span> <span class='hs-varid'>p</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-varid'>op</span><span class='hs-keyglyph'>@</span><span class='hs-layout'>(</span><span class='hs-varid'>c</span><span class='hs-conop'>:</span><span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-layout'>,</span> <span class='hs-varid'>y</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>isAlpha</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-55"></a> <span class='hs-varid'>showParen</span> <span class='hs-layout'>(</span><span class='hs-varid'>p</span><span class='hs-varop'>></span><span class='hs-varid'>q</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>showsPrec</span> <span class='hs-varid'>ql</span> <span class='hs-varid'>x</span> <span class='hs-varop'>.</span> <span class='hs-varid'>showString</span> <span class='hs-varid'>op</span> <span class='hs-varop'>.</span> <span class='hs-varid'>showsPrec</span> <span class='hs-varid'>qr</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span>
<a name="line-56"></a> <span class='hs-keyword'>where</span> <span class='hs-layout'>(</span><span class='hs-varid'>ql</span><span class='hs-layout'>,</span> <span class='hs-varid'>q</span><span class='hs-layout'>,</span> <span class='hs-varid'>qr</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromMaybe</span> <span class='hs-layout'>(</span><span class='hs-num'>9</span><span class='hs-layout'>,</span><span class='hs-num'>9</span><span class='hs-layout'>,</span><span class='hs-num'>9</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-varid'>lookup</span> <span class='hs-varid'>op</span> <span class='hs-keyglyph'>[</span>
<a name="line-57"></a> <span class='hs-layout'>(</span><span class='hs-str'>"**"</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-num'>9</span><span class='hs-layout'>,</span><span class='hs-num'>8</span><span class='hs-layout'>,</span><span class='hs-num'>8</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span>
<a name="line-58"></a> <span class='hs-layout'>(</span><span class='hs-str'>"/"</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-num'>7</span><span class='hs-layout'>,</span><span class='hs-num'>7</span><span class='hs-layout'>,</span><span class='hs-num'>8</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span>
<a name="line-59"></a> <span class='hs-layout'>(</span><span class='hs-str'>"*"</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-num'>7</span><span class='hs-layout'>,</span><span class='hs-num'>7</span><span class='hs-layout'>,</span><span class='hs-num'>8</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span>
<a name="line-60"></a> <span class='hs-layout'>(</span><span class='hs-str'>"+"</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-num'>6</span><span class='hs-layout'>,</span><span class='hs-num'>6</span><span class='hs-layout'>,</span><span class='hs-num'>7</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span>
<a name="line-61"></a> <span class='hs-layout'>(</span><span class='hs-str'>"-"</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-num'>6</span><span class='hs-layout'>,</span><span class='hs-num'>6</span><span class='hs-layout'>,</span><span class='hs-num'>7</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>]</span>
<a name="line-62"></a> <span class='hs-varid'>showsPrec</span> <span class='hs-varid'>p</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"negate"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-63"></a> <span class='hs-varid'>showParen</span> <span class='hs-layout'>(</span><span class='hs-varid'>p</span><span class='hs-varop'>>=</span><span class='hs-num'>6</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>showString</span> <span class='hs-str'>"-"</span> <span class='hs-varop'>.</span> <span class='hs-varid'>showsPrec</span> <span class='hs-num'>7</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-64"></a> <span class='hs-varid'>showsPrec</span> <span class='hs-varid'>p</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-varid'>f</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-65"></a> <span class='hs-varid'>showParen</span> <span class='hs-layout'>(</span><span class='hs-varid'>p</span><span class='hs-varop'>></span><span class='hs-num'>10</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>foldl</span> <span class='hs-layout'>(</span><span class='hs-varop'>.</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>showString</span> <span class='hs-varid'>f</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-keyglyph'>\</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>showChar</span> <span class='hs-chr'>' '</span> <span class='hs-varop'>.</span> <span class='hs-varid'>showsPrec</span> <span class='hs-num'>11</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-66"></a>
<a name="line-67"></a><a name="instance%20Num%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Num</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Eq</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Num</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-68"></a> <span class='hs-varid'>x</span> <span class='hs-varop'>+</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-layout'>(</span><span class='hs-varop'>+</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span> <span class='hs-str'>"+"</span> <span class='hs-varid'>y</span>
<a name="line-69"></a> <span class='hs-varid'>x</span> <span class='hs-comment'>-</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-layout'>(</span><span class='hs-comment'>-</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span> <span class='hs-str'>"-"</span> <span class='hs-varid'>y</span>
<a name="line-70"></a> <span class='hs-varid'>x</span> <span class='hs-varop'>*</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-layout'>(</span><span class='hs-varop'>*</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span> <span class='hs-str'>"*"</span> <span class='hs-varid'>y</span>
<a name="line-71"></a> <span class='hs-varid'>negate</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>negate</span> <span class='hs-str'>"negate"</span> <span class='hs-varid'>x</span>
<a name="line-72"></a> <span class='hs-varid'>abs</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>abs</span> <span class='hs-str'>"abs"</span> <span class='hs-varid'>x</span>
<a name="line-73"></a> <span class='hs-varid'>signum</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>signum</span> <span class='hs-str'>"signum"</span> <span class='hs-varid'>x</span>
<a name="line-74"></a> <span class='hs-varid'>fromInteger</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromInteger</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-75"></a>
<a name="line-76"></a><a name="instance%20Fractional%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Fractional</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Eq</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Fractional</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-77"></a> <span class='hs-varid'>x</span> <span class='hs-varop'>/</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-layout'>(</span><span class='hs-varop'>/</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span> <span class='hs-str'>"/"</span> <span class='hs-varid'>y</span>
<a name="line-78"></a> <span class='hs-varid'>fromRational</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromRational</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-79"></a>
<a name="line-80"></a><a name="binOp"></a><span class='hs-comment'>-- Assume the numbers are a field and simplify a little</span>
<a name="line-81"></a><span class='hs-definition'>binOp</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Num</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Eq</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-keyglyph'>-></span><span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span>
<a name="line-82"></a><span class='hs-definition'>binOp</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-varid'>f</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span>
<a name="line-83"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"+"</span> <span class='hs-num'>0</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-84"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-num'>0</span> <span class='hs-str'>"+"</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-85"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"+"</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"+"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>y</span><span class='hs-layout'>,</span> <span class='hs-varid'>z</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varid'>x</span> <span class='hs-varop'>+</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-varop'>+</span> <span class='hs-varid'>z</span>
<a name="line-86"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"+"</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isCon</span> <span class='hs-varid'>y</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>isCon</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>y</span> <span class='hs-varop'>+</span> <span class='hs-varid'>x</span>
<a name="line-87"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"+"</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"negate"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>y</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span> <span class='hs-comment'>-</span> <span class='hs-varid'>y</span>
<a name="line-88"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"-"</span> <span class='hs-num'>0</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-89"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"-"</span> <span class='hs-varid'>x'</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>x'</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>0</span>
<a name="line-90"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"-"</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>isCon</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-comment'>-</span><span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-varop'>+</span> <span class='hs-varid'>x</span>
<a name="line-91"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-str'>"*"</span> <span class='hs-num'>0</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>0</span>
<a name="line-92"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"*"</span> <span class='hs-num'>1</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-93"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"*"</span> <span class='hs-layout'>(</span><span class='hs-comment'>-</span><span class='hs-num'>1</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-comment'>-</span><span class='hs-varid'>x</span>
<a name="line-94"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-num'>0</span> <span class='hs-str'>"*"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>0</span>
<a name="line-95"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-num'>1</span> <span class='hs-str'>"*"</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-96"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-comment'>-</span><span class='hs-num'>1</span><span class='hs-layout'>)</span> <span class='hs-str'>"*"</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-comment'>-</span><span class='hs-varid'>x</span>
<a name="line-97"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"*"</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"*"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>y</span><span class='hs-layout'>,</span> <span class='hs-varid'>z</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varid'>x</span> <span class='hs-varop'>*</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-varop'>*</span> <span class='hs-varid'>z</span>
<a name="line-98"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"*"</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isCon</span> <span class='hs-varid'>y</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>isCon</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>y</span> <span class='hs-varop'>*</span> <span class='hs-varid'>x</span>
<a name="line-99"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"*"</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"/"</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>y</span><span class='hs-layout'>,</span> <span class='hs-varid'>z</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>App</span> <span class='hs-str'>"/"</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-varop'>*</span><span class='hs-varid'>y</span><span class='hs-layout'>,</span> <span class='hs-varid'>z</span><span class='hs-keyglyph'>]</span>
<a name="line-100"></a><span class='hs-comment'>{-
<a name="line-101"></a>binOp _ x "*" (App "+" _ [y, z]) = x*y + x*z
<a name="line-102"></a>binOp _ (App "+" _ [y, z]) "*" x = y*x + z*x
<a name="line-103"></a>-}</span>
<a name="line-104"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"/"</span> <span class='hs-num'>1</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-105"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"/"</span> <span class='hs-layout'>(</span><span class='hs-comment'>-</span><span class='hs-num'>1</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-comment'>-</span><span class='hs-varid'>x</span>
<a name="line-106"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"/"</span> <span class='hs-varid'>x'</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>x'</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>1</span>
<a name="line-107"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-str'>"/"</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"/"</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>y</span><span class='hs-layout'>,</span> <span class='hs-varid'>z</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>App</span> <span class='hs-str'>"/"</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-varop'>*</span><span class='hs-varid'>z</span><span class='hs-layout'>,</span> <span class='hs-varid'>y</span><span class='hs-keyglyph'>]</span>
<a name="line-108"></a><span class='hs-definition'>binOp</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"**"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-layout'>,</span> <span class='hs-varid'>y</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-str'>"**"</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-varid'>f</span> <span class='hs-varid'>x</span> <span class='hs-str'>"**"</span> <span class='hs-layout'>(</span><span class='hs-varid'>y</span> <span class='hs-varop'>*</span> <span class='hs-varid'>z</span><span class='hs-layout'>)</span>
<a name="line-109"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-str'>"**"</span> <span class='hs-num'>0</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>1</span>
<a name="line-110"></a><span class='hs-definition'>binOp</span> <span class='hs-keyword'>_</span> <span class='hs-num'>0</span> <span class='hs-str'>"**"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>0</span>
<a name="line-111"></a><span class='hs-definition'>binOp</span> <span class='hs-varid'>f</span> <span class='hs-varid'>x</span> <span class='hs-varid'>op</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>App</span> <span class='hs-varid'>op</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>a</span><span class='hs-layout'>,</span><span class='hs-varid'>b</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>f</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-layout'>,</span> <span class='hs-varid'>y</span><span class='hs-keyglyph'>]</span>
<a name="line-112"></a>
<a name="line-113"></a><a name="unOp"></a><span class='hs-definition'>unOp</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Num</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> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span>
<a name="line-114"></a><span class='hs-definition'>unOp</span> <span class='hs-varid'>f</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-varid'>f</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span>
<a name="line-115"></a><span class='hs-definition'>unOp</span> <span class='hs-keyword'>_</span> <span class='hs-str'>"negate"</span> <span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"negate"</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-116"></a><span class='hs-definition'>unOp</span> <span class='hs-keyword'>_</span> <span class='hs-str'>"abs"</span> <span class='hs-varid'>e</span><span class='hs-keyglyph'>@</span><span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"abs"</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>e</span>
<a name="line-117"></a><span class='hs-definition'>unOp</span> <span class='hs-keyword'>_</span> <span class='hs-str'>"signum"</span> <span class='hs-varid'>e</span><span class='hs-keyglyph'>@</span><span class='hs-layout'>(</span><span class='hs-conid'>App</span> <span class='hs-str'>"signum"</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>e</span>
<a name="line-118"></a><span class='hs-definition'>unOp</span> <span class='hs-varid'>f</span> <span class='hs-varid'>op</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>App</span> <span class='hs-varid'>op</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</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'>f</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-keyglyph'>]</span>
<a name="line-119"></a>
<a name="line-120"></a><a name="isCon"></a><span class='hs-definition'>isCon</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
<a name="line-121"></a><span class='hs-definition'>isCon</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>True</span>
<a name="line-122"></a><span class='hs-definition'>isCon</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
<a name="line-123"></a>
<a name="line-124"></a>
<a name="line-125"></a><a name="instance%20Integral%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Integral</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Integral</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-126"></a> <span class='hs-varid'>quot</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-varid'>quot</span> <span class='hs-varid'>x</span> <span class='hs-str'>"quot"</span> <span class='hs-varid'>y</span>
<a name="line-127"></a> <span class='hs-varid'>rem</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-varid'>rem</span> <span class='hs-varid'>x</span> <span class='hs-str'>"rem"</span> <span class='hs-varid'>y</span>
<a name="line-128"></a> <span class='hs-varid'>quotRem</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varid'>quot</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span><span class='hs-layout'>,</span> <span class='hs-varid'>rem</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span>
<a name="line-129"></a> <span class='hs-varid'>div</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-varid'>div</span> <span class='hs-varid'>x</span> <span class='hs-str'>"div"</span> <span class='hs-varid'>y</span>
<a name="line-130"></a> <span class='hs-varid'>mod</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-varid'>mod</span> <span class='hs-varid'>x</span> <span class='hs-str'>"mod"</span> <span class='hs-varid'>y</span>
<a name="line-131"></a> <span class='hs-varid'>toInteger</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toInteger</span> <span class='hs-varid'>c</span>
<a name="line-132"></a>
<a name="line-133"></a><a name="instance%20Enum%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Enum</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Enum</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-134"></a> <span class='hs-varid'>toEnum</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-varop'>.</span> <span class='hs-varid'>toEnum</span>
<a name="line-135"></a> <span class='hs-varid'>fromEnum</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromEnum</span> <span class='hs-varid'>a</span>
<a name="line-136"></a>
<a name="line-137"></a><a name="instance%20Real%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Real</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Real</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-138"></a> <span class='hs-varid'>toRational</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toRational</span> <span class='hs-varid'>c</span>
<a name="line-139"></a>
<a name="line-140"></a><a name="instance%20RealFrac%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>RealFrac</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>RealFrac</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-141"></a> <span class='hs-varid'>properFraction</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varid'>i</span><span class='hs-layout'>,</span> <span class='hs-conid'>Con</span> <span class='hs-varid'>c'</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span> <span class='hs-layout'>(</span><span class='hs-varid'>i</span><span class='hs-layout'>,</span> <span class='hs-varid'>c'</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>properFraction</span> <span class='hs-varid'>c</span>
<a name="line-142"></a>
<a name="line-143"></a><a name="instance%20Floating%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>Floating</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Eq</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Floating</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-144"></a> <span class='hs-varid'>pi</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>var</span> <span class='hs-str'>"pi"</span>
<a name="line-145"></a> <span class='hs-varid'>exp</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>exp</span> <span class='hs-str'>"exp"</span>
<a name="line-146"></a> <span class='hs-varid'>sqrt</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>sqrt</span> <span class='hs-str'>"sqrt"</span>
<a name="line-147"></a> <span class='hs-varid'>log</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>log</span> <span class='hs-str'>"log"</span>
<a name="line-148"></a> <span class='hs-varid'>x</span> <span class='hs-varop'>**</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-layout'>(</span><span class='hs-varop'>**</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span> <span class='hs-str'>"**"</span> <span class='hs-varid'>y</span>
<a name="line-149"></a> <span class='hs-varid'>logBase</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-varid'>logBase</span> <span class='hs-varid'>x</span> <span class='hs-str'>"logBase"</span> <span class='hs-varid'>y</span>
<a name="line-150"></a> <span class='hs-varid'>sin</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>sin</span> <span class='hs-str'>"sin"</span>
<a name="line-151"></a> <span class='hs-varid'>tan</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>tan</span> <span class='hs-str'>"tan"</span>
<a name="line-152"></a> <span class='hs-varid'>cos</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>cos</span> <span class='hs-str'>"cos"</span>
<a name="line-153"></a> <span class='hs-varid'>asin</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>asin</span> <span class='hs-str'>"asin"</span>
<a name="line-154"></a> <span class='hs-varid'>atan</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>atan</span> <span class='hs-str'>"atan"</span>
<a name="line-155"></a> <span class='hs-varid'>acos</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>acos</span> <span class='hs-str'>"acos"</span>
<a name="line-156"></a> <span class='hs-varid'>sinh</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>sinh</span> <span class='hs-str'>"sinh"</span>
<a name="line-157"></a> <span class='hs-varid'>tanh</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>tanh</span> <span class='hs-str'>"tanh"</span>
<a name="line-158"></a> <span class='hs-varid'>cosh</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>cosh</span> <span class='hs-str'>"cosh"</span>
<a name="line-159"></a> <span class='hs-varid'>asinh</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>asinh</span> <span class='hs-str'>"asinh"</span>
<a name="line-160"></a> <span class='hs-varid'>atanh</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>atanh</span> <span class='hs-str'>"atanh"</span>
<a name="line-161"></a> <span class='hs-varid'>acosh</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unOp</span> <span class='hs-varid'>acosh</span> <span class='hs-str'>"acosh"</span>
<a name="line-162"></a>
<a name="line-163"></a><a name="instance%20RealFloat%20(Sym%20a)"></a><span class='hs-keyword'>instance</span> <span class='hs-layout'>(</span><span class='hs-conid'>RealFloat</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>RealFloat</span> <span class='hs-layout'>(</span><span class='hs-conid'>Sym</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-164"></a> <span class='hs-varid'>floatRadix</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>floatRadix</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unSym</span>
<a name="line-165"></a> <span class='hs-varid'>floatDigits</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>floatDigits</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unSym</span>
<a name="line-166"></a> <span class='hs-varid'>floatRange</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>floatRange</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unSym</span>
<a name="line-167"></a> <span class='hs-varid'>decodeFloat</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>decodeFloat</span> <span class='hs-varid'>c</span>
<a name="line-168"></a> <span class='hs-varid'>encodeFloat</span> <span class='hs-varid'>m</span> <span class='hs-varid'>e</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-varid'>encodeFloat</span> <span class='hs-varid'>m</span> <span class='hs-varid'>e</span><span class='hs-layout'>)</span>
<a name="line-169"></a> <span class='hs-varid'>exponent</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>exponent</span> <span class='hs-varid'>c</span>
<a name="line-170"></a> <span class='hs-varid'>exponent</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>0</span>
<a name="line-171"></a> <span class='hs-varid'>significand</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-varid'>significand</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span>
<a name="line-172"></a> <span class='hs-varid'>scaleFloat</span> <span class='hs-varid'>k</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Con</span> <span class='hs-layout'>(</span><span class='hs-varid'>scaleFloat</span> <span class='hs-varid'>k</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span>
<a name="line-173"></a> <span class='hs-varid'>scaleFloat</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
<a name="line-174"></a> <span class='hs-varid'>isNaN</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isNaN</span> <span class='hs-varid'>c</span>
<a name="line-175"></a> <span class='hs-varid'>isInfinite</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isInfinite</span> <span class='hs-varid'>c</span>
<a name="line-176"></a> <span class='hs-varid'>isDenormalized</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isDenormalized</span> <span class='hs-varid'>c</span>
<a name="line-177"></a> <span class='hs-varid'>isNegativeZero</span> <span class='hs-layout'>(</span><span class='hs-conid'>Con</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isNegativeZero</span> <span class='hs-varid'>c</span>
<a name="line-178"></a> <span class='hs-varid'>isIEEE</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isIEEE</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unSym</span>
<a name="line-179"></a> <span class='hs-varid'>atan2</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>binOp</span> <span class='hs-varid'>atan2</span> <span class='hs-varid'>x</span> <span class='hs-str'>"atan2"</span> <span class='hs-varid'>y</span>
</pre></body>
</html>
|