<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>the occasional occurrence</title>
	<atom:link href="http://blog.dowski.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dowski.com</link>
	<description>Unfortunately, Christian had a Thwart, and the Magpie stayed in play.</description>
	<pubDate>Wed, 21 Jul 2010 18:33:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A JSON Parser Using SimpleParse</title>
		<link>http://blog.dowski.com/2010/07/21/a-json-parser-using-simpleparse/</link>
		<comments>http://blog.dowski.com/2010/07/21/a-json-parser-using-simpleparse/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 18:31:32 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=387</guid>
		<description><![CDATA[I&#8217;ve been reading the recent posts on CodeTalker with interest.  I&#8217;ve written a handful of parsers using two different parser generators for Python: PLY and SimpleParse.  My most recent work with parsing has had me gravitating toward SimpleParse so I thought I&#8217;d see how it stacks up against CodeTalker.
First I checked the web [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading <a href="http://jaredforsyth.com/blog/2010/jul/21/codetalker-doubles-in-speed/">the recent posts on CodeTalker</a> with interest.  I&#8217;ve written a handful of parsers using two different parser generators for Python: <a href="http://www.dabeaz.com/ply/">PLY</a> and <a href="http://simpleparse.sourceforge.net/">SimpleParse</a>.  My most recent work with parsing has had me gravitating toward SimpleParse so I thought I&#8217;d see how it stacks up against CodeTalker.</p>
<p>First I checked the web to see if someone had written a JSON parser using SimpleParse.  I found <a href="http://bitbucket.org/robla/jsonwidget-python/src/tip/jsonwidget/jsonorder.py">Rob Lanphier&#8217;s JsonOrder</a>.  It at least had a grammar that I could yank as a jumping off point.</p>
<p>The result after about an hour of coding and benchmarking is <a href="http://bitbucket.org/dowski/etc/src/tip/parsing/spjson.py">spjson.py</a>.  At first I tried to adapt Rob&#8217;s version but I switched back to SimpleParse&#8217;s <a href="http://simpleparse.sourceforge.net/processing_result_trees.html">dispatch processor</a> model.  Pretty much the only thing that remains from JsonOrder is the tweaked grammar.</p>
<p>How does it measure up to CodeTalker&#8217;s JSON parser?</p>
<p>It&#8217;s a bit slower.  I added a simple timeit benchmark to the spjson.py file.  I used <a href="http://github.com/jabapyth/benchmarking-stuff/blob/master/json_/large_doc.json">the same JSON file</a> that Jared (the CodeTalker author) used in his benchmarks.  Here are the results of running it against <a href="http://github.com/jabapyth/codetalker/commit/67225442b2c8889d12fd795510cf24384ed815bb">the latest version of CodeTalker at the time</a>:</p>
<pre>
CodeTalker 0.0484498786926
SimpleParse 0.0623928356171
</pre>
<p>In terms of lines of code they are nearly identical.  I didn&#8217;t do anything fancy to omit docstrings or comments (neither module has many of either).</p>
<pre>
$ # use 'head' to strip the 'if __name__ ...' section
$ head spjson.py -n 71 | grep -v '^\s*$' | wc -l
55
$ cat src/codetalker/codetalker/contrib/json.py | grep -v '^\s*$' | wc -l
55
</pre>
<p>The style is the biggest difference.  SimpleParse uses an EBNF defined in a string to create the parser.  CodeTalker uses an EBNF defined using Python code.</p>
<p>Both libraries let you write specialized processors for the grammar.  This is one thing that I really value in SimpleParse over PLY.  Your grammar and the code to act on the parse tree (or token stream) are neatly separated.</p>
<p>I&#8217;m still quite happy with SimpleParse.  I like having the grammar in a nice contained EBNF rather than defined with Python + syntactic sugar.  I&#8217;ll probably give CodeTalker a look next time a new parsing task comes up though.  It&#8217;s great to see how the options for parsing in Python are expanding.</p>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/07/21/a-json-parser-using-simpleparse/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rebasing to a New Branch with Mercurial</title>
		<link>http://blog.dowski.com/2010/07/09/rebasing-to-a-new-branch-with-mercurial/</link>
		<comments>http://blog.dowski.com/2010/07/09/rebasing-to-a-new-branch-with-mercurial/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:53:56 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=378</guid>
		<description><![CDATA[I had a situation at work the other day where I had made a number of local commits to the default branch of my repo.  I wanted to push them upstream to our central server but the feature was incomplete and I didn&#8217;t want to break anything in case someone needed to make a [...]]]></description>
			<content:encoded><![CDATA[<p>I had a situation at work the other day where I had made a number of local commits to the <code>default</code> branch of my repo.  I wanted to push them upstream to our central server but the feature was incomplete and I didn&#8217;t want to break anything in case someone needed to make a tweak to the current code in the <code>default</code> branch.</p>
<p>I had the idea to use the <code><a href="http://mercurial.selenic.com/wiki/RebaseProject">hg rebase</a></code> command to move all my local commits to a new branch before pushing.  It worked, and here&#8217;s how I did it.</p>
<ol>
<li><code>hg clone localrepo temp-localrepo</code>. I always try crazy ideas in another local clone in case I trash the repo.</li>
<li><code>hg up</code> to the revision before my local commits that I want to put in a branch.</li>
<li><code>hg branch newbranchname &#038;&#038; hg ci -m "Branching for reason foo."</code> This creates a new branch and head that can be used as a rebase destination.</li>
<li>Now for the rebase. I needed to rebase the first changeset in my series of local changes onto the <code>newbranchname</code> changeset.  Something like <code>hg rebase --source 94 --dest 105</code>.</li>
</ol>
<p>That&#8217;s about it.  After verifying that it did what I wanted all that was left was to repeat the steps in my main local repo and push to the central server.*</p>
<p>cw</p>
<p>* <em>Of course what I actually did was push these changes to my main local repo and then to the central repo.  Woops.  That left me with the changes both in <code>default</code> and in <code>newbranchname</code>.</em></p>
<p><em>Don&#8217;t do that.  Repeat the steps after you&#8217;ve tried them in another local clone.  I leave recovering from such a situation with <code><a href="http://mercurial.selenic.com/wiki/Strip">hg strip</a></code> as an exercise for the reader.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/07/09/rebasing-to-a-new-branch-with-mercurial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting Version Information from Mercurial</title>
		<link>http://blog.dowski.com/2010/05/13/getting-version-information-from-mercurial/</link>
		<comments>http://blog.dowski.com/2010/05/13/getting-version-information-from-mercurial/#comments</comments>
		<pubDate>Thu, 13 May 2010 20:52:49 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=373</guid>
		<description><![CDATA[In an application I&#8217;m working on at work I want to be able to display various bits of version information in the UI.  This goes for both production deployments from Python EGG files and in development running straight out of the repository.
We use Mercurial for revision control so it is a logical choice for [...]]]></description>
			<content:encoded><![CDATA[<p>In an application I&#8217;m working on <a href="http://www.polimetrix.com">at work</a> I want to be able to display various bits of version information in the UI.  This goes for both production deployments from Python EGG files and in development running straight out of the repository.</p>
<p>We use <a href="http://mercurial.selenic.com/">Mercurial</a> for revision control so it is a logical choice for a version information source.  The result of some hacking is my first Mercurial extension and commit hook.</p>
<p><a href="http://bitbucket.org/dowski/mercurial-version-info-plugin/src">Mercurial Version Info Plugin</a>.</p>
<p>See the README file rendered at that link for the details.  <a href="http://bitbucket.org/dowski/mercurial-version-info-plugin/downloads">Click here to download version 1.0</a>.</p>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/05/13/getting-version-information-from-mercurial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My Take on Multiple Constructors</title>
		<link>http://blog.dowski.com/2010/03/17/my-take-on-multiple-constructors/</link>
		<comments>http://blog.dowski.com/2010/03/17/my-take-on-multiple-constructors/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 21:38:25 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=365</guid>
		<description><![CDATA[I noticed the same question on c.l.p that Steve Ferg responded to on his blog.  I was feeling too lazy to respond to the thread earlier but I thought I&#8217;d throw my idea up on the ol&#8217; blog before wrapping up for the day.
I think this is a classic use-case for class methods. Here [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed the same <a href="http://pythonconquerstheuniverse.wordpress.com/2010/03/17/multiple-constructors-in-a-python-class/">question on c.l.p that Steve Ferg responded to on his blog</a>.  I was feeling too lazy to respond to the thread earlier but I thought I&#8217;d throw my idea up on the ol&#8217; blog before wrapping up for the day.</p>
<p>I think this is a classic use-case for class methods. Here is my implementation.</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">class</span> Vector<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, x, y, z<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">x</span> = x
        <span style="color: #008000;">self</span>.<span style="color: black;">y</span> = y
        <span style="color: #008000;">self</span>.<span style="color: black;">z</span> = z
&nbsp;
    @<span style="color: #008000;">classmethod</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> from_sequence<span style="color: black;">&#40;</span>cls, sequence<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> cls<span style="color: black;">&#40;</span>*sequence<span style="color: black;">&#41;</span>
&nbsp;
    @<span style="color: #008000;">classmethod</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> from_vector<span style="color: black;">&#40;</span>cls, vec<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> cls<span style="color: black;">&#40;</span>vec.<span style="color: black;">x</span>, vec.<span style="color: black;">y</span>, vec.<span style="color: black;">z</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__repr__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;Vector(%s, %s, %s)&quot;</span> % <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">x</span>, <span style="color: #008000;">self</span>.<span style="color: black;">y</span>, <span style="color: #008000;">self</span>.<span style="color: black;">z</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> Vector<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">2</span>,<span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> Vector.<span style="color: black;">from_sequence</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span>,<span style="color: #ff4500;">5</span>,<span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> Vector.<span style="color: black;">from_sequence</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">7</span>,<span style="color: #ff4500;">8</span>,<span style="color: #ff4500;">9</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    v = Vector<span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span>, <span style="color: #ff4500;">11</span>, <span style="color: #ff4500;">12</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> Vector.<span style="color: black;">from_vector</span><span style="color: black;">&#40;</span>v<span style="color: black;">&#41;</span>;</pre></div></div>

<p>Here is the output from running the script:</p>
<pre>
Vector(1, 2, 3)
Vector(4, 5, 6)
Vector(7, 8, 9)
Vector(10, 11, 12)
</pre>
<p>I like the classmethod route because it is obvious what the code is doing, it makes it easy to add new <code>from_*</code> methods and keeps the general <code>__init__</code> method clean.</p>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/03/17/my-take-on-multiple-constructors/feed/</wfw:commentRss>
		</item>
		<item>
		<title>That Sucks</title>
		<link>http://blog.dowski.com/2010/03/17/that-sucks/</link>
		<comments>http://blog.dowski.com/2010/03/17/that-sucks/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 04:25:59 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[Family]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[stories]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=358</guid>
		<description><![CDATA[Spent the morning working from a coffee shop.  I was feeling hip and fresh.
I came home and was going to whip up a sammich for lunch and then get back to work.  
Opened the bread to make the sammich and then had to go and bring the puppy back in the house.  [...]]]></description>
			<content:encoded><![CDATA[<p>Spent the morning working from a coffee shop.  I was feeling hip and fresh.</p>
<p>I came home and was going to whip up a sammich for lunch and then get back to work.  </p>
<p>Opened the bread to make the sammich and then had to go and bring the puppy back in the house.  Eli had &#8220;accidentally&#8221; let him out. Oh well.  I bring the dog in and return to the kitchen.</p>
<p>I got the ham and swiss laid out on the bread.  Then I get called back out because Eli let the dog out again.  Bring the dog <em>and</em> Eli in this time.</p>
<p>Back to making the sammich.  It was taking longer than planned (something like 8 minutes had elapsed) but it was gonna be <em>gooooood</em>.  I proceeded to drop some succulent bean sprouts onto my delicious lunch creation.</p>
<p>Panicked shouts from the living room.</p>
<blockquote><p>&#8220;Curtis and Eli are peeing in the front yard!&#8221;
</p></blockquote>
<p>This just won&#8217;t do.</p>
<p>I go and bring the boys in and deliver a fatherly lecture on the right and wrong times and places to pee outside.  I send them to their room to clean it up.  <em>Super dad</em>.</p>
<p><em>Super hungry dad</em>.</p>
<p>I get back to the kitchen to finish making the sammich.</p>
<p>The dog ate the sammich.</p>
<p>That Sucks.</p>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/03/17/that-sucks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tagged Revision Log Messages in Mercurial</title>
		<link>http://blog.dowski.com/2010/03/12/tagged-revision-log-messages-in-mercurial/</link>
		<comments>http://blog.dowski.com/2010/03/12/tagged-revision-log-messages-in-mercurial/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 17:49:56 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=355</guid>
		<description><![CDATA[I work at YouGov and we use the Mercurial for revision control.
We tag every release in a MAJOR.MINOR.BUGFIX format.  2.32.2 for example.
Recently I wanted to get a summary of the commit log messages for each of the tagged revisions.  Here is the magic command that got me the output that I wanted:

# get [...]]]></description>
			<content:encoded><![CDATA[<p>I work at <a href="http://www.polimetrix.com">YouGov</a> and we use the <a href="http://mercurial.selenic.com/">Mercurial</a> for revision control.</p>
<p>We tag every release in a MAJOR.MINOR.BUGFIX format.  2.32.2 for example.</p>
<p>Recently I wanted to get a summary of the commit log messages for each of the tagged revisions.  Here is the magic command that got me the output that I wanted:</p>
<pre>
# get all log entries for releases tagged with a 2.31 MAJOR.MINOR
hg tags | grep 2\.31 | cut -c33-36 | xargs -L1 hg log -r
</pre>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/03/12/tagged-revision-log-messages-in-mercurial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Evolution of a Haskell Function</title>
		<link>http://blog.dowski.com/2010/03/11/evolution-of-a-haskell-function/</link>
		<comments>http://blog.dowski.com/2010/03/11/evolution-of-a-haskell-function/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 17:23:56 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=345</guid>
		<description><![CDATA[I'm going through <a href="http://www.realworldhaskell.org/">Real World Haskell</a> trying to get a handle on the <a href="http://www.haskell.org">Haskell</a> programming language.  <a href="http://www.python.org">Python</a> is my current language of choice, but I like to learn new programming languages too.

So last night I was going over the chapter that introduces 'let', 'where', 'case' and guards and I wanted to try them out.  I contrived a simple situation where I thought I could use them.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going through <a href="http://book.realworldhaskell.org/">Real World Haskell</a> trying to get a handle on the <a href="http://www.haskell.org">Haskell</a> programming language.  <a href="http://www.python.org">Python</a> is my current language of choice, but I like to learn new programming languages too.</p>
<p>So last night I was going over <a href="http://book.realworldhaskell.org/read/defining-types-streamlining-functions.html">the chapter that introduces &#8216;let&#8217;, &#8216;where&#8217;, &#8216;case&#8217; and guards</a> and I wanted to try them out.  I contrived a simple situation where I thought I could use them.</p>
<p><span id="more-345"></span></p>
<p>I made some Contestants and wanted to see if they were &#8220;valid&#8221; for some definition of the word.  I chose that they had to have a real value for age (not <code>Missing</code>) and be 30 years old or older (I&#8217;m pretty sure the game is called &#8220;Who Wants to Be a 30-year-old Computer Nerd?&#8221;).</p>
<p>Here is my implementation.</p>

<div class="wp_syntax"><div class="code"><pre class="haskell"><span style="color: #5d478b; font-style: italic;">-- my parameterized type</span>
<span style="color: #06c; font-weight: bold;">data</span> Perhaps a = Is a
               | Missing
                 <span style="color: #06c; font-weight: bold;">deriving</span> <span style="color: green;">&#40;</span><span style="color: #cccc00; font-weight: bold;">Show</span><span style="color: green;">&#41;</span>
&nbsp;
<span style="color: #5d478b; font-style: italic;">-- definition of a Contestant</span>
<span style="color: #06c; font-weight: bold;">data</span> Contestant = Contestant <span style="color: green;">&#123;</span>
                    name ::  <span style="color: #cccc00; font-weight: bold;">String</span>,
                    age  ::  Perhaps <span style="color: #cccc00; font-weight: bold;">Int</span>
                <span style="color: green;">&#125;</span> <span style="color: #06c; font-weight: bold;">deriving</span> <span style="color: green;">&#40;</span><span style="color: #cccc00; font-weight: bold;">Show</span><span style="color: green;">&#41;</span>
&nbsp;
<span style="color: #5d478b; font-style: italic;">-- some contestants</span>
contestant1 = Contestant <span style="background-color: #3cb371;">&quot;Christian&quot;</span> <span style="color: green;">&#40;</span>Is <span style="color: red;">31</span><span style="color: green;">&#41;</span>
contestant2 = Contestant <span style="background-color: #3cb371;">&quot;Sarah&quot;</span> Missing
contestant3 = Contestant <span style="background-color: #3cb371;">&quot;Curtis&quot;</span> <span style="color: green;">&#40;</span>Is <span style="color: red;">6</span><span style="color: green;">&#41;</span>
&nbsp;
<span style="color: #5d478b; font-style: italic;">-- the validation logic</span>
contestantValid :: Contestant -&gt; <span style="color: #cccc00; font-weight: bold;">Bool</span>
contestantValid c = 
    <span style="color: #06c; font-weight: bold;">case</span> age c <span style="color: #06c; font-weight: bold;">of</span>
        Missing      -&gt; False
        Is true_age  -&gt; oldenough true_age
            <span style="color: #06c; font-weight: bold;">where</span>
                oldenough a
                    | a &gt;= <span style="color: red;">30</span> = True
                    | a &lt; <span style="color: red;">30</span>  = False
&nbsp;
<span style="color: #5d478b; font-style: italic;">-- some code to print the results of running the validation against contestants</span>
main = <span style="color: #06c; font-weight: bold;">do</span>
    <span style="font-weight: bold;">print</span> $ <span style="color: green;">&#40;</span>contestant1, contestantValid contestant1<span style="color: green;">&#41;</span>
    <span style="font-weight: bold;">print</span> $ <span style="color: green;">&#40;</span>contestant2, contestantValid contestant2<span style="color: green;">&#41;</span>
    <span style="font-weight: bold;">print</span> $ <span style="color: green;">&#40;</span>contestant3, contestantValid contestant3<span style="color: green;">&#41;</span></pre></div></div>

<p>I was pretty proud of myself.  I used &#8216;case&#8217;, &#8216;where&#8217; and guards (not to mention parameterized types - I reimplemented Maybe/Just/Nothing as Perhaps/Is/Missing).</p>
<p>But man, it seemed like a lot of code to do something simple.</p>
<p>As I was falling asleep I realized how I could simplify it.  I could use pattern matching to easily handle the <code>Missing</code> case.  It would also let me pull the <code>age</code> out of a Contestant with ease too.</p>
<p>Here is the <code>contestantValid</code> function updated to reflect that.</p>
</pre>

<div class="wp_syntax"><div class="code"><pre class="haskell">contestantValid :: Contestant -&gt; <span style="color: #cccc00; font-weight: bold;">Bool</span>
contestantValid <span style="color: green;">&#40;</span>Contestant _ Missing<span style="color: green;">&#41;</span> = False
contestantValid <span style="color: green;">&#40;</span>Contestant _ <span style="color: green;">&#40;</span>Is age<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
                                | age &gt;= <span style="color: red;">30</span> = True
                                | age &lt; <span style="color: red;">30</span>  = False</pre></div></div>

<p>Quite a bit simpler.  I patted myself on the back.  It was less fancy than the first version, but at least I had some guards in there.</p>
<p>Then it hit me.  I didn&#8217;t need the guards.</p>
</pre>

<div class="wp_syntax"><div class="code"><pre class="haskell">contestantValid :: Contestant -&gt; <span style="color: #cccc00; font-weight: bold;">Bool</span>
contestantValid <span style="color: green;">&#40;</span>Contestant _ Missing<span style="color: green;">&#41;</span> = False
contestantValid <span style="color: green;">&#40;</span>Contestant _ <span style="color: green;">&#40;</span>Is age<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> = age &gt;= <span style="color: red;">30</span></pre></div></div>

<p>Well, so much for &#8216;where&#8217;, &#8216;case&#8217; and guards.  It sure is a boring function now, but I think the process of how I got there is interesting.</p>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/03/11/evolution-of-a-haskell-function/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Link: PiCloud Overview</title>
		<link>http://blog.dowski.com/2010/03/11/link-picloud-overview/</link>
		<comments>http://blog.dowski.com/2010/03/11/link-picloud-overview/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 14:50:31 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=341</guid>
		<description><![CDATA[Here&#8217;s a great overview of using PiCloud that goes beyond &#8220;hello world&#8221; type stuff.
For those of you who don&#8217;t know, PiCloud is a cloud computing platform for Python that aims to simplify the task of running code in &#8220;the cloud.&#8221;
cw
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a <a href="http://chmullig.com/2010/03/picloud-introduction/">great overview of using PiCloud</a> that goes beyond &#8220;hello world&#8221; type stuff.</p>
<p>For those of you who don&#8217;t know, <a href="http://www.picloud.com">PiCloud</a> is a cloud computing platform for Python that aims to simplify the task of running code in &#8220;the cloud.&#8221;</p>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/03/11/link-picloud-overview/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Aubrey</title>
		<link>http://blog.dowski.com/2010/01/06/aubrey/</link>
		<comments>http://blog.dowski.com/2010/01/06/aubrey/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 17:04:41 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[Family]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=333</guid>
		<description><![CDATA[Our family is so excited and blessed to welcome Aubrey into the world.

She was born this morning at 7:11am EST.  She weighed in at 8lbs. 1oz. and is 19&#8243; long.  Mom and baby are doing well.  I&#8217;m doing great!  
cw
]]></description>
			<content:encoded><![CDATA[<p>Our family is so excited and blessed to welcome Aubrey into the world.</p>
<p><img src="http://lh4.ggpht.com/_9gjL_waMKiA/S0TABTqKQ8I/AAAAAAAAAtM/GuBiQeMKm80/s400/IMG_3210.JPG" alt="Baby Aubrey" /></p>
<p>She was born this morning at 7:11am EST.  She weighed in at 8lbs. 1oz. and is 19&#8243; long.  Mom and baby are doing well.  I&#8217;m doing great! <img src='http://blog.dowski.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>cw</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2010/01/06/aubrey/feed/</wfw:commentRss>
		</item>
		<item>
		<title>On Tree Houses and Software</title>
		<link>http://blog.dowski.com/2009/11/12/on-tree-houses-and-software/</link>
		<comments>http://blog.dowski.com/2009/11/12/on-tree-houses-and-software/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 04:43:46 +0000</pubDate>
		<dc:creator>christian</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Software]]></category>

		<category><![CDATA[computing]]></category>

		<guid isPermaLink="false">http://blog.dowski.com/?p=309</guid>
		<description><![CDATA[From the ShopTalk blog:
The Minimum Viable Tree House 
A case-study in what not to do with your software project.
]]></description>
			<content:encoded><![CDATA[<p>From the <a href="http://shoptalkapp.com/">ShopTalk</a> blog:</p>
<p><a href="http://shoptalkapp.com/blog/2009/11/11/the-minimum-viable-tree-house">The Minimum Viable Tree House</a> </p>
<p>A case-study in what not to do with your software project.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dowski.com/2009/11/12/on-tree-houses-and-software/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
