1 <span class="kw1">module</span> Shapes
2 <span class="br0">(</span> Shape<span class="br0">(</span><span class="sy0">..</span><span class="br0">)</span>
3 <span class="sy0">,</span> surface
4 <span class="br0">)</span> <span class="kw1">where</span>
6 <span class="kw1">data</span> Shape <span class="sy0">=</span> Circle <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <span class="sy0">|</span> Rectangle <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a>
7 <span class="kw1">data</span> Shape <span class="sy0">=</span> Circle <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <span class="sy0">|</span> Rectangle <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a> <span class="kw1">deriving</span> <span class="br0">(</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Show"><span class="kw4">Show</span></a><span class="br0">)</span>
9 surface <span class="sy0">::</span> Shape <span class="sy0">-></span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a>
10 surface <span class="br0">(</span>Circle <span class="sy0">_</span> <span class="sy0">_</span> r<span class="br0">)</span> <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:pi"><span class="kw3">pi</span></a> <span class="sy0">*</span> r <span class="sy0">^</span> 2
11 surface <span class="br0">(</span>Rectangle x1 y1 x2 y2<span class="br0">)</span> <span class="sy0">=</span> <span class="br0">(</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:abs"><span class="kw3">abs</span></a> <span class="sy0">$</span> x2 <span class="sy0">-</span> x1<span class="br0">)</span> <span class="sy0">*</span> <span class="br0">(</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:abs"><span class="kw3">abs</span></a> <span class="sy0">$</span> y2 <span class="sy0">-</span> y1<span class="br0">)</span>