<?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>Didactic Code</title>
	<atom:link href="http://davefancher.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://davefancher.com</link>
	<description>Learn By Doing</description>
	<lastBuildDate>Sun, 16 Jun 2013 21:12:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='davefancher.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Didactic Code</title>
		<link>http://davefancher.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://davefancher.com/osd.xml" title="Didactic Code" />
	<atom:link rel='hub' href='http://davefancher.com/?pushpress=hub'/>
		<item>
		<title>Bloomington .NET Society &#8211; June 27</title>
		<link>http://davefancher.com/2013/06/16/bloomington-net-society-june-27/</link>
		<comments>http://davefancher.com/2013/06/16/bloomington-net-society-june-27/#comments</comments>
		<pubDate>Sun, 16 Jun 2013 21:12:55 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[IU .NET]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[User Groups]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2714</guid>
		<description><![CDATA[I know I&#8217;ve been quiet for a few months but don&#8217;t worry, I haven&#8217;t disappeared. Instead I&#8217;ve been hard at work on an upcoming F# book! The book has consumed most of my time but not being one to pass up a chance to talk about my obsession I&#8217;m making the trip down to Bloomington, &#8230; <a href="http://davefancher.com/2013/06/16/bloomington-net-society-june-27/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2714&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I know I&#8217;ve been quiet for a few months but don&#8217;t worry, I haven&#8217;t disappeared. Instead I&#8217;ve been hard at work on an upcoming F# book! The book has consumed most of my time but not being one to pass up a chance to talk about my obsession I&#8217;m making the trip down to Bloomington, IN at the end of the month to talk to the Bloomington .NET Society.</p>
<p>If you&#8217;re in the Bloomington area on June 27th and interested in learning about F#, please join us. You can find the full meeting details on the group&#8217;s site: <a href="http://dotnet.indiana.edu/news/jun-2013-meeting">http://dotnet.indiana.edu/news/jun-2013-meeting</a>.</p>
<p>I hope to see you there!</p>
<br /> Tagged: <a href='http://davefancher.com/tag/community/'>Community</a>, <a href='http://davefancher.com/tag/speaking/'>Speaking</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2714/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2714&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/06/16/bloomington-net-society-june-27/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>
	</item>
		<item>
		<title>Replicating F#&#8217;s using Function in C#</title>
		<link>http://davefancher.com/2013/03/23/replicating-fs-using-function-in-c/</link>
		<comments>http://davefancher.com/2013/03/23/replicating-fs-using-function-in-c/#comments</comments>
		<pubDate>Sat, 23 Mar 2013 16:32:28 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[IDisposable]]></category>
		<category><![CDATA[using]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2698</guid>
		<description><![CDATA[It didn&#8217;t take long for me to really appreciate the power offered by F#&#8217;s using function. Properly managing IDisposable instances in C# isn&#8217;t particularly problematic but the using statement really doesn&#8217;t offer a whole lot in the way of flexibility. &#160;Sure, the block lets you create and dispose some IDisposable instance and put some arbitrary &#8230; <a href="http://davefancher.com/2013/03/23/replicating-fs-using-function-in-c/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2698&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It didn&#8217;t take long for me to really appreciate the power offered by F#&#8217;s <kbd>using</kbd> function.  Properly managing <kbd>IDisposable</kbd> instances in C# isn&#8217;t particularly problematic but the <kbd>using</kbd> statement really doesn&#8217;t offer a whole lot in the way of flexibility. &nbsp;Sure, the block lets you create and dispose some <kbd>IDisposable</kbd> instance and put some arbitrary code within it but even before I entered the world of functional programming I found the syntax clunky, particularly when I only want the instance around long enough to get some value from it so I can do something with that value later.  The obvious solution to the problem is to just use F# instead but unfortunately that&#8217;s not always a viable option in this C# dominated market.</p>
<p>Assuming that I have to work in C# I could address the situation by just putting all the code in the using block.</p>
<pre class="brush: csharp; title: ; notranslate">
// C#
using(var img = Image.FromFile(@&quot;C:\Windows\Web\Screen\img100.png&quot;))
{
  Console.WriteLine(&quot;Dimensions: {0} x {1}&quot;, img.Width, img.Height);
}
</pre>
<p>Granted, in this contrived example I&#8217;m only writing the dimensions to the console so the image would be disposed quickly but what if I needed those dimensions somewhere else?  There are a few approaches to take and honestly, I don&#8217;t like any of them all that much.</p>
<p>The first way would be to forego using altogether.</p>
<pre class="brush: csharp; title: ; notranslate">
// C#
var img = Image.FromFile(@&quot;C:\Windows\Web\Screen\img100.png&quot;);
var dims = Tuple.Create(img.Width, img.Height);
img.Dispose();

// Do something with dims elsewhere
</pre>
<p>This approach is probably the cleanest and is very similar to a <kbd>use</kbd> binding in F# but it requires discipline to remember to manually dispose of the object.  In C# I&#8217;m so conditioned to define <kbd>IDisposable</kbd>s within <kbd>using</kbd> blocks though that I seldom take this approach.  In order to do this same task with a <kbd>using</kbd> statement there are basically two options, define a variable outside of the block and assign it inside the block or define a method to wrap the using statement.  I generally prefer the later because it facilitates reuse and eliminates a state change.</p>
<p><strong>Variable approach</strong></p>
<pre class="brush: csharp; title: ; notranslate">
// C#
Tuple&lt;int, int&gt; dims;
using(var img = Image.FromFile(@&quot;C:\Windows\Web\Screen\img100.png&quot;))
{
  dims = Tuple.Create(img.Width, img.Height);
}

// Do something with dims elsewhere
</pre>
<p><strong>Method approach</strong></p>
<pre class="brush: csharp; title: ; notranslate">
// C#
private Tuple&lt;int, int&gt; GetDimensions()
{
  using(var img = Image.FromFile(@&quot;C:\Windows\Web\Screen\img100.png&quot;))
  {
    return Tuple.Create(img.Width, img.Height);
  }
}

// Do something with dims elsewhere
</pre>
<p>Now let&#8217;s see how this same example would look in F# with the <kbd>using</kbd> function.</p>
<pre class="brush: fsharp; title: ; notranslate">
// F#
let dims = using (Image.FromFile(@&quot;C:\Windows\Web\Screen\img100.png&quot;))
                 (fun img -&gt; (img.Width, img.Height))
</pre>
<p>Look how clean that is!  Wouldn&#8217;t it be nice to have something like that in C#?  You&#8217;ve probably guessed if from nothing else than the title of this article that it&#8217;s entirely possible.  Right now you might be thinking that you could just reference <kbd>FSharp.Core</kbd> and call the function from the <kbd>Operators</kbd> module but you&#8217;ll quickly find that more trouble than it&#8217;s worth.  The <kbd>using</kbd> function&#8217;s signature is:</p>
<pre class="brush: fsharp; title: ; notranslate">
// F#
val using : resource:'T -&gt; action:('T -&gt; 'U) (requires 'T :&gt; System.IDisposable)
</pre>
<p>The function accepts two arguments: resource, a generic argument constrained to <kbd>IDisposable</kbd>, and action, a function that accepts <kbd>'T</kbd> and returns another (unconstrained) generic type, <kbd>'U</kbd>.  That second argument is what would prove problematic if you tried to call the function from C# since it compiles to <kbd>FSharpFunc&lt;T, TResult&gt;</kbd> instead of <kbd>Func&lt;T, TResult&gt;</kbd>.  Fortunately though it&#8217;s really easy to replicate the functionality natively in C#.</p>
<p>Due to differences between C# and F# the C# version of the Using function needs to be overloaded to accept either a <kbd>Func</kbd> or an <kbd>Action</kbd> depending on whether you&#8217;re returning a value.  You&#8217;ll see though that in either case the function is just wrapping up the provided <kbd>IDisposable</kbd> instance inside a <kbd>using</kbd> statement and invoking the delegate, passing the <kbd>IDisposable</kbd> as an argument.  To make the code accessible you&#8217;ll want to put the <kbd>IDisposableHelper</kbd> class in one of your common assemblies.</p>
<pre class="brush: csharp; title: ; notranslate">
// C#
public static class IDisposableHelper
{
  public static TResult Using&lt;TResource, TResult&gt; (TResource resource, Func&lt;TResource, TResult&gt; action)
    where TResource : IDisposable
  {
    using (resource) return action(resource);
  }

  public static void Using&lt;TResource&gt; (TResource resource, Action&lt;TResource&gt; action)
    where TResource : IDisposable
  {
    using (resource) action(resource);
  }  
}
</pre>
<p>Using the functions isn&#8217;t quite as elegant as in F# but it definitely gets the job done in a much more functional manner.</p>
<p><strong>Not returning a value</strong></p>
<pre class="brush: csharp; title: ; notranslate">
// C#
IDisposableHelper.Using(
  Image.FromFile(@&quot;C:\Windows\Web\Screen\img100.png&quot;),
  img =&gt; Console.WriteLine(&quot;Dimensions: {0} x {1}&quot;, img.Width, img.Height)
);
</pre>
<p><strong>Returning a value</strong></p>
<pre class="brush: csharp; title: ; notranslate">
// C#
var dims =
  IDisposableHelper.Using(
    Image.FromFile(@&quot;C:\Windows\Web\Screen\img100.png&quot;),
    img =&gt; Tuple.Create(img.Width, img.Height)
  );

Console.WriteLine(&quot;Dimensions: {0} x {1}&quot;, dims.Item1, dims.Item2);
</pre>
<p>I&#8217;d still prefer to use F# but when I can&#8217;t at least I can turn to this to make C# feel a little more like home.</p>
<br /> Tagged: <a href='http://davefancher.com/tag/c/'>C#</a>, <a href='http://davefancher.com/tag/f/'>F#</a>, <a href='http://davefancher.com/tag/idisposable/'>IDisposable</a>, <a href='http://davefancher.com/tag/using/'>using</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2698/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2698/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2698&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/03/23/replicating-fs-using-function-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>
	</item>
		<item>
		<title>IndySA &#8211; March 21, 2013</title>
		<link>http://davefancher.com/2013/03/19/indysa-march-21-2013/</link>
		<comments>http://davefancher.com/2013/03/19/indysa-march-21-2013/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 12:00:14 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[IndySA]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[User Groups]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2693</guid>
		<description><![CDATA[The March IndySA meeting is this Thursday.  I&#8217;m excited for the opportunity to spread around a bit more F# love as this month&#8217;s speaker.  If you&#8217;re looking for a fun way to fill the evening please join us at the SEP office in Carmel at 5:30 PM.  All of the logistics details are available on &#8230; <a href="http://davefancher.com/2013/03/19/indysa-march-21-2013/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2693&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.meetup.com/indysa/"><img class="alignright" alt="" src="http://photos3.meetupstatic.com/photos/event/c/4/8/8/global_85550312.jpeg" width="180" height="180" /></a>The March IndySA meeting is this Thursday.  I&#8217;m excited for the opportunity to spread around a bit more F# love as this month&#8217;s speaker.  If you&#8217;re looking for a fun way to fill the evening please join us at the SEP office in Carmel at 5:30 PM.  All of the logistics details are available on the <a title="IndySA Meetup" href="http://www.meetup.com/indysa/events/108016012/">meetup</a> site.</p>
<p>I hope to see you there!</p>
<p><strong>About the Talk</strong></p>
<p><em>F# Needs Love Too</em></p>
<p>Originally developed by Microsoft Research, Cambridge, F# is an open-source, functional-first language in the ML family. Despite its lofty position as a first-class Visual Studio language for the past two releases and its cross-platform availability it hasn&#8217;t seen widespread adoption in the business world. In this talk we&#8217;ll take an introductory look at F#, exploring how its constructs and terse syntax can allow you to write more stable, maintainable code while keeping you focused on the problem rather than the plumbing.</p>
<p>&nbsp;</p>
<br /> Tagged: <a href='http://davefancher.com/tag/community/'>Community</a>, <a href='http://davefancher.com/tag/indysa/'>IndySA</a>, <a href='http://davefancher.com/tag/speaking/'>Speaking</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2693/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2693/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2693&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/03/19/indysa-march-21-2013/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>

		<media:content url="http://photos3.meetupstatic.com/photos/event/c/4/8/8/global_85550312.jpeg" medium="image" />
	</item>
		<item>
		<title>GR DevDay</title>
		<link>http://davefancher.com/2013/03/05/gr-devday/</link>
		<comments>http://davefancher.com/2013/03/05/gr-devday/#comments</comments>
		<pubDate>Wed, 06 Mar 2013 04:24:38 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[GR DevDay]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2687</guid>
		<description><![CDATA[Last weekend I made the trek up to Grand Rapids, Michigan for the GR DevDay conference.  This was the second time I&#8217;d attended this conference but this time was special &#8211; it was my first time speaking at a conference!  I was honored to have my talk &#8220;F# Needs Love Too&#8221; selected and to have been included in &#8230; <a href="http://davefancher.com/2013/03/05/gr-devday/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2687&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<div id="attachment_2688" class="wp-caption alignright" style="width: 234px"><a href="http://davefancher.files.wordpress.com/2013/03/grdevday-badge.jpg"><img class="size-medium wp-image-2688 " title="GR DevDay Speaker Badge" alt="GR DevDay Speaker Badge" src="http://davefancher.files.wordpress.com/2013/03/grdevday-badge.jpg?w=224&#038;h=300" width="224" height="300" /></a><p class="wp-caption-text">GR DevDay Speaker Badge</p></div>
<p>Last weekend I made the trek up to Grand Rapids, Michigan for the <a title="GR DevDay" href="http://grdevday.org/" target="_blank">GR DevDay</a> conference.  This was the second time I&#8217;d attended this conference but this time was special &#8211; it was my first time speaking at a conference!  I was honored to have my talk &#8220;F# Needs Love Too&#8221; selected and to have been included in line-up of speakers that included some familiar names like Eric Boyd, Jay Harris, Michael Eaton, David Giard, and Jennifer Marsman.</p>
<p>My talk was in the first time slot immediately following the keynote.  Considering I was up against some HTML5 and mobile development talks I was happy to see such interest in F#.  I thought the talk went well and spurred some good conversation.  Thanks to everyone that attended.  Hopefully you were inspired to take a closer look at the language and see how it can change the way you think about writing software.</p>
<p>Having the first time slot gave me the rest of the day to attend other sessions.  The sessions I selected were:</p>
<ol>
<li>Collaborate: Windows Phone and Windows 8 &#8211; Michael Perry</li>
<li>Make Node.js Package. Become Famous. &#8211; Jay Harris</li>
<li>Hot Data and Cool Cash &#8211; Joe Kunk</li>
<li>Creating apps with high code reuse between Windows 8 and Windows Phone 8 &#8211; Jennifer Marsman</li>
</ol>
<p>All of the talks were interesting in their own right.  Naturally I was most interested in the two Windows Phone 8/Windows 8 talks and they didn&#8217;t disappoint.  The other two sessions weren&#8217;t as immediately relevant to me but gave me some stuff to think about.</p>
<p>I&#8217;d like to thank the organizers for putting on yet another great conference.  I thought the event was every bit as good as the last one and was happy to be a part of it.</p>
<br /> Tagged: <a href='http://davefancher.com/tag/community/'>Community</a>, <a href='http://davefancher.com/tag/gr-devday/'>GR DevDay</a>, <a href='http://davefancher.com/tag/speaking/'>Speaking</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2687/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2687&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/03/05/gr-devday/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>

		<media:content url="http://davefancher.files.wordpress.com/2013/03/grdevday-badge.jpg?w=224" medium="image">
			<media:title type="html">GR DevDay Speaker Badge</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom Dark Colors for F# Depth Colorizer for VS2012</title>
		<link>http://davefancher.com/2013/03/01/custom-dark-colors-for-f-depth-colorizer-for-vs2012/</link>
		<comments>http://davefancher.com/2013/03/01/custom-dark-colors-for-f-depth-colorizer-for-vs2012/#comments</comments>
		<pubDate>Fri, 01 Mar 2013 06:42:12 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tools & Utilities]]></category>
		<category><![CDATA[Visual Studio 2012]]></category>
		<category><![CDATA[Depth Colorizer]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2668</guid>
		<description><![CDATA[A few days ago I installed the F# Depth Colorizer extension for Visual Studio 2012. I really liked the idea but didn&#8217;t care much for the default colors used with the dark theme. Rather than alternating light and dark colors I thought it would look better with the background getting progressively lighter giving the illusion &#8230; <a href="http://davefancher.com/2013/03/01/custom-dark-colors-for-f-depth-colorizer-for-vs2012/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2668&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://davefancher.files.wordpress.com/2013/03/depth-coloring.png"><img class="size-full wp-image-2675 alignright" alt="Custom F# Depth Coloring" src="http://davefancher.files.wordpress.com/2013/03/depth-coloring.png?w=600"   /></a>A few days ago I installed the <a href="http://visualstudiogallery.msdn.microsoft.com/07636c36-52be-4dce-9f2e-3c56b8329e33" target="_blank">F# Depth Colorizer</a> extension for Visual Studio 2012. I really liked the idea but didn&#8217;t care much for the default colors used with the dark theme. Rather than alternating light and dark colors I thought it would look better with the background getting progressively lighter giving the illusion of each block being stacked on its container.</p>
<p>After a little tweaking I created the necessary registry entry and was pretty pleased with the result.  The image to the right shows the colors against the same code snippet used in the extension&#8217;s description.  If you&#8217;d like to use these colors just copy the registry information below into a <kbd>.reg</kbd> file and apply it. You&#8217;ll need to restart Visual Studio for the changes to take effect.</p>
<pre class="brush: plain; title: ; notranslate">
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor\FSharpDepthColorizer\Dark]
&quot;Depth0&quot;=&quot;0,0,0,0,0,0&quot;
&quot;Depth1&quot;=&quot;15,15,15,15,15,15&quot;
&quot;Depth2&quot;=&quot;30,30,30,30,30,30&quot;
&quot;Depth3&quot;=&quot;45,45,45,45,45,45&quot;
&quot;Depth4&quot;=&quot;55,55,55,55,55,55&quot;
&quot;Depth5&quot;=&quot;65,65,65,65,65,65&quot;
&quot;Depth6&quot;=&quot;75,75,75,75,75,75&quot;
&quot;Depth7&quot;=&quot;80,80,80,80,80,80&quot;
&quot;Depth8&quot;=&quot;85,85,85,85,85,85&quot;
&quot;Depth9&quot;=&quot;90,90,90,90,90,90&quot;
</pre>
<p>More information about the extension including how to customize the colors is available on <a title="Inside F# - F# Depth Colorizer for VS2012 now available" href="http://lorgonblog.wordpress.com/2012/06/24/f-depth-colorizer-for-vs2012-now-available/" target="_blank">Brian McNamara&#8217;s blog</a>.</p>
<br /> Tagged: <a href='http://davefancher.com/tag/depth-colorizer/'>Depth Colorizer</a>, <a href='http://davefancher.com/tag/f/'>F#</a>, <a href='http://davefancher.com/tag/visual-studio-2012/'>Visual Studio 2012</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2668/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2668&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/03/01/custom-dark-colors-for-f-depth-colorizer-for-vs2012/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>

		<media:content url="http://davefancher.files.wordpress.com/2013/03/depth-coloring.png" medium="image">
			<media:title type="html">Custom F# Depth Coloring</media:title>
		</media:content>
	</item>
		<item>
		<title>The Hacker News Effect</title>
		<link>http://davefancher.com/2013/01/30/the-hacker-news-effect/</link>
		<comments>http://davefancher.com/2013/01/30/the-hacker-news-effect/#comments</comments>
		<pubDate>Wed, 30 Jan 2013 06:25:23 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Metablogging]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2638</guid>
		<description><![CDATA[It has been known by many different names: the Reddit effect, the Slashdot effect, the Digg effect; but whatever the source the result is the same &#8211; a huge spike in traffic due to a popular site linking to a lesser known one. Didactic Code experienced this first hand for the first time when Why &#8230; <a href="http://davefancher.com/2013/01/30/the-hacker-news-effect/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2638&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It has been known by many different names: the Reddit effect, the Slashdot effect, the Digg effect; but whatever the source the result is the same &#8211; a huge spike in traffic due to a popular site linking to a lesser known one. Didactic Code experienced this first hand for the first time when <a title="Why F#?" href="http://davefancher.com/2013/01/27/why-f/">Why F#?</a> gained some traction on <a title="Hacker News" href="http://news.ycombinator.com/" target="_blank">Hacker News</a>.</p>
<p>My blog traffic is predictable to the point that I occasionally joke about how I can tell what time it is by looking at the stats. Lately my quiet little node on the Web had been seeing around 200 views on weekdays and generally about 1/4 of that on weekends. Sunday evening though I noticed something unusual &#8211; my view count had climbed to over 1000. The blog stats showed the traffic was coming from Hacker News so naturally I started watching to see how high the numbers would climb. Sunday ended with 1,575 views and the momentum carried on well into Monday until after the article peaked at #13.</p>
<div id="attachment_2652" class="wp-caption aligncenter" style="width: 273px"><img class="size-full wp-image-2652 " alt="Hourly Traffic" src="http://davefancher.files.wordpress.com/2013/01/hourly-stats.jpg?w=600"   /><p class="wp-caption-text">Hourly Traffic</p></div>
<p>The hourly traffic graph from the WordPress banner shows traffic for the past 48 hours.  It maxed out at 705 views.</p>
<div id="attachment_2651" class="wp-caption aligncenter" style="width: 630px"><a href="http://davefancher.files.wordpress.com/2013/01/dailystats.jpg"><img class="size-large wp-image-2651" alt="Daily Traffic" src="http://davefancher.files.wordpress.com/2013/01/dailystats.jpg?w=620&#038;h=166" width="620" height="166" /></a><p class="wp-caption-text">Daily Traffic</p></div>
<p>The daily traffic graph shows all traffic for the past 30 days. You can imagine my surprise when the traffic shot up on Sunday.</p>
<div id="attachment_2654" class="wp-caption aligncenter" style="width: 630px"><a href="http://davefancher.files.wordpress.com/2013/01/weeklystats.jpg"><img class="size-large wp-image-2654" alt="Weekly Traffic" src="http://davefancher.files.wordpress.com/2013/01/weeklystats.jpg?w=620&#038;h=162" width="620" height="162" /></a><p class="wp-caption-text">Weekly Traffic</p></div>
<p>The weekly traffic graph shows 31 weeks of history. You can clearly see the annual dip around the holidays followed by this week&#8217;s spike.</p>
<div id="attachment_2653" class="wp-caption aligncenter" style="width: 630px"><a href="http://davefancher.files.wordpress.com/2013/01/monthlystats.jpg"><img class="size-large wp-image-2653" alt="Monthly Traffic" src="http://davefancher.files.wordpress.com/2013/01/monthlystats.jpg?w=620&#038;h=162" width="620" height="162" /></a><p class="wp-caption-text">Monthly Traffic</p></div>
<p>The monthly graph is the most interesting to me because it shows how steadily my traffic has increased over the years and what an anomaly like this looks like in the life of a small blog.</p>
<p>For as much excitement as I got out of this I was really happy about the discussion the post generated here, <a title="HN Discussion" href="http://news.ycombinator.com/item?id=5126443" target="_blank">on HN</a>, and on Twitter.  I didn&#8217;t jump into the HN conversation but I really enjoyed reading the comments, particularly those comparing languages that I haven&#8217;t even thought about looking at.  So, to everyone that took the time to read my post and those that joined in on the conversation &#8211; thank you!</p>
<br /> Tagged: <a href='http://davefancher.com/tag/blogging/'>Blogging</a>, <a href='http://davefancher.com/tag/metablogging/'>Metablogging</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2638/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2638/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2638&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/01/30/the-hacker-news-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>

		<media:content url="http://davefancher.files.wordpress.com/2013/01/hourly-stats.jpg" medium="image">
			<media:title type="html">Hourly Traffic</media:title>
		</media:content>

		<media:content url="http://davefancher.files.wordpress.com/2013/01/dailystats.jpg?w=620" medium="image">
			<media:title type="html">Daily Traffic</media:title>
		</media:content>

		<media:content url="http://davefancher.files.wordpress.com/2013/01/weeklystats.jpg?w=620" medium="image">
			<media:title type="html">Weekly Traffic</media:title>
		</media:content>

		<media:content url="http://davefancher.files.wordpress.com/2013/01/monthlystats.jpg?w=620" medium="image">
			<media:title type="html">Monthly Traffic</media:title>
		</media:content>
	</item>
		<item>
		<title>GR DevDay &#8211; March 2, 2013</title>
		<link>http://davefancher.com/2013/01/27/gr-devday-march-2-2013/</link>
		<comments>http://davefancher.com/2013/01/27/gr-devday-march-2-2013/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 03:17:27 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[GR DevDay]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2495</guid>
		<description><![CDATA[If you&#8217;re looking for a great developer conference in the Grand Rapids, MI area I highly recommend checking out GR DevDay. This year the conference is being held on March 2 at Calvin College. The organizers have lined up a &#160;great selection sessions covering a wide range of topics and technologies. Whether you&#8217;re developing for &#8230; <a href="http://davefancher.com/2013/01/27/gr-devday-march-2-2013/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2495&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re looking for a great developer conference in the Grand Rapids, MI area I highly recommend checking out <a title="GR DevDay: Home" href="http://grdevday.org/" target="_blank">GR DevDay</a>. This year the conference is being held on March 2 at <a title="GR DevDay: Location" href="http://grdevday.org/Location.aspx" target="_blank">Calvin College</a>. The organizers have lined up a &nbsp;great selection sessions covering a wide range of topics and technologies. Whether you&#8217;re developing for the cloud, desktop, or mobile spaces you&#8217;ll be sure to find something of interest.</p>
<p>I&#8217;m honored to be included among this year&#8217;s speakers.&nbsp;If you&#8217;re interested in an introduction to F# be sure to check out my session:</p>
<p><strong>F# Needs Love Too!</strong></p>
<p><em>Originally developed by Microsoft Research, Cambridge, F# is an open-source, functional-first language in the ML family. Despite its lofty position as a first-class Visual Studio language for the past two releases and its cross-platform availability it hasn&#8217;t seen widespread adoption in the business world. In this session we&#8217;ll take an introductory look at F#, exploring how its constructs and terse syntax can allow you to write more stable, maintainable code while keeping you focused on the problem rather than the plumbing.</em></p>
<p>I hope to <a title="GR DevDay: Register" href="http://grdevday.org/Register.aspx" target="_blank">see you there</a> even if you don&#8217;t attend my session.<br />
<span style="font-size:85%;margin-left:15px;">&#8230;but please do</span><br />
<span style="font-size:70%;margin-left:30px;">&#8230;you know you want to!</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2495/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2495&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/01/27/gr-devday-march-2-2013/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>
	</item>
		<item>
		<title>BinaryReader Change in .NET 4.5</title>
		<link>http://davefancher.com/2013/01/27/binaryreader-change-in-net-4-5/</link>
		<comments>http://davefancher.com/2013/01/27/binaryreader-change-in-net-4-5/#comments</comments>
		<pubDate>Sun, 27 Jan 2013 21:28:58 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[BinaryReader]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2633</guid>
		<description><![CDATA[BinaryReader has always had what I consider a design flaw in the way it implemented IDisposable.  Even since the early days of .NET, the BinaryReader constructors have required a stream.  To me this means that the BinaryReader has a dependency on the stream thus something else is responsible for that stream&#8217;s lifecycle.  The problem is that &#8230; <a href="http://davefancher.com/2013/01/27/binaryreader-change-in-net-4-5/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2633&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a title="BinaryReader" href="http://msdn.microsoft.com/en-us/library/system.io.binaryreader(v=VS.110).aspx" target="_blank">BinaryReader</a> has always had what I consider a design flaw in the way it implemented IDisposable.  Even since the early days of .NET, the BinaryReader constructors have required a stream.  To me this means that the BinaryReader has a dependency on the stream thus <em>something else</em> is responsible for that stream&#8217;s lifecycle.  The problem is that when the BinaryReader was disposed it would also close the Stream!</p>
<p>It took until .NET 4.5 but Microsoft finally gave us a way to address this issue in the form of a third constructor overload.  With this constructor we can now specify whether we want to close the provided stream or leave it open.</p>
<br /> Tagged: <a href='http://davefancher.com/tag/net/'>.NET</a>, <a href='http://davefancher.com/tag/binaryreader/'>BinaryReader</a>, <a href='http://davefancher.com/tag/software-development/'>Software Development</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2633/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2633/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2633&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/01/27/binaryreader-change-in-net-4-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>
	</item>
		<item>
		<title>Why F#?</title>
		<link>http://davefancher.com/2013/01/27/why-f/</link>
		<comments>http://davefancher.com/2013/01/27/why-f/#comments</comments>
		<pubDate>Sun, 27 Jan 2013 20:26:43 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2593</guid>
		<description><![CDATA[If you&#8217;ve been following along with my posts over the past six months or so you can probably imagine that I&#8217;ve been asked some variation of this post&#8217;s title more than a few times. One question that I keep getting is why I chose F# over some other functional languages like Haskell, Erlang, or Scala. &#8230; <a href="http://davefancher.com/2013/01/27/why-f/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2593&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;ve been following along with my posts over the past six months or so you can probably imagine that I&#8217;ve been asked some variation of this post&#8217;s title more than a few times. One question that I keep getting is why I chose F# over some other functional languages like <a title="Haskell" href="http://en.wikipedia.org/wiki/Haskell_(programming_language)" target="_blank">Haskell</a>, <a title="Erlang" href="http://en.wikipedia.org/wiki/Erlang_(programming_language)" target="_blank">Erlang</a>, or <a title="Scala" href="http://en.wikipedia.org/wiki/Scala_(programming_language)" target="_blank">Scala</a>. The problem with that question though is that it&#8217;s predicated on the assumption that I actually set out to learn a functional language. The truth is that moving to F# was more of a long but natural progression from C# rather than a conscious decision.</p>
<p>The story begins about two and a half years ago. I had pretty much burned out and was deep into what I can only begin to describe as a stagnation coma. I stopped attending user group meetings; I cut way back on reading; I pretty much stopped doing anything that would help me remain even remotely aware of what was going on in the industry.</p>
<p>It&#8217;s easy to explain how I got to this point. My employer at the time gave very little incentive to stay current. For instance, there were homegrown frameworks for nearly every aspect of the product. Who needs NHibernate (or other ORM) when you have a proprietary DAL? Why learn ASP.NET MVC when you have a proprietary system for page layout? What&#8217;s the point of diving into WPF when the entire application is Web-based? Introducing new technologies or practices was generally discouraged under the banner of being too risky.</p>
<p>It wasn&#8217;t until the company hired a new architect that I started to wake up. He brought a wealth of knowledge of fascinating technologies that I&#8217;d hardly heard of and his excitement reminded me of what I loved about technology. My passion for software development was reigniting and I started looking at many of the technologies that had passed me by.</p>
<p>The first technology that really caught my attention during this time was LINQ. I&#8217;d consider it my introduction to the wonderful world of functional programming. As cool as I thought its query syntax was, I was really interested in the method syntax. I remember reading early on (although I don&#8217;t remember where) that query syntax was only added to C# after users complained that method syntax was too cumbersome in the preview versions. I didn&#8217;t understand this sentiment at all because to me method syntax felt completely natural. Gradually I began to realize that the reason it felt so natural was because it works the way I think. Lambda expressions, higher-order functions, composability, all of these functional concepts just spoke to me.</p>
<p>Over time I started using more of C#&#8217;s functional aspects but found myself getting increasingly frustrated. For the longest time though I couldn&#8217;t quite pinpoint anything specific but <em>something</em> just didn&#8217;t feel right anymore. It wasn&#8217;t until I was mowing the lawn late on a summer afternoon when I had that &#8220;a ha!&#8221; moment that changed my life.</p>
<p>That afternoon my yard work podcast selection included <a href="http://hanselminutes.com/311/why-f-with-richard-minerich-and-phillip-trelford" target="_blank">Hanselminutes #311</a>. In this episode Richard Minerich and Phillip Trelford were talking about a functional language called F# that had been around for a few years and was built upon the .NET framework. I&#8217;d seen a few mentions of F# here and there but before hearing this podcast I hadn&#8217;t given it much thought.</p>
<p>At one point the discussion turned to language productivity and Phillip remarked that writing C# feels like completing government forms in triplicate. As he elaborated I experienced a sudden burst of clarity into one of the major things that had been bothering me about C# &#8211; it&#8217;s verbosity! After listening to the rest of the podcast and hearing more about how the functional nature of the language made it less error prone and how things like default immutability helped alleviate some of the complexity of parallel programming I knew I had to give it a try.</p>
<blockquote><p>A language that doesn&#8217;t affect the way you think about programming, is not worth knowing.<br />
&#8211; Alan Perlis, Epigrams on Programming</p></blockquote>
<p>Despite my love of F# most of my work is still in C# but learning F# has had an amazing impact on how I write C#. C# has been becoming more of a functional language with virtually every new release and I&#8217;ve been using many of those capabilities for a few years but the language is hardly built around them. That said, forgetting about all the times I&#8217;ve typed <kbd>let</kbd> instead of <kbd>var</kbd> or tried to define a default constructor in the class signature in the last week alone F# really has changed the way I work. I find myself writing more higher-order functions and making much better use of delegation; I&#8217;ve developed a strong preference for <kbd>readonly</kbd> member fields and properties; and I regularly find myself longing for some of F#&#8217;s constructs like tuples, records, discriminated unions, and pattern matching.</p>
<p>The truth is that for all of its strengths though I&#8217;m finding working in C# increasingly annoying especially as I continue to work with F#. In many ways, working with C# feels like interacting with a toddler. I feel like I have to hold its hand and guide it along with explicit instructions on what to do every step of the way &#8211; even if I&#8217;ve already told it something. On the other hand, F# feels like having a personal assistant. Its functional nature allows me to more or less describe what I want and it handles the details.</p>
<p>There are plenty of things that make me prefer F# over C# but I&#8217;d like to highlight a few in particular. I&#8217;ve already written extensively about some of these and will be writing more about others as time permits but here I&#8217;d like to look at them from a more comparative angle.</p>
<h2>Terse Syntax</h2>
<p>Even though F# is a functional-first language I think a great way to illustrate the language&#8217;s expressiveness is with an object-oriented. We&#8217;ll start with a simple class definition in C#.</p>
<pre class="brush: csharp; title: ; notranslate">
public class CircleMeasurements
{
  private double _diameter;
  private double _area;
  private double _circumference;

  public CircleMeasurements(double diameter, double area, double circumference)
  {
    _diameter = diameter;
    _area = area;
    _circumference = circumference;
  }

  public double Diameter { get { return _diameter; } }
  public double Area { get { return _area; } }
  public double Circumference { get { return _circumference; }  }
}

// Usage
var measurements = new CircleMeasurements(5.0, 19.63495408, 15.70796327);
</pre>
<p>Look how much code was required to create a class with three properties. Even in this small example we had to tell the compiler what type to use for each value three times! I could have used auto-implemented properties to simplify it a bit but even then we still need to tell the compiler which type to use twice for each value. Now let&#8217;s take a look at the same class in F#:</p>
<pre class="brush: fsharp; title: ; notranslate">
type CircleMeasurements(diameter, area, circumference) =
  member x.Diameter = diameter
  member x.Area = area
  member x.Circumference = circumference

// Usage
let measurements = CircleMeasurements(5.0, 19.63495408, 15.70796327);
</pre>
<p>That&#8217;s it &#8211; four lines of code. Granted this compiles to something that resembles the C# class but we didn&#8217;t have to write any of it and thanks to the fantastic type inference system we didn&#8217;t have to tell the compiler multiple times which type to use for each value. Quite often though even this is more verbose than we actually need. Many times we can use another F# construct &#8211; a record type &#8211; to represent something we&#8217;d represent with a class in other .NET languages:</p>
<pre class="brush: fsharp; title: ; notranslate">
type CircleMeasurements = { Diameter : float; Area : float; Circumference : float }

// Usage
let measurements = { Diameter = 5.0; Area = 19.63495408; Circumference = 15.70796327 }
</pre>
<p>In addition to being even more concise than the corresponding class definition, record types have the added benefit of being structurally comparable so we can easily check for equality between two instances. Record types do require us to include the type annotations but we only need to explicitly tell the compiler what to use once for each value and the constructor and properties are each created implicitly.</p>
<h2>Functional Style</h2>
<p>I already mentioned that functional programming feels more natural to me and by design F# really shines when it comes to expressing and using functions. Traditional .NET development has always had some type of support for delegation and it has definitely improved over the years, particularly with the common generic delegate classes (e.g.: Func, Action) and lambda expressions but actually trying to use them in a more functional style is a pain. This is complicated by the fact that in some situations the C# compiler can&#8217;t infer whether a lambda expression is a delegate or an expression tree. Although in some regards I prefer the C# lambda expression syntax I definitely prefer F#&#8217;s syntactic distinction between delegates and code quotations.</p>
<p>While on the topic of functional programming I have to mention F#&#8217;s default immutability. Immutability is key to any functional language and has been shown to improve overall program correctness by eliminating side effects. C# has some support for immutability through <kbd>readonly</kbd> fields or by omitting setters from property definitions but either of these require a conscious decision to enable. Nearly everything in F# is immutable unless explicitly declared otherwise. Immutability also provides benefits when writing asynchronous code because if nothing is changing, there&#8217;s a reduced need for locking.</p>
<h2>Discriminated Unions</h2>
<p>If you haven&#8217;t read my post on discriminated unions yet, they&#8217;re a way to express simple object hierarchies (or even tree structures) in a concise manner. From a syntactic perspective they&#8217;re incredibly simple but trying to replicate them even for simple structures really isn&#8217;t particularly feasible in C#. Here&#8217;s a simple example:</p>
<p><em>In this example <kbd>suit</kbd> is another discriminated union.</em></p>
<pre class="brush: fsharp; title: ; notranslate">
type Card =
| Ace of Suit
| King of Suit
| Queen of Suit
| Jack of Suit
| ValueCard of Suit * int
</pre>
<p>Using this discriminated union we express the 7 of hearts as <kbd>ValueCard(Heart, 7)</kbd>. For illustration of what it would take to represent this structure in C# I&#8217;m including a screenshot of ILSpy&#8217;s decompilation. Note that I&#8217;ve only included the signatures and even this five case discriminated union more than fills my screen. Just to drive the point home, fully expanded, this code is nearly 700 lines long! Granted there are a few <kbd>CompilerGeneratedAttribute</kbd>s in there but they hardly count for a majority of the code.</p>
<p>Ultimately, the union type is an abstract class and each case is a nested class. The nested classes are each assigned a unique tag that&#8217;s used for type checking and code branching in some of the union type&#8217;s methods. Not included in the screenshot are implementations of several interfaces and overrides of <kbd>Equals</kbd> and <kbd>GetHashCode</kbd>.</p>
<div id="attachment_2617" class="wp-caption aligncenter" style="width: 310px"><a href="http://davefancher.files.wordpress.com/2013/01/decompiledcarddiscriminatedunion.jpg"><img class="size-medium wp-image-2617" alt="Decompiled Card Discriminated Union" src="http://davefancher.files.wordpress.com/2013/01/decompiledcarddiscriminatedunion.jpg?w=300&#038;h=262" width="300" height="262" /></a><p class="wp-caption-text">Decompiled Card Discriminated Union</p></div>
<h2>Collection Types &amp; Comprehensions</h2>
<p>C# has made great strides in regard to initializing various collection types but it still pales in comparison to the constructs offered by F#. Don&#8217;t get me wrong, collection initializers are a nice syntactic convenience but nearly every time I use it I think how much easier it would likely be with a comprehension. LINQ can address some of these shortcomings but even convenience methods like <kbd>Enumerable.Range</kbd> feel limiting. Yes, I could write some additional convenience methods to address some of the shortcomings but in F# I don&#8217;t have to.</p>
<p>Part of the beauty of comprehensions is that they generally apply regardless of which collection type you&#8217;re creating. Although each of the examples below create F# lists they can easily be modified to create sequences or arrays instead.</p>
<pre class="brush: fsharp; title: ; notranslate">
// Numbers 0 - 10
&gt; [0..10];;
val it : int list = [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10]

// Numbers 0 - 10 by 2
&gt; [0..2..10];;
val it : int list = [0; 2; 4; 6; 8; 10]

// Charcters 'a' - 'z'
&gt; ['a'..'z'];;
val it : char list =
  ['a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm'; 'n'; 'o';
   'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z']

// Unshuffled deck
&gt; let deck =
  [ for suit in [ Heart; Diamond; Spade; Club ] do
      yield Ace(suit)
      yield King(suit)
      yield Queen(suit)
      yield Jack(suit)
      for v in 2 .. 10 do
        yield ValueCard(suit, v)
  ];;

val deck : Card list =
  [Ace Heart; King Heart; Queen Heart; Jack Heart; ValueCard (Heart,2);
   ValueCard (Heart,3); ValueCard (Heart,4); ValueCard (Heart,5);
   ValueCard (Heart,6); ValueCard (Heart,7); ValueCard (Heart,8);
   ValueCard (Heart,9); ValueCard (Heart,10); Ace Diamond; King Diamond;
   Queen Diamond; Jack Diamond; ValueCard (Diamond,2); ValueCard (Diamond,3);
   ValueCard (Diamond,4); ValueCard (Diamond,5); ValueCard (Diamond,6);
   ValueCard (Diamond,7); ValueCard (Diamond,8); ValueCard (Diamond,9);
   ValueCard (Diamond,10); Ace Spade; King Spade; Queen Spade; Jack Spade;
   ValueCard (Spade,2); ValueCard (Spade,3); ValueCard (Spade,4);
   ValueCard (Spade,5); ValueCard (Spade,6); ValueCard (Spade,7);
   ValueCard (Spade,8); ValueCard (Spade,9); ValueCard (Spade,10); Ace Club;
   King Club; Queen Club; Jack Club; ValueCard (Club,2); ValueCard (Club,3);
   ValueCard (Club,4); ValueCard (Club,5); ValueCard (Club,6);
   ValueCard (Club,7); ValueCard (Club,8); ValueCard (Club,9);
   ValueCard (Club,10)]
</pre>
<h2>Pattern Matching</h2>
<blockquote><p><em>faced with a 20th century computer</em><br />
<strong>Scotty:</strong> Computer! Computer?<br />
<em>He&#8217;s handed a mouse, and he speaks into it</em><br />
<strong>Scotty:</strong> Hello, computer.<br />
<strong>Dr. Nichols:</strong> Just use the keyboard.<br />
<strong>Scotty:</strong> Keyboard. How quaint.<br />
&#8211; Star Trek IV</p></blockquote>
<p>The above conversation enters my mind when I&#8217;m working with C#&#8217;s branching constructs, <kbd>switch</kbd> statements in particular.  F#&#8217;s pattern matching may bear a slight resemblance to C# switch statements but they&#8217;re so much more powerful.  <kbd>switch</kbd> statements limit us to simply branching on constant values but pattern matching allows value extraction, multiple cases, and refinement constraints for more precise control with a syntax much friendlier than your common if/else statement. Furthermore, like virtually everything else in F#, pattern matches are expressions so they return a value making them ideal candidates for inline conditional bindings.</p>
<h2>Units of Measure</h2>
<p>Every programmer works with code that uses different units of measure. In most languages dealing with units of measure is error prone because they require discipline from the developer to ensure that the correct units are always used. There are some libraries that attempt to address the problem but to my knowledge (please correct me if I&#8217;m wrong) F# is the only one to actually include it in the type system. F#&#8217;s unit of measure support is complete enough that it can often automatically convert values between units, particularly when a conversion expression is included with the type definition.</p>
<pre class="brush: fsharp; title: ; notranslate">
[&lt;Measure&gt;] type px
[&lt;Measure&gt;] type inch
[&lt;Measure&gt;] type dot = 1 px
[&lt;Measure&gt;] type dpi = dot / inch

let convertToPixels (inches : float&lt;inch&gt;) (resolution : float&lt;dpi&gt;) : float&lt;px&gt; =
  inches * resolution

let convertToInches (pixels : float&lt;px&gt;) (resolution : float&lt;dpi&gt;) : float&lt;inch&gt; =
  pixels / resolution
</pre>
<p>The biggest downfall of F#&#8217;s units of measure is that they&#8217;re a feature of the type system and compiler rather than a CLR feature. As such, the compiled code doesn&#8217;t have any unit information and we can&#8217;t enforce the units in cross-language scenarios.</p>
<h2>Object Expressions</h2>
<p>I haven&#8217;t written about object expressions yet but they&#8217;re definitely on my backlog. Object expressions provide a way to create ad-hoc (anonymous) types based on one or more interfaces or a base class. They&#8217;re useful in a variety of scenarios like creating one-off formatters or comparers and I think they can at least supplement, if not replace some mocking libraries. To illustrate we&#8217;ll use a somewhat contrived example of a logging service.</p>
<pre class="brush: fsharp; title: ; notranslate">
type LogMessageType =
| DebugMessage of string
| InfoMessage of string
| ErrorMessage of string

type ILogProvider =
  abstract member Log : LogMessageType -&gt; unit

type LogService(provider : ILogProvider) =
  let log = provider.Log
  member this.LogDebug msg = DebugMessage(msg) |&gt; log
  member this.LogInfo msg = InfoMessage(msg) |&gt; log
  member this.LogError msg = ErrorMessage(msg) |&gt; log
</pre>
<p>Here we use a discriminated union to define the message types the logging provider interface can handle. The log service itself provides a slightly friendlier API than the provider interface itself. Normally if we wanted to use the log service instance we&#8217;d have to define a concrete implementation of <kbd>ILogProvider</kbd> but object expressions allow us to easily define one inline.</p>
<pre class="brush: fsharp; title: ; notranslate">
let logger =
  LogService(
    { new ILogProvider with
      member this.Log msg =
        match msg with
        | DebugMessage(m) -&gt; printfn &quot;DEBUG: %s&quot; m
        | InfoMessage(m) -&gt; printfn &quot;INFO: %s&quot; m
        | ErrorMessage(m) -&gt; printfn &quot;ERROR: %s&quot; m
    }
  )
</pre>
<p>In our object expression we use pattern matching to detect the message type, extract the associated string, and write an appropriate message to the console.</p>
<pre class="brush: fsharp; title: ; notranslate">
&gt; logger.LogDebug &quot;message&quot;
logger.LogInfo &quot;message&quot;
logger.LogError &quot;message&quot;;;
DEBUG: message
INFO: message
ERROR: message
</pre>
<h2>What&#8217;s Not So Great?</h2>
<p>I could continue on for a while with things I like about F# but this post is already long enough as it is. That said, I think it&#8217;s only fair to list out a few of the things I don&#8217;t like about the language.</p>
<h3>Tooling Support</h3>
<p>Probably the biggest gripe I have is the lack of tooling support around the language. So many tools and templates that I take for granted when working with C# simply aren&#8217;t available. Things like IntelliSense are pretty complete but if you&#8217;re just getting started with F# and looking to do more than a console application or library be prepared to spend some time looking for 3rd party templates and reading blog posts.</p>
<h3>Language Interop</h3>
<p>On a somewhat related note, even though F# compiles to MSIL and can reference or be referenced by other .NET assemblies there are some quirks that make language interoperability a but cumbersome. For instance, using extension methods defined in C# doesn&#8217;t work as cleanly as I thought they would. When I was experimenting with MassTransit I couldn&#8217;t get the UseMsmq, VerifyMsmqConfiguration, or a number of other extension methods to appear no matter what I tried. I ultimately had to call the static methods directly.</p>
<p><em>I&#8217;ve read that this is addressed in F# 3.0 but I haven&#8217;t done enough with 3.0 yet to confirm.</em></p>
<h3>Project Structure</h3>
<p>It&#8217;s not really fair to put this under the &#8220;what&#8217;s not so great?&#8221; heading but it seemed most appropriate. This isn&#8217;t so much an issue with the language as much as it&#8217;s a big mindset shift of a similar magnitude of switching from OO to functional. The structure of an F# project is significantly different than that of a C# (or even VB) project and is something I&#8217;m still struggling with.</p>
<p>In C# we generally organize code into folders representing namespaces and keep one type (class) per file. F# evaluates code from top down throughout the project so file sequence is significant. Furthermore, code is organized by modules rather than type. F# does have namespaces but even then they&#8217;re usually divided across one or more files and from my experience, not grouped by folder.</p>
<h2>Wrap Up</h2>
<blockquote><p>No matter what language you work in, programming in a functional style provides benefits. You should do it whenever it is convenient, and you should think hard about the decision when it isn&#8217;t convenient.<br />
&#8211; John Carmack, Functional Programming in C++</p></blockquote>
<p>In general I&#8217;ve found that the more I learn and work with F# the more I like it. I regularly find myself reaching for it as my first choice, especially when it comes to new development. Although there are a few things that I don&#8217;t like about working in F# most of them just require more diligence on my part or are easily managed. I&#8217;ve only listed a few key areas where I think F# excels but I firmly believe that their strengths far outweigh any weaknesses.</p>
<br /> Tagged: <a href='http://davefancher.com/tag/net/'>.NET</a>, <a href='http://davefancher.com/tag/c/'>C#</a>, <a href='http://davefancher.com/tag/f/'>F#</a>, <a href='http://davefancher.com/tag/software-development/'>Software Development</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2593/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2593/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2593&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/01/27/why-f/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>

		<media:content url="http://davefancher.files.wordpress.com/2013/01/decompiledcarddiscriminatedunion.jpg?w=300" medium="image">
			<media:title type="html">Decompiled Card Discriminated Union</media:title>
		</media:content>
	</item>
		<item>
		<title>Revisiting String Distances</title>
		<link>http://davefancher.com/2013/01/19/revisiting-string-distances/</link>
		<comments>http://davefancher.com/2013/01/19/revisiting-string-distances/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 21:50:10 +0000</pubDate>
		<dc:creator>Dave Fancher</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[String Comparison]]></category>
		<category><![CDATA[Hamming Distance]]></category>
		<category><![CDATA[Levenshtein Distance]]></category>
		<category><![CDATA[Damerau-Levenshtein Distance]]></category>
		<category><![CDATA[String Distances]]></category>

		<guid isPermaLink="false">http://davefancher.com/?p=2602</guid>
		<description><![CDATA[Back in April I wrote about three different string distance algorithms. &#160;If you&#8217;re not familiar with string distance algorithms I encourage you to read the original post but in short, these algorithms provide different ways to determine how many steps are required to translate one string into another. &#160;Since the algorithms I wrote about aren&#8217;t &#8230; <a href="http://davefancher.com/2013/01/19/revisiting-string-distances/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2602&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Back in April I wrote about three different <a title="String&nbsp;Distances" href="http://davefancher.com/2012/04/22/string-distances-9/">string distance algorithms</a>. &nbsp;If you&#8217;re not familiar with string distance algorithms I encourage you to read the original post but in short, these algorithms provide different ways to determine how many steps are required to translate one string into another. &nbsp;Since the algorithms I wrote about aren&#8217;t particularly complex I thought translating them to F# would be a fun exercise.</p>
<p>In general the code is pretty similar to its C# counterpart but I was able to take advantage of a few F# constructs, tuples and pattern matching in particular. &nbsp;These examples may or may not be the best way to implement the algorithms in F# (ok, I&#8217;ll be honest, they&#8217;re probably not) but they certainly show how well suited F# is to this type of work.</p>
<h2>Hamming Distance</h2>
<p>The Hamming distance algorithm simply counts how many characters are different in equal length strings.</p>
<pre class="brush: fsharp; title: ; notranslate">
let hammingDistance (source : string) (target : string) =
  if source.Length &lt;&gt; target.Length then failwith &quot;Strings must be equal length&quot;
 
  Array.zip (source.ToCharArray()) (target.ToCharArray())
  |&gt; Array.fold (fun acc (x, y) -&gt; acc + (if x = y then 0 else 1)) 0

hammingDistance &quot;abcde&quot; &quot;abcde&quot; |&gt; printfn &quot;%i&quot; // 0
hammingDistance &quot;abcde&quot; &quot;abcdz&quot; |&gt; printfn &quot;%i&quot; // 1
hammingDistance &quot;abcde&quot; &quot;abcyz&quot; |&gt; printfn &quot;%i&quot; // 2
hammingDistance &quot;abcde&quot; &quot;abxyz&quot; |&gt; printfn &quot;%i&quot; // 3
hammingDistance &quot;abcde&quot; &quot;awxyz&quot; |&gt; printfn &quot;%i&quot; // 4
hammingDistance &quot;abcde&quot; &quot;vwxyz&quot; |&gt; printfn &quot;%i&quot; // 5
</pre>
<h2>Levenshtein Distance</h2>
<p>The Levenshtein distance algorithm counts how many characters are different between any two strings taking into account character insertions and deletions.</p>
<pre class="brush: fsharp; title: ; notranslate">
open System
let levenshteinDistance (source : string) (target : string) =
  let wordLengths = (source.Length, target.Length)
  let matrix = Array2D.create ((fst wordLengths) + 1) ((snd wordLengths) + 1) 0

  for c1 = 0 to (fst wordLengths) do
    for c2 = 0 to (snd wordLengths) do
      matrix.[c1, c2] &lt;-
        match (c1, c2) with
        | h, 0 -&gt; h
        | 0, w -&gt; w
        | h, w -&gt;
          let sourceChar, targetChar = source.[h - 1], target.[w - 1]
          let cost = if sourceChar = targetChar then 0 else 1
          let insertion = matrix.[h, w - 1] + 1
          let deletion = matrix.[h - 1, w] + 1
          let subst = matrix.[h - 1, w - 1] + cost
          Math.Min(insertion, Math.Min(deletion, subst))
  matrix.[fst wordLengths, snd wordLengths]

levenshteinDistance &quot;abcde&quot; &quot;abcde&quot; |&gt; printfn &quot;%i&quot; // 0
levenshteinDistance &quot;abcde&quot; &quot;abcdz&quot; |&gt; printfn &quot;%i&quot; // 1
levenshteinDistance &quot;abcde&quot; &quot;abcyz&quot; |&gt; printfn &quot;%i&quot; // 2
levenshteinDistance &quot;abcde&quot; &quot;abxyz&quot; |&gt; printfn &quot;%i&quot; // 3
levenshteinDistance &quot;abcde&quot; &quot;awxyz&quot; |&gt; printfn &quot;%i&quot; // 4
levenshteinDistance &quot;abcde&quot; &quot;vwxyz&quot; |&gt; printfn &quot;%i&quot; // 5
levenshteinDistance &quot;abcdefg&quot; &quot;abcde&quot; |&gt; printfn &quot;%i&quot; // 2
levenshteinDistance &quot;abcdefg&quot; &quot;zxyde&quot; |&gt; printfn &quot;%i&quot; // 5
levenshteinDistance &quot;abcde&quot; &quot;bacde&quot; |&gt; printfn &quot;%i&quot; // 2
levenshteinDistance &quot;abcde&quot; &quot;baced&quot; |&gt; printfn &quot;%i&quot; // 4
</pre>
<h2>Damerau-Levenshtein Distance</h2>
<p>The Damerau-Levenshtein algorithm builds upon the Levenshtein algorithm by taking transpositions into account.</p>
<pre class="brush: fsharp; title: ; notranslate">
open System
let damerauLevenshteinDistance (source : string) (target : string) =
  let wordLengths = (source.Length, target.Length)
  let matrix = Array2D.create ((fst wordLengths) + 1) ((snd wordLengths) + 1) 0

  for h = 0 to (fst wordLengths) do
    for w = 0 to (snd wordLengths) do
      matrix.[h, w] &lt;-
        match (h, w) with
        | x, 0 -&gt; x
        | 0, y -&gt; y
        | x, y -&gt;
          let sourceChar, targetChar = source.[x - 1], target.[y - 1]
          let cost = if sourceChar = targetChar then 0 else 1
          let insertion = matrix.[x, y - 1] + 1
          let deletion = matrix.[x - 1, y] + 1
          let subst = matrix.[x - 1, y - 1] + cost

          let distance = Math.Min(insertion, Math.Min(deletion, subst))

          if x &gt; 1 &amp;&amp; w &gt; 1 &amp;&amp; sourceChar = target.[y - 2] &amp;&amp; source.[x - 2] = targetChar then
            Math.Min(distance, matrix.[x - 2, y - 2] + cost)
          else
            distance
  matrix.[fst wordLengths, snd wordLengths]

damerauLevenshteinDistance &quot;abcde&quot; &quot;abcde&quot; |&gt; printfn &quot;%i&quot; // 0
damerauLevenshteinDistance &quot;abcde&quot; &quot;abcdz&quot; |&gt; printfn &quot;%i&quot; // 1
damerauLevenshteinDistance &quot;abcde&quot; &quot;abcyz&quot; |&gt; printfn &quot;%i&quot; // 2
damerauLevenshteinDistance &quot;abcde&quot; &quot;abxyz&quot; |&gt; printfn &quot;%i&quot; // 3
damerauLevenshteinDistance &quot;abcde&quot; &quot;awxyz&quot; |&gt; printfn &quot;%i&quot; // 4
damerauLevenshteinDistance &quot;abcde&quot; &quot;vwxyz&quot; |&gt; printfn &quot;%i&quot; // 5
damerauLevenshteinDistance &quot;abcdefg&quot; &quot;abcde&quot; |&gt; printfn &quot;%i&quot; // 2
damerauLevenshteinDistance &quot;abcdefg&quot; &quot;zxyde&quot; |&gt; printfn &quot;%i&quot; // 5
// Transpositions
damerauLevenshteinDistance &quot;abcde&quot; &quot;bacde&quot; |&gt; printfn &quot;%i&quot; // 1
damerauLevenshteinDistance &quot;abcde&quot; &quot;baced&quot; |&gt; printfn &quot;%i&quot; // 2
</pre>
<br /> Tagged: <a href='http://davefancher.com/tag/net/'>.NET</a>, <a href='http://davefancher.com/tag/damerau-levenshtein-distance/'>Damerau-Levenshtein Distance</a>, <a href='http://davefancher.com/tag/f/'>F#</a>, <a href='http://davefancher.com/tag/hamming-distance/'>Hamming Distance</a>, <a href='http://davefancher.com/tag/levenshtein-distance/'>Levenshtein Distance</a>, <a href='http://davefancher.com/tag/software-development/'>Software Development</a>, <a href='http://davefancher.com/tag/string-comparison/'>String Comparison</a>, <a href='http://davefancher.com/tag/string-distances/'>String Distances</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davefancher.wordpress.com/2602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davefancher.wordpress.com/2602/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davefancher.com&#038;blog=12467521&#038;post=2602&#038;subd=davefancher&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://davefancher.com/2013/01/19/revisiting-string-distances/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad02f59c6c342c3788b9439c53bbf242?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">davefancher</media:title>
		</media:content>
	</item>
	</channel>
</rss>
