<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Search And Destroy</title>
	<atom:link href="http://kilfour.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kilfour.wordpress.com</link>
	<description>Look out honey, 'cause I'm using technology!</description>
	<lastBuildDate>Thu, 26 Jan 2012 13:19:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='kilfour.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Search And Destroy</title>
		<link>http://kilfour.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://kilfour.wordpress.com/osd.xml" title="Search And Destroy" />
	<atom:link rel='hub' href='http://kilfour.wordpress.com/?pushpress=hub'/>
		<item>
		<title>QuickGenerate 0.5 Coming Soon</title>
		<link>http://kilfour.wordpress.com/2012/01/13/quickgenerate-0-5-coming-soon/</link>
		<comments>http://kilfour.wordpress.com/2012/01/13/quickgenerate-0-5-coming-soon/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 09:35:09 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[QuickGenerate]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2717</guid>
		<description><![CDATA[And I reckon I&#8217;m going to move to 1.0 pretty quickly right after that. I promised that stability was going to be a feature, and actually I think it allready is. I&#8217;ve been using QG extensively in production over the last year (there&#8217;s three or four projects I&#8217;m currently involved with that are using it, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2717&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>And I reckon I&#8217;m going to move to 1.0 pretty quickly right after that.</p>
<p>I promised that stability was going to be a feature, and actually I think it allready is.<br />
I&#8217;ve been using QG extensively in production over the last year (there&#8217;s three or four projects I&#8217;m currently involved with that are using it, and I know of quite a few others).</p>
<p>Some &#8216;known issues&#8217; have popped up though.<br />
If you know you&#8217;re way around the lib there&#8217;s always a way to work around it, but recently I&#8217;ve been able to tear myself away from the Haskell compiler (and, I must admit, &#8216;Dwarf Fortress&#8217;) for long enough to start adressing these issues in a more fundamental manner.</p>
<p>One breaking change, unfortunately, was neccesary : </p>
<p>As of yesterday, relations are no longer bidirectional.<br />
This means that if you define (f.i.) a OneToMany relation between a &#8216;Parent&#8217; class and a &#8216;Child&#8217; class, a Parent instance will no longer be automatically generated if you ask the generator for a Child instance.<br />
There is now a ManyToOne method for just this case.</p>
<p>Believe me, It simplifies matters. Not only in quickgenerate, but for quickgenerate users (i.e. the client code) aswell.<br />
All kinds of circular misery is now easily avoided.</p>
<p>As it really didn&#8217;t take me that long to update a production project with about two thousands tests, where about a quarter of them relied on this feature, and it actually simplified a lot of the code, I do believe it is worth the change.</p>
<p>I don&#8217;t think it will affect too many users as I&#8217;m probably the only one generating entire domains with just the one generator.<br />
You can still do that if you want to though, you only need a couple of extra lines of code now.<br />
You can combine the OneToMany with a similar ManyToOne, infinite recursion will be avoided, and you get the same behaviour that was there before, including all the problems that come with it.</p>
<p>So, once again, for those of you that are impacted, I&#8217;m sorry, but it needed to be done.</p>
<p>Also on the list for the 0.5 release.<br />
 &#8211; better support for inheritance.<br />
 &#8211; better support for the generation of constructor parameters and the ability to choose between different constructors.</p>
<p>Both features are now available through the &#8216;StartingValue&#8217; method but a more intuitive API would be desirable.</p>
<p>There&#8217;s also a request for backing field generation, but I&#8217;m still hoping I can pull this off without taking a dependency hit to an external library.</p>
<p>In the meantime I&#8217;ve added a QuickGenerate.NHibernate.Testing.Sample project to the solution, as it seems that this is what most people are using it for these days.<br />
Any issues that pop up while you&#8217;re trying to do this, just send me a failing test/use-case (and/or patch) and I&#8217;ll definitely look into it.<br />
It&#8217;s still quite a simple example.<br />
I&#8217;m using sqlite to demonstrate possibilities and, well, sqlite is &#8230; limited.<br />
Feel (very) free to get involved in this part of the code <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .<br />
And if anybody feels like contributing an E.F./AutoMapper/LLBGen/Ditto/whatever example, please do.<br />
The AutoMapper example is on my todo list as you might have gathered from a previous post.</p>
<p>Specific Generator requests are also, as always, still welcome.</p>
<p>F.i. a &#8216;ShortGenerator&#8217; was added recently and someone suggested a generator based on Regex expressions.<br />
But seeing as how I hate RegEx with a passion (*), I&#8217;m going to leave that one as an exercise for some of the more masochistic devs out there <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>(*) : have a look at Parsec for a decent, and really, only slightly more verbose, alternative.</p>
<p>On a sidenote :<br />
 &#8211; Once I&#8217;ve reached the QG 1.0 milestone, I promise I will give QuickDotNetCheck some much needed love.<br />
   I&#8217;d really like to clean up all of the QG tests and replace them with QDNC tests, but, &#8230; small steps, &#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2717/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2717&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2012/01/13/quickgenerate-0-5-coming-soon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>Heavy Lifting</title>
		<link>http://kilfour.wordpress.com/2011/12/21/heavy-lifting/</link>
		<comments>http://kilfour.wordpress.com/2011/12/21/heavy-lifting/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 10:32:52 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2705</guid>
		<description><![CDATA[Yesterday I was having lunch with some co-workers of mine and I mentioned &#8216;lifting&#8217;. I gave a very general description of what it is and what it&#8217;s used for and of them said : &#8216;It sounds beautiful, but I have no idea what you&#8217;re talking about&#8217;. So here&#8217;s an example. The &#8216;metaphysical&#8217; description goes something [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2705&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was having lunch with some co-workers of mine and I mentioned &#8216;lifting&#8217;.</p>
<p>I gave a very general description of what it is and what it&#8217;s used for and of them said : &#8216;It sounds beautiful, but I have no idea what you&#8217;re talking about&#8217;.</p>
<p>So here&#8217;s an example.</p>
<p>The &#8216;metaphysical&#8217; description goes something like this :</p>
<p>A lifting function takes a function that operates in a certain context as it&#8217;s argument and returns a transformation of that function that can operate in a different context.</p>
<p>A C# example :</p>
<p>Consider the following class which wrappes an int and that I have imaginatively called Wrapper :<br />
<pre class="brush: csharp;">
public class Wrapper
{
    public Wrapper(int value)
    {
        Value = value;
    }

    public int Value { get; private set; }
    public override string ToString()
    {
        return string.Format(&quot;{0} wrapped&quot;, Value);
    }
}
</pre></p>
<p>And then we have the following functions which operate on int&#8217;s.</p>
<p><pre class="brush: csharp;">
public int Add(int a, int b)
{
    return a + b;
}

public int Multiply(int a, int b)
{
    return a * b;
}
</pre><br />
We can then define a lifting function which unwraps the int&#8217;s, applies another function and then wraps up the result again.<br />
<pre class="brush: csharp;">
public Wrapper Lift(Func&lt;int, int, int&gt; f, Wrapper a, Wrapper b)
{
    return new Wrapper(f(a.Value, b.Value));
}
</pre></p>
<p>Then we can use the two functions above and apply them to instances of Wrapper like so :</p>
<p><pre class="brush: csharp;">
Console.WriteLine(Lift(Add, new Wrapper(41), new Wrapper(1)));
</pre><br />
results in : Wrapper 42<br />
<pre class="brush: csharp;">
Console.WriteLine(Lift(Multiply, new Wrapper(333), new Wrapper(2)));
</pre><br />
results in : Wrapper 666</p>
<p>Now I can&#8217;t think of a lot of situations (well I can&#8217;t think of any actually) where code like that would be useful in C# but let&#8217;s see what we can do with it in Haskell.</p>
<p>Translating above code :</p>
<p><pre class="brush: plain;">
data Wrapper = Wrapper Int
  deriving Show 
</pre></p>
<p>It&#8217;s pretty identical to the C# Wrapper class although we don&#8217;t need all that boilerplate code.<br />
The deriving Show part gives us a default ToString Implementation f.i. </p>
<p>Here&#8217;s the &#8216;lift&#8217; function :</p>
<p><pre class="brush: plain;">
lift f (Wrapper a) (Wrapper b) = Wrapper (f a b)
</pre><br />
Again similar to the C# example, although we can now use pattern matching and the compiler&#8217;s type inference capabilities to be &#8216;slightly&#8217; less verbose.</p>
<p>We don&#8217;t have to define the add and multiply functions in Haskell as operators are functions as well, so there is no need to wrap them in yet more boilerplate code.</p>
<p>Let&#8217;s fire up the GHCI and verify that it behaves as expected.</p>
<p><pre class="brush: plain;">
&gt;lift (+) (Wrapper 41) (Wrapper 1)
Wrapper 42
&gt;lift (*) (Wrapper 2) (Wrapper 333)
Wrapper 666
</pre></p>
<p>Well that seems to work.</p>
<p>But even though everything is type checked at compile-time (Haskell being a static language just like C#), Haskell&#8217;s rich type system allows us to generalize even further to an extent that is simply not possible in C#.</p>
<p>The lift function does not touch the value of the Wrapper&#8217;s field, so it really could be anything and the function would still work.</p>
<p>Let&#8217;s change the definition of our Wrapper datatype to a more general version by introducing a type parameter.</p>
<p><pre class="brush: plain;">
data Wrapper a = Wrapper a
  deriving Show
</pre></p>
<p>The a is the type parameter, kind of like a generic in C#, albeit quite a bit more powerful.<br />
Retrying the code again in the GHCI gives exactly the same result as before.<br />
But now we can also do it for other types f.i. :</p>
<p>Doubles :<br />
<pre class="brush: plain;">
&gt;lift (+) (Wrapper 41.5) (Wrapper 0.5)
Wrapper 42.0
</pre></p>
<p>Concatenating strings :<br />
<pre class="brush: plain;">
&gt;lift (++) (Wrapper &quot;hello &quot;) (Wrapper &quot;world&quot;)
Wrapper &quot;hello world&quot;
</pre></p>
<p>The types of the wrapped value don&#8217;t even have to be same as long as the function we&#8217;re lifting matches the parameters.<br />
F.i. :<br />
<pre class="brush: plain;">
&gt;let convertAndAppend a b = (read a):b 
&gt;lift convertAndAppend (Wrapper &quot;1&quot;) (Wrapper [2,3,4])
Wrapper [1,2,3,4]
</pre></p>
<p>&#8216;read&#8217; is similar to C#&#8217;s Parse(Int/Double/DateTime/&#8230;) functions and (:) is the operator for appending an element to a list.<br />
So &#8216;a&#8217; should be a string and &#8216;b&#8217; should be a list of things that &#8216;a&#8217; can be parsed into.</p>
<p>In Haskell the compiler is your friend, all this just works but when you try to do something nonsensical such as multiplying two strings you get a compile time error.</p>
<p><pre class="brush: plain;">
&gt;lift (*) (Wrapper &quot;hello &quot;) (Wrapper &quot;world&quot;)

&lt;interactive&gt;:1:6:
    No instance for (Num [Char])
      arising from a use of `*'
    Possible fix: add an instance declaration for (Num [Char])
    In the first argument of `lift', namely `(*)'
    In the expression: lift (*) (Wrapper &quot;hello &quot;) (Wrapper &quot;world&quot;)
    In an equation for `it':
        it = lift (*) (Wrapper &quot;hello &quot;) (Wrapper &quot;world&quot;)
</pre></p>
<p>Now even though I already think all that kind of parametric polymorphism is pretty kewl and useful, let&#8217;s look at why lifting is such an integral part of the Haskell language.</p>
<p>Take the following data structure :<br />
<pre class="brush: plain;">
data Session = Session ClockTime ClockTime
</pre><br />
Just a simple struct with two fields.<br />
The first representing the beginning of a session, the second the end.<br />
I could have made that more explicit by using record syntax, but I&#8217;m trying to keep things simple.</p>
<p>And then we have the following function that calculates the total number of seconds elapsed for a given session.</p>
<p><pre class="brush: plain;">
sessionLength (Session begin end) =  tdSec $ diffClockTimes end begin
</pre></p>
<p>This is a &#8216;pure&#8217; function.<br />
Meaning it has no side-effects and every time we pass  in the same Session parameter we can be sure we get the same result. </p>
<p>Now consider the following function :<br />
<pre class="brush: plain;">
timeIt = do
  begin &lt;- getClockTime
  putStr &quot;Timing, press any key to stop.&quot;
  getChar
  end &lt;- getClockTime
  return $ Session begin end 
</pre></p>
<p>This function gets the current time (through getClockTime), then waits for the user to press a key gets the current time again and returns a Session structure with both times filled in.</p>
<p>It&#8217;s pretty easy to see that this function is not referentially transparent.<br />
It will return a different result every time we call it.<br />
So what happens when we want to apply our pure function to the result of this &#8216;impure&#8217; function.</p>
<p><pre class="brush: plain;">
&gt;sessionLength timeIt 

&lt;interactive&gt;:1:15:
    Couldn't match expected type `Session'
                with actual type `IO Session'
    In the first argument of `sessionLength', namely `timeIt'
    In the expression: sessionLength timeIt
    In an equation for `it': it = sessionLength timeIt
</pre></p>
<p>The compiler starts moaning.</p>
<p>The error message already explains it but looking at the actual type of our functions will make things clearer if you&#8217;re not used to Haskell&#8217;s compiler errors.</p>
<p><pre class="brush: plain;">
&gt;:type sessionLength 
sessionLength :: Session -&gt; Int
&gt;:type timeIt 
timeIt :: IO Session
</pre></p>
<p>sessionLength takes a Session as a parameter and returns an Int (the number of seconds elapsed).<br />
timeIt however, does not return a Session, but an IO Session.</p>
<p>So what&#8217;s this IO thing.</p>
<p>This is Haskell&#8217;s way of saying that we&#8217;re executing code that produces side-effects.</p>
<p>Seeing as the getClockTime function is impure, everything we do with the result of that will also be impure.</p>
<p>This kind of code is executed inside a specific context.<br />
In this case the IO Monad.<br />
And once something is inside a Monad it can never, ever, ever escape it.</p>
<p>This protects us from leaking side-effects into places where we don&#8217;t expect them.</p>
<p>It does however restricts us a little.</p>
<p>One solution would be to rewrite the sessionLength function to allow for side effects but that would deprive us of all of the advantages (such as ease of program verification for one) of pure code.</p>
<p>A better way to deal with this is lifting.</p>
<p>Although nothing is ever allowed out of the IO Monad, we _are_ allowed to bring things in.<br />
More specifically we can lift pure functions into the IO Monad.</p>
<p>Similarly as in our Wrapper toy example the Control.Monad module defines a lifting function called liftM which does just that.<br />
It takes a pure function and lifts it into the IO Monad context.</p>
<p>So this :<br />
<pre class="brush: plain;">
&gt;liftM sessionLength timeIt 
Timing, press any key to stop.
2
</pre></p>
<p>Behaves exactly the way we want.</p>
<p>And now we can write most of our program and algorithms in a pure coding style and separate the side-effects in a very specific place that we then ofcourse unit-, or better yet, quickcheck-test like hell.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2705/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2705&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/12/21/heavy-lifting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>On Having Fun, Elaborating Part II</title>
		<link>http://kilfour.wordpress.com/2011/09/13/on-having-fun-elaborating-part-ii/</link>
		<comments>http://kilfour.wordpress.com/2011/09/13/on-having-fun-elaborating-part-ii/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 10:22:56 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2687</guid>
		<description><![CDATA[On a sidenote : String notation : &#8220;hello world&#8221; A Char : &#8216;h&#8217; An empty list : [] List containing the numbers 1, 2 and 3 : [1, 2, 3] A String in Haskell is actually a list of Char&#8217;s. I.e, : The &#8216;:&#8217; operator is for appending an element to a list, I.e. : [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2687&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>On a sidenote :</strong><br />
String notation : &#8220;hello world&#8221;<br />
A Char : &#8216;h&#8217;<br />
An empty list : []<br />
List containing the numbers 1, 2 and 3 : [1, 2, 3]</p>
<p>A String in Haskell is actually a list of Char&#8217;s.<br />
I.e,  :<br />
<pre class="brush: plain;">
&quot;hello world&quot; == ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
</pre></p>
<p>The &#8216;:&#8217; operator is for appending an element to a list, I.e. :<br />
<pre class="brush: plain;">
&quot;hello world&quot; == 'h':['e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
</pre><br />
Or even :<br />
<pre class="brush: plain;">
&quot;hello world&quot; == 'h':'e':'l':'l':'o':' ':'w':'o':'r':'l':'d':[]
</pre></p>
<p><strong>The compareLine function.</strong><br />
<pre class="brush: plain;">
compareLine :: Int -&gt; Int -&gt; String -&gt; String -&gt; String
</pre><br />
As we can tell from the signature, this is a function which takes two Int&#8217;s, two String&#8217;s and returns a string.<br />
It is a recursive function which we use to compare two lines (the String parameters).<br />
The first int parameter is the lineIndex which we just pass in from the calling function and thread around every time we make a recursive call.<br />
The colIndex parameter is initially 0 (passed in by calling code, see CompareLines) and get&#8217;s incremented with every recursive call.</p>
<p>What follows the functions signature, might look like a bunch of overloads to most C# devs, but it is actually pattern-matching.<br />
When we call this function the arguments are matched against the expression on the left of the assignment operator, and if a match is found the expression on the right is executed.<br />
These patterns are evaluated in the order that they are defined, so let&#8217;s go over them, one by one.</p>
<p><em>End of line or empty strings</em><br />
<pre class="brush: plain;">
compareLine lineIndex colIndex [] []
</pre><br />
The Int&#8217;s can be any value as there is no specific pattern defined.<br />
They are bound to the argument names so they can be used in the right hand of the function, just like c# parameters.</p>
<p>Both Strings however _are_ matched.<br />
[] is the empty list, and in the case of a Char List, also an empty string. So : &#8220;&#8221; == []</p>
<p>This pattern will only match if we pass in two empty strings. I.e. :<br />
<pre class="brush: plain;">
compareLine 42 666 &quot;&quot; &quot;&quot;
</pre><br />
In the context of our recursive compareLine function this pattern evaluates when we have arrived at the end of the line(s), and no difference was found.</p>
<p><em>Different string length</em><br />
<pre class="brush: plain;">
compareLine lineIndex colIndex [] (y:ys) = 		failure lineIndex colIndex
compareLine lineIndex colIndex (x:xs) [] = 		failure lineIndex colIndex
</pre></p>
<p>The new part of this pattern uses the list append operator.</p>
<p>(x:xs) is a common way of writing :<br />
    an x (atleast one) followed by a bunch of xs (could be zero).</p>
<p>Or differently put, a list with atleast one element.</p>
<p>In above pattern (x:xs) will match :<br />
 &#8211; &#8220;hello world&#8221;, which could be written as &#8216;h&#8217;:&#8221;ello world&#8221;<br />
 &#8211; &#8220;h&#8221;,  which could be written as &#8216;h&#8217;:[]<br />
But not &#8220;&#8221;.<br />
In the context of our recursive compareLine function this pattern evaluates when one line is longer than the other.</p>
<p><em>Different Char&#8217;s</em><br />
<pre class="brush: plain;">
compareLine lineIndex colIndex (x:xs) (y:ys) | x /= y = failure lineIndex colIndex
</pre><br />
Ok, so we know this will match if we have two non empty strings (x:xs) (y:ys).<br />
But there&#8217;s a &#8216;guard&#8217; in the pattern.<br />
The expression between the pipe token and the assignment operator is the guard :  x /= y. </p>
<p>&#8216;/=&#8217; is Haskell&#8217;s inequality operator.</p>
<p>x and y are defined in the pattern left of the guard.<br />
In the same way parameters are bound to argument names, values broken down by patterns are assigned to the names used in the pattern.<br />
Which means x is the first element of the first string parameter and y is the first element of the other string parameter.</p>
<p>The guard is doing char comparison.</p>
<p>Above pattern evaluates if we have two non-empty strings, and the first character of the first string differs from the first character of the second string.</p>
<p><em>Recursion</em><br />
<pre class="brush: plain;">
compareLine lineIndex colIndex (x:xs) (y:ys) | x == y = compareLine lineIndex (colIndex + 1)  xs ys
</pre></p>
<p>Knowing what we know we can read the pattern now as : we have two non-empty strings, and the first character of the first string _equals_ the first character of the second string.<br />
The interesting part here is the right hand expression.<br />
This is where the recursion happens.<br />
We keep the lineIndex, increment the colIndex counter and pass in the decomposed &#8216;tail&#8217; lists (xs and ys).<br />
F.i.<br />
<pre class="brush: plain;">
compareLine 0 0 &quot;hello&quot; &quot;hello&quot;
</pre><br />
Will match, seeing as :<br />
<pre class="brush: plain;">
('h':&quot;ello&quot;) ('h':&quot;ello&quot;) | 'h' == 'h'
</pre><br />
And results in :<br />
<pre class="brush: plain;">
compareLine 0 1 &quot;ello&quot; &quot;ello&quot;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2687/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2687&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/09/13/on-having-fun-elaborating-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>On Having Fun, Elaborating Part I</title>
		<link>http://kilfour.wordpress.com/2011/09/09/on-having-fun-elaborating-part-i/</link>
		<comments>http://kilfour.wordpress.com/2011/09/09/on-having-fun-elaborating-part-i/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 06:19:53 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2649</guid>
		<description><![CDATA[The module declaration. Modules are the primary way of encapsulation in Haskell. The statement above exposes one function to the outside-world : &#8216;fileDiff&#8217;. Everything else we use in the module can not be used anywhere else, it is &#8216;private&#8217;. Import statement(s) Quite similar to the using statement in c#, this declares dependencies of one module [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2649&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>The module declaration.</strong></p>
<p><pre class="brush: plain;">
module FileCompare (
    fileDiff
)
</pre></p>
<p>Modules are the primary way of encapsulation in Haskell.<br />
The statement above exposes one function to the outside-world : &#8216;fileDiff&#8217;.<br />
Everything else we use in the module can not be used anywhere else, it is &#8216;private&#8217;. </p>
<p><strong>Import statement(s)</strong></p>
<p><pre class="brush: plain;">
import System.IO (readFile)
</pre></p>
<p>Quite similar to the using statement in c#, this declares dependencies of one module on another.<br />
An interesting thing to note though, is that I am able to restrict which functions of the System.IO module (namespace if you will) are imported.<br />
In this case I&#8217;m only using readFile so I inform the compiler of this, which will allow it to optimize.</p>
<p>It also expresses intent quite clearly.<br />
If I inadvertently use something else I _will_ get a compiler error.<br />
I.e. the module&#8217;s declaration will give me some important clues of what is going on in the implementation.</p>
<p><strong>The failure function</strong></p>
<p><pre class="brush: plain;">
failure :: Int -&gt; Int -&gt; String
failure lineIndex colIndex  =
    &quot;Files differ at line : &quot; ++ (show lineIndex) ++ &quot;, column : &quot; ++ (show colIndex) ++ &quot;.&quot;
</pre></p>
<p>The first part is the function&#8217;s signature.<br />
It&#8217;s name followed by it&#8217;s arguments and ending with the return type.<br />
So this one takes two Int&#8217;s and returns a String.</p>
<p>The slightly weird arrow notation actually makes sense if you take in to account currying.</p>
<p>The following (not very usefull) functions show this by example.<br />
<pre class="brush: plain;">
failureOnLineTwo :: Int -&gt; String
failureOnLineTwo lineIndex colIndex = failure 2

failureOnLineTwoColumnThree :: String
failureOnLineTwoColumnThree = failureOnLineTwo 3
</pre></p>
<p>As you can tell from the signature &#8216;failureOnLineTwo&#8217; is a function that takes an int and returns a string.<br />
&#8216;failureOnLineTwoColumnThree&#8217; is just a string. All the free parameters have been filled in so it evaluates to a value.</p>
<p>&#8216;++&#8217; is Haskell&#8217;s string concatenation operator.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2649/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2649&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/09/09/on-having-fun-elaborating-part-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>NHibernate Integration Testing Helpers</title>
		<link>http://kilfour.wordpress.com/2011/09/08/nhibernate-integration-testing-helpers/</link>
		<comments>http://kilfour.wordpress.com/2011/09/08/nhibernate-integration-testing-helpers/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 08:16:26 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[C# Musings]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2679</guid>
		<description><![CDATA[What I want to test : The plumbing :<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2679&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What I want to test :<br />
<pre class="brush: csharp;">
[Test]
public void MapperShouldNotCauseExtraQueries()
{
    using(0.Queries())
    {
        Mapper.Map(entityResultFromQuery);
    }
}
</pre><br />
The plumbing :<br />
<pre class="brush: csharp;">
public class QuerySpy : IDisposable
{
    private readonly int expectedNumber;
    private readonly NHibernateSqlLogSpy spy;

    public QuerySpy(int expectedNumber)
    {
        this.expectedNumber = expectedNumber;
        spy = new NHibernateSqlLogSpy();
    }

    public void Dispose()
    {
        Assert.AreEqual(expectedNumber, spy.Appender.GetEvents().Count());
    }
}

public static class NumberOfQueriesUsedExtension
{
    public static QuerySpy Queries(this int expectedNumber)
    {
        return new QuerySpy(expectedNumber);
    }
}

public class NHibernateSqlLogSpy : LogSpy
{
    public NHibernateSqlLogSpy() : base(&quot;NHibernate.SQL&quot;) { }
}

public class LogSpy : IDisposable
{
    static LogSpy()
    {
        XmlConfigurator.Configure();
    }

    private readonly MemoryAppender appender;
    private readonly Logger logger;
    private readonly Level prevLogLevel;

    public LogSpy(string loggerName)
    {
        logger = LogManager.GetLogger(loggerName) as Logger;
        if (logger == null)
            throw new NullReferenceException();
        prevLogLevel = logger.Level;
        logger.Level = Level.Debug;
        appender = new MemoryAppender();
        logger.AddAppender(appender);
    }

    public MemoryAppender Appender { get { return appender; } }

    public virtual void Dispose()
    {
        logger.Level = prevLogLevel;
        logger.RemoveAppender(appender);
    }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2679/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2679/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2679/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2679/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2679/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2679/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2679/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2679/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2679/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2679/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2679/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2679/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2679/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2679/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2679&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/09/08/nhibernate-integration-testing-helpers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>Homeless Again</title>
		<link>http://kilfour.wordpress.com/2011/09/02/homeless-again/</link>
		<comments>http://kilfour.wordpress.com/2011/09/02/homeless-again/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 23:33:16 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2669</guid>
		<description><![CDATA[It has been a while. Kind of takes me back to my busking days. But thanks too my innate ability of not getting stressed out about anything, I am once again in this (for most people) non-enviable position. Fortunately I&#8217;ve got something lined up soon. But I must say, it does feel as if a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2669&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It has been a while.</p>
<p>Kind of takes me back to my busking days.</p>
<p>But thanks too my innate ability of not getting stressed out about anything, I am once again in this (for most people) non-enviable position.</p>
<p>Fortunately I&#8217;ve got something lined up soon.</p>
<p>But I must say, it does feel as if a weight has lifted of my shoulders.</p>
<p>A lot of useless stuff I accumulated over the past couple of years has been sold or just simply thrown away.<br />
This includes dvd players, tv&#8217;s, lot&#8217;s of technological gadget&#8217;s, my kids stuff that they don&#8217;t care about anymore but that were still floating &#8217;round, lot&#8217;s of rodent cages and accessories that I once used when I was trying to train a bunch of gerbils/rats etc &#8230;</p>
<p>And I kept only what I value most (a guitar or two-three, my macbook, some clothes, &#8230;)</p>
<p>I really wish I could get rid of the car aswell <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>I&#8217;ve told this story a number of times, but a long time ago we used to hang out in this one guy&#8217;s place.<br />
He was the only one with a regular job.<br />
At one point he got a vcr recorder (yep it&#8217;s quite a while back).<br />
So we ended up watching movies in his place quite often.<br />
And then it broke down.<br />
Everybody was ticked off.<br />
So he send it in for repairs.<br />
A week later he got it back, walked into the apartement, hooked it up and we started watching a movie.</p>
<p>Half way through he got up, yanked the &#8216;ken thing out and threw it out of his window.<br />
Seeing as he lived on the fourth floor not much was left of it.<br />
Everybody just stared at him and one person asked : &#8216;What did you do that for?&#8217;<br />
He replied :<br />
Before I had the &#8216;ken thing I was happy.<br />
When I bought it and it worked I was happy.<br />
When It broke down it made me unhappy.<br />
I don&#8217;t like it when _things_ make me unhappy, so I reckon I&#8217;m better off without it.</p>
<p>Let go, &#8230;, just, &#8230; let it go.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2669/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2669&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/09/02/homeless-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>On Having Fun</title>
		<link>http://kilfour.wordpress.com/2011/08/27/on-having-fun/</link>
		<comments>http://kilfour.wordpress.com/2011/08/27/on-having-fun/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 21:51:04 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2630</guid>
		<description><![CDATA[As mentioned (often) before, a while ago I took a break from professional programming. During which I started honing my functional programming skills. I reckon&#8217; I was, and still am, quite proficient in OCaml. After that I got really interested in Haskell, so I experimented. But the unforgiving nature of the type system was really [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2630&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As mentioned (often) before, a while ago I took a break from professional programming.<br />
During which I started honing my functional programming skills.<br />
I reckon&#8217; I was, and still am, quite proficient in OCaml.</p>
<p>After that I got really interested in Haskell, so I experimented.<br />
But the unforgiving nature of the type system was really hard to deal with and I had a lot of trouble implementing anything usefull.<br />
I managed to pull some things off, but really didn&#8217;t get why.</p>
<p>Recently I have picked it up again, and it&#8217;s all starting to make sense.</p>
<p>Still having trouble making stuff compile and getting things to work.<br />
The fact that I&#8217;m using a different setup/IDE/OS than before, probably isn&#8217;t helping.<br />
But I&#8217;m really, _really_ having fun with this.</p>
<p>Currently looking into Happstack/HStringTemplate/et-all in order to deliver a simple web app, and I was quite proud of myself that I got a &#8216;hello world&#8217; working with minimal code, and that I actually understood all of what is going on <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>Another thing that I&#8217;m currently investigating is Parsec, Haskell&#8217;s built in parser.<br />
Delivering the power of regular expressions _without_ sacrificing readability.<br />
It is not that much more verbose than that horrendous regex stuff, but I can actually program it without having to resort to some kind of tool that translates it for me.</p>
<p>Here&#8217;s a small (unrelated to all of the above) thing I cooked up :<br />
<pre class="brush: plain;">
module FileCompare (
    fileDiff
) where


import System.IO (readFile)

failure :: Int -&gt; Int -&gt; String
failure lineIndex colIndex  =
    &quot;Files differ at line : &quot; ++ (show lineIndex) ++ &quot;, column : &quot; ++ (show colIndex) ++ &quot;.&quot;;

compareLine :: Int -&gt; Int -&gt; String -&gt; String -&gt; String
compareLine lineIndex colIndex [] [] = 				    &quot;&quot;
compareLine lineIndex colIndex (x:xs) [] = 			    failure lineIndex colIndex
compareLine lineIndex colIndex [] (y:ys) = 			    failure lineIndex colIndex
compareLine lineIndex colIndex (x:xs) (y:ys) | x /= y = failure lineIndex colIndex
compareLine lineIndex colIndex (x:xs) (y:ys) | x == y =	compareLine lineIndex (colIndex + 1)  xs ys

compareLines :: Int -&gt; [String] -&gt; [String] -&gt; String
compareLines lineIndex (x:xs) (y:ys) = 	(compareLine lineIndex 0 x y) ++ (compareLines (lineIndex +1) xs ys)
compareLines lineIndex [] (y:ys) = 	&quot;File two contains more lines then file one.&quot;
compareLines lineIndex (x:xs) [] = 	&quot;File one contains more lines then file two.&quot;
compareLines lineIndex [] [] = 		&quot;Files are identical.&quot;

diff :: String -&gt; String -&gt; String
diff a b = compareLines 0 (lines a) (lines b)

fileDiff :: FilePath -&gt; FilePath -&gt; IO String
fileDiff f1 f2 = do
  fileOne &lt;- readFile f1
  fileTwo &lt;- readFile f2
  return $ diff fileOne fileTwo
</pre></p>
<p>Performance equals a C++ version and it can easily handle huge files.</p>
<p>Tell me what you think.</p>
<p>For the imperative minded : start reading at the bottom and then move up <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2630/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2630/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2630/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2630/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2630/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2630/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2630/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2630/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2630/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2630/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2630/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2630/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2630/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2630/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2630&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/08/27/on-having-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>One of Those Nights</title>
		<link>http://kilfour.wordpress.com/2011/08/24/one-of-those-nights/</link>
		<comments>http://kilfour.wordpress.com/2011/08/24/one-of-those-nights/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 17:36:07 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2626</guid>
		<description><![CDATA[QuickGenerate suits my needs for the moment. QuickDotNetCheck still isn&#8217;t working the way I want to, but I&#8217;m going to let it rest for a little while. I&#8217;ll probably iron out a couple of bugs I have recently introduced, so that I can start using it full-time at work. But after that I&#8217;m going to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2626&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>QuickGenerate suits my needs for the moment.</p>
<p>QuickDotNetCheck still isn&#8217;t working the way I want to, but I&#8217;m going to let it rest for a little while.<br />
I&#8217;ll probably iron out a couple of bugs I have recently introduced, so that I can start using it full-time at work.<br />
But after that I&#8217;m going to let the idea ripe in my head a little.</p>
<p>So what to do for fun at home.</p>
<p><a href="http://www.xent.com/pipermail/fork/Week-of-Mon-20070219/044101.html">And then there&#8217;s Haskell&#8230;</a></p>
<p><a href="http://kilfour.files.wordpress.com/2011/08/screen-shot-2011-08-24-at-19-33-31.png"><img src="http://kilfour.files.wordpress.com/2011/08/screen-shot-2011-08-24-at-19-33-31.png?w=300&#038;h=187" alt="" title="Screen shot 2011-08-24 at 19.33.31" width="300" height="187" class="alignnone size-medium wp-image-2627" /></a></p>
<p>Particulary interested in getting some web-related stuff working.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2626/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2626/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2626/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2626/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2626/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2626/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2626/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2626&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/08/24/one-of-those-nights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>

		<media:content url="http://kilfour.files.wordpress.com/2011/08/screen-shot-2011-08-24-at-19-33-31.png?w=300" medium="image">
			<media:title type="html">Screen shot 2011-08-24 at 19.33.31</media:title>
		</media:content>
	</item>
		<item>
		<title>On Scientific Arrogance</title>
		<link>http://kilfour.wordpress.com/2011/08/23/on-scientific-arrogance/</link>
		<comments>http://kilfour.wordpress.com/2011/08/23/on-scientific-arrogance/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 22:02:55 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2611</guid>
		<description><![CDATA[It is not a new thing. There&#8217;s a reason I prefer Alan Kaye&#8217;s publications over Edgar Dijkstra&#8217;s, f.i. I think it has to do with pragmatism versus arrogance. When I was in my teens I read about relativity theory. For fun. And because I wanted to be the smartest kid on the block. In those [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2611&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is not a new thing.</p>
<p>There&#8217;s a reason I prefer Alan Kaye&#8217;s publications over Edgar Dijkstra&#8217;s, f.i.</p>
<p>I think it has to do with pragmatism versus arrogance.</p>
<p>When I was in my teens I read about relativity theory.<br />
For fun.<br />
And because I wanted to be the smartest kid on the block.<br />
In those days, it wasn&#8217;t exactly common knowledge, and I did have a lot of fun hassling my science teachers with questions they couldn&#8217;t answer.</p>
<p>Recently, I&#8217;ve noticed, relativity is far more widely understood, and most people coming out of university have a much better grasp of it than I do.</p>
<p>After reading all that, I took some things as axioms :<br />
 &#8211; nothing travels faster than the speed of light.<br />
 &#8211; there is no such thing as action at a distance.<br />
 &#8211; nothing, not even light, can escape a black hole&#8217;s gravitational field.<br />
 &#8211; the conservation laws (notably the second law of thermodynamics, and conservation of baryon number)<br />
 &#8211; etc&#8230;</p>
<p>Most of these things have been proven wrong by observation in recent years.</p>
<p>So theories were adapted, or thrown out completely, as they should be.<br />
Although the latter option does happen less and less.</p>
<p>The one thing that annoys me up to a point of boiling anger, is that some &#8216;scientists&#8217; seem reluctant to accept an alternative view and even ridicule it, until a &#8216;peer&#8217; higher up on the pecking order tells them that&#8217;s it&#8217;s actually a viable idea.</p>
<p>Just visit some of the physics forums for some &#8216;discussions&#8217; that make some of the net storms in the software blogosphere seem like a friendly exchange of ideas.</p>
<p>The holographic universe theory (and even more so the holographic mind theory) was regarded as fringe theory for a while until some respected scientists got behind it.</p>
<p>Just to make things clear, I have serious apprehensions to above mentioned hypothesis&#8217;s (see my previous post), but I would never have to arrogance to debunk it, because I realize I&#8217;m not qualified to do so.</p>
<p>Yet, people who have studied longer than I have and should understand the math, seem to have no problem in doing so (debunking it I mean) on just first glance.<br />
And they often employ the same unscientific methods that they accuse the other party of using.</p>
<p>Being just an interested laymen, I&#8217;m looking for an objective, scientific approach to the theories/models I&#8217;m interested in, and this is really hard to find.</p>
<p>Engelbarts dream seems further off than ever.</p>
<p>And here&#8217;s one thing that _really_ ticks me off.</p>
<p><a href="http://math.ucr.edu/home/baez/crackpot.html">The Crackpot Index</a>, by John C Baez.</p>
<p>The next phrase should be read whilst imagining mr brando in &#8216;Apocalypse Now&#8217;.</p>
<p>&#8216;The Arrogance, The Arrogance, &#8230;&#8217;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2611/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2611/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2611/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2611&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/08/23/on-scientific-arrogance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
		<item>
		<title>My Favourite Scientific Principle : Occam&#8217;s Razor</title>
		<link>http://kilfour.wordpress.com/2011/08/23/my-favourite-scientific-principle-occams-razor/</link>
		<comments>http://kilfour.wordpress.com/2011/08/23/my-favourite-scientific-principle-occams-razor/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 23:02:44 +0000</pubDate>
		<dc:creator>kilfour</dc:creator>
				<category><![CDATA[My Favourite]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://kilfour.wordpress.com/?p=2603</guid>
		<description><![CDATA[One should not increase, beyond what is necessary, the number of entities required to explain anything. So please, science dudes, get a grip.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2603&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<blockquote><p>One should not increase, beyond what is necessary, the number of entities required to explain anything.</p></blockquote>
<p>So please, <a href="http://www.sciencedaily.com/releases/2009/02/090203130708.htm">science dudes</a>, get a grip.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kilfour.wordpress.com/2603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kilfour.wordpress.com/2603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kilfour.wordpress.com/2603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kilfour.wordpress.com/2603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kilfour.wordpress.com/2603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kilfour.wordpress.com/2603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kilfour.wordpress.com/2603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kilfour.wordpress.com/2603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kilfour.wordpress.com/2603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kilfour.wordpress.com/2603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kilfour.wordpress.com/2603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kilfour.wordpress.com/2603/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kilfour.wordpress.com/2603/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kilfour.wordpress.com/2603/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kilfour.wordpress.com&amp;blog=6941522&amp;post=2603&amp;subd=kilfour&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kilfour.wordpress.com/2011/08/23/my-favourite-scientific-principle-occams-razor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dd9ca13b364abc3165b9a89340cf2091?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilfour</media:title>
		</media:content>
	</item>
	</channel>
</rss>
