atupal's site2015-03-27T04:46:43+00:00http://atupal.org/atupalme@atupal.orgHaskell's type and typeclass2015-03-26T00:00:00+00:00http://atupal.org/blog/posts/programming/2015/03/26/Haskell-type-and-typeclass<h1>Haskell's type and typeclass</h1>
<p>Typeclass defines behavior on types and then that can behave in that way are made
instances of that typeclass. Just like interfaces in other languages:).
The interfaces are achieved by defining function or just type declaration.
So when we say that a type is an instance of a typeclass, we mean that we can use
the function that the typeclass defines with that type.</p>
<p>Let's we see the definition of <code>Eq</code>:</p>
<div class="highlight"><pre><code class="language-haskell" data-lang="haskell"><span class="kr">class</span> <span class="kt">Eq</span> <span class="n">a</span> <span class="kr">where</span>
<span class="p">(</span><span class="o">==</span><span class="p">)</span> <span class="ow">::</span> <span class="n">a</span> <span class="ow">-></span> <span class="n">a</span> <span class="ow">-></span> <span class="kt">Bool</span>
<span class="p">(</span><span class="o">/=</span><span class="p">)</span> <span class="ow">::</span> <span class="n">a</span> <span class="ow">-></span> <span class="n">a</span> <span class="ow">-></span> <span class="kt">Bool</span>
</code></pre></div>Hello world2014-11-26T00:00:00+00:00http://atupal.org/blog/posts/programming/2014/11/26/Hello-world<h1>Hello world</h1>
<p>Hello world;</p>
<div class="highlight"><pre><code class="language-python" data-lang="python"><span class="c"># python code</span>
<span class="bp">False</span> <span class="o">=</span> <span class="bp">True</span>
<span class="sd">"""</span>
<span class="sd"> string</span>
<span class="sd">"""</span>
</code></pre></div>
<p>On July 2, an alien mothership entered Earth's orbit and deployed several dozen saucer-shaped "destroyer" spacecraft, each 15 miles (24 km) wide.</p>
<p>On July 3, the Black Knights, a squadron of Marine Corps F/A-18 Hornets, participated in an assault on a destroyer near the city of Los Angeles.</p>
<p>In the words of Abraham Lincoln:</p>
<blockquote>
<p>Pardon my french</p>
</blockquote>
<p><em>This text will be italic</em>
<strong>This text will be bold</strong></p>
<p><strong>Everyone <em>must</em> attend the meeting at 5 o'clock today.</strong></p>
<ul>
<li>Item</li>
<li>Item</li>
<li><p>Item</p></li>
<li><p>Item</p></li>
<li><p>Item</p></li>
<li><p>Item</p></li>
</ul>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li><p>Item 3</p></li>
<li><p>Item 1</p>
<ol>
<li>A corollary to the above item.</li>
<li>Yet another point to consider.</li>
</ol></li>
<li><p>Item 2</p>
<ul>
<li>A corollary that does not need to be ordered.</li>
<li>This is indented four spaces, because it's two spaces further than the item above.</li>
<li>You might want to consider making a new list.</li>
</ul></li>
<li><p>Item 3</p></li>
</ol>
<p>Here's an idea: why don't we take <code>SuperiorProject</code> and turn it into <code>**Reasonable**Project</code>.</p>
<p><a href="www.github.com">Visit GitHub!</a></p>
<p>~~Mistaken text.~~</p>
<p><a href="http://github.com/atupal">http://github.com/atupal</a></p>
<p>| Left-Aligned | Center Aligned | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is | some wordy text | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |</p>