<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>F#</title>
        <link>http://geekswithblogs.net/Podwysocki/category/7560.aspx</link>
        <description>F#</description>
        <language>en-US</language>
        <copyright>Matthew Podwysocki</copyright>
        <managingEditor>matthew.podwysocki@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>ALT.NET Open Spaces Closing Day Recap</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/24/121604.aspx</link>
            <description>In my previous post, I talked about some of the happenings from the day two experience.  Day three was only a half day with only two sessions.  So, it was best to make the best of times anyhow.  Once again, it snowed again, rather heavily at times, so nature's cruel joke on ALT.NET.&lt;br /&gt;
&lt;br style="font-weight: bold;" /&gt;
&lt;span style="font-weight: bold;"&gt;Impromptu Sessions&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
One of the best sessions was an impromptu session with &lt;a href="http://codebetter.com/blogs/jeremy.miller/"&gt;Jeremy Miller&lt;/a&gt; on the &lt;a href="http://storyteller.tigris.org/"&gt;StoryTeller&lt;/a&gt; tool and his future plans for it.  If you're not familiar with it, it is a tool used to manage and create automated testing over the &lt;a href="http://www.syterra.com/FitnesseDotNet.html"&gt;FitNesse Dot Net&lt;/a&gt; libraries and helps in an acceptance test driven development environment.  Anyhow, a number of us managed to corner him at one point during the day and sure enough he had his laptop available.  From there, we were able to encourage him to work on it some more as well as learn about where to go from where it is right now.  Jeremy covers more about it &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/04/23/structuremap-and-storyteller-plans.aspx"&gt;here&lt;/a&gt;.  Sometimes these impromtu sessions are some of the more valuable interactions to be had at events such as these.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;More Video To Be Had&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
It seems that almost everyone had a camera at the event.  &lt;a href="http://codebetter.com/blogs/gregyoung"&gt;Greg Young&lt;/a&gt; and &lt;a href="http://codebetter.com/blogs/david_laribee/"&gt;Dave Laribee&lt;/a&gt; managed to capture a bit of the sessions on video.  That's a great thing because I honestly wish I could have cloned myself and gone to more sessions.  Hopefully more of this will be forthcoming.  Dave posted Greg Young's &lt;a href="http://en.wikipedia.org/wiki/Fishbowl_%28conversation%29"&gt;fishbowl conversation&lt;/a&gt; on Architecture Futures which you can see &lt;a href="http://codebetter.com/blogs/david_laribee/archive/2008/04/23/future-architectures-fishbowl.aspx"&gt;here&lt;/a&gt;.  &lt;br /&gt;
&lt;br /&gt;
Other videos that are on this list are from &lt;a href="http://iunknown.com"&gt;John Lam's&lt;/a&gt; &lt;a href="http://www.ironruby.net/"&gt;IronRuby&lt;/a&gt; session, &lt;a href="http://udidahan.weblogs.us"&gt;Udi Dahan&lt;/a&gt; with &lt;a href="http://weblogs.asp.net/scottgu"&gt;ScottGu&lt;/a&gt; and &lt;a href="http://www.lostechies.com/blogs/chad_myers/"&gt;Chad Myers&lt;/a&gt; talking about Microsoft and Open Source Software and so on.  You can find them at the end of Greg's video.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Software Design Has Failed, What Can We Do About It?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Scott Koon, aka &lt;a href="http://www.lazycoder.com"&gt;LazyCoder&lt;/a&gt;, convened with &lt;a href="http://www.jpboodhoo.com/blog/"&gt;JP Boodhoo&lt;/a&gt; a session on how software design has failed us.  This turned into a fishbowl conversation as well since there was a lot to be said.  The basic points revolved around the large amount of software failures.  What causes them?  Are they technological issues?  People issues?  Politics?  Many people brought their opinions to bear, and it was interesting that the point that I brought is that at the end of the day, customer satisfaction is the metric that matters.  Are we listening to them?  In the Agile methodology world, customer satisfaction is the only metric.  Yes, we can talk about TDD/BDD, DDD and so on, but are we actually putting software into the hands of the user that they actually want?&lt;br /&gt;
&lt;br /&gt;
I'm not forgetting of course the ideals around mentoring and helping make the team stronger.  Those issues are important as well.  Do we do pair programming?  Do we hold brown bag sessions?  All of those suggestions are key to helping grow a stronger team.  But, also it helps grow the team as a more cohesive unit that's not afraid to ask questions, pair up and avoid flailing.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;F# and Concurrency&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Roy Osherove convened a session on concurrency and functional programming as the last topic I was going to attend.  When we start to deal with multi-core environments, threading issues come to bear more frequently.  Are we utilizing the CPUs to the maximum or are we still just sitting on that one thread, and barely using the machine to its capacity?  Those are many of the issues we face.  In &lt;a href="http://se-radio.net/podcast/2006-05/episode-14-interview-ted-neward"&gt;Software Engineering Radio Episode 14&lt;/a&gt;, &lt;a href="http://blogs.tedneward.com/"&gt;Ted Neward&lt;/a&gt; talks to this very point quite frankly that multi-threaded programming is hard.  There are no two ways about it.  But, when we talk about functional programming, some of that is solved.  Why?  Immutability by default is one of the key strong points of FP.  Instead, you have to go out of your way to make a value to be mutable.  Is this something we'll see in C# 4.0?  Spec# has something to say about it.  And once again, another topic for discussion.  I keep putting these things on my plate...&lt;br /&gt;
&lt;br /&gt;
Anyhow, Harry Pierson and I helped run this session.  Harry had some of his parsing code that he has posted on his blog to show off.  I think that did the trick well to show some advanced things such as &lt;a href="http://en.wikipedia.org/wiki/Higher-order_function"&gt;high order functions&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Pattern_matching"&gt;pattern matching&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Anonymous_functions"&gt;anonymous functions&lt;/a&gt; and so on.  Instead, if you wish to learn more, I'll probably cover it here in some detail, but you can check chapter 13 of Don Syme's "Expert F#" book to learn more in the mean time.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Action Items&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Some action items came up from this event that I think are rather important.  Because ALT.NET is a community looking to improve itself, there are naturally some things that help.  Here are a few that I can think of:&lt;br /&gt;
&lt;ol&gt;
    &lt;li&gt;Keep the conversation going&lt;br /&gt;
    Just because the conference ended doesn't mean the conversations that started there have to.&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Start a local group&lt;br /&gt;
    After the session was done, the &lt;a href="http://tech.groups.yahoo.com/group/altdotnet/"&gt;altdotnet mailing list &lt;/a&gt;came alive with people wanting to create that ALT.NET groups like I did in &lt;a href="http://altnet.ent0.com"&gt;DC&lt;/a&gt;, &lt;a href="http://persistall.com"&gt;Brian Donahue&lt;/a&gt; did in &lt;a href="http://phillyalt.net/"&gt;Philly&lt;/a&gt; and &lt;a href="http://jeremyjarrell.com/"&gt;Jeremy Jarrell&lt;/a&gt; did in &lt;a href="http://www.pittsburghalt.net/"&gt;Pittsburgh&lt;/a&gt;.&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Support the community&lt;br /&gt;
    &lt;a href="http://www.lostechies.com/blogs/rhouston/archive/2008/04/22/funding-open-source-with-donations.aspx"&gt;Ray Houston&lt;/a&gt; laid out a challenge for those who use Open Source products to donate to them.  This doesn't mean only money, but time as well.  Many projects are in need of some assistance, and all it takes is for someone to ask.&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Challenge Assumptions and Bring Change&lt;br /&gt;
    It was said best during the conference "If you can't change your job, change your job".  Don't let these discussions that happened here just stay there.  Bring them to your work place, bring change for the better.  Question why things are done the way they are.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Wrapping it Up&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I'm glad to have been a part of this event in Seattle.  It couldn't have been with a better bunch of people who are willing to better themselves, challenge themselves and their assumptions and bring change to the developer community.  There was a lot to learn this past weekend and each conversation brought up a new angle.  Until next time...
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/24/121604.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/24/121604.aspx" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121604"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121604" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121604.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/24/121604.aspx</guid>
            <pubDate>Thu, 24 Apr 2008 06:20:38 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121604.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/24/121604.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121604.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121604.aspx</trackback:ping>
        </item>
        <item>
            <title>NOVARUG with Dave Thomas (PragDave) Recap</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/17/121312.aspx</link>
            <description>Last night I attended the &lt;a href="http://novarug.org"&gt;Northern Virginia Ruby Users Group (NovaRUG)&lt;/a&gt; meeting in Reston last night with &lt;a href="http://pragdave.pragprog.com/"&gt;Dave Thomas (PragDave)&lt;/a&gt; and &lt;a href="http://chadfowler.com/"&gt;Chad Fowler&lt;/a&gt;.  It was a completely packed house and the temperatures were a bit hight in the room, but it was well worth the sweating to attend.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://paulbarry.com/"&gt;Paul Barry&lt;/a&gt; presented first on &lt;a href="http://www.merbivore.com/"&gt;Merb&lt;/a&gt; and gave a really good demonstration of some of the capabilities in comparison to Ruby on Rails.  If you're not familiar with Merb, it is a lightweight Model View Controller framework written in Ruby.  It was written by &lt;a href="http://brainspl.at/"&gt;Ezra Zygmuntowicz&lt;/a&gt; in response to trying and giving up on making Ruby on Rails thread safe.  You can find his presentation materials &lt;a href="http://paulbarry.com/articles/2008/04/17/merb-intro"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
It was mentioned that there will be a Ruby conference in the Northern Virginia area upcoming  I'd like to see if we can get some IronRuby in there instead of all those Java guys with JRuby.  We'll see what happens, but for right now, everything seems to be in flux.  Stay tuned!&lt;br /&gt;
&lt;br /&gt;
Next up, Dave Thomas talked about the Ruby object model with a very good presentation.  Below you can find some of my pictures I took from the event.  Forgive the quality of the images, but you can tell that it was a crowded place!  Anyhow, it was a really good talk about the object model, how the scoping of self and the resolution of classes and methods are done deep down in Ruby.  It was an excellent presentation and I was definitely excited by his passion for the community and the technology.&lt;br /&gt;
&lt;br /&gt;
First we have Dave talking about the inheritance chain of Ruby objects.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://weblogs.asp.net/blogs/podwysocki/dave_1.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
Then here's Dave talking about the method resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://weblogs.asp.net/blogs/podwysocki/Dave_2.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
I had a chance to chat with Dave afterwards on F# as he has been looking into OCaml lately, where F# got most of its functionality from.  It's his hope that F# succeeds and I ultimately think it will.  So, I told him to give it a try.  Anyhow, it was a great night and good to reach out to the community.  The DC area has a pretty rich community of .NET, Ruby and Java programmers that's really refreshing to see.  Until next time...
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/17/121312.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/17/121312.aspx" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121312"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121312" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121312.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/17/121312.aspx</guid>
            <pubDate>Thu, 17 Apr 2008 15:29:31 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121312.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/17/121312.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121312.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121312.aspx</trackback:ping>
        </item>
        <item>
            <title>Metaprogramming in F#</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/16/121296.aspx</link>
            <description>Tonight I will be heading to the &lt;a href="http://www.novarug.org/"&gt;Northern Virginia Ruby Users Group (NoVARUG)&lt;/a&gt; meeting tonight with &lt;a href="http://pragdave.pragprog.com/"&gt;Dave Thomas (PragDave)&lt;/a&gt; talking about &lt;a href="http://en.wikipedia.org/wiki/Metaprogramming"&gt;metaprogramming&lt;/a&gt; in Ruby.  Should be a great time and I'm sure it will be full tonight.   For those interested in some introduction to metaprogramming in Ruby, here's a &lt;a href="http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html"&gt;good link&lt;/a&gt; to help get you started.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Metaprogramming in F#?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
One of the many things that has interested me in F# is that it was originally written as a language to write other languages.  This of course leads me to a discussion of F# and metaprogramming.  Is it a fit?  There are a couple of links well worth visiting and then at a future date, we'll come back to the subject.&lt;br /&gt;
&lt;br /&gt;
Before the links, most of the language oriented stuff comes from quotations.  Quotations are a little block of code which turns a particular piece of code into an expression tree.  This language tree can then be transformed, optimized and even compiled into different languages.  There are two types of these quotations, raw and typed.  Typed Quotations contain static typing information whereas the raw do not.  For a good introduction to these, check out &lt;a href="http://tomasp.net/"&gt;Tomas Petricek's&lt;/a&gt; post &lt;a href="http://tomasp.net/blog/fsquotations.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://research.microsoft.com/~dsyme/papers/ml03-syme.pdf"&gt;Leveraging Meta-Programming Components with F#&lt;/a&gt; - &lt;a href="http://blogs.msdn.com/dsyme/"&gt;Don Syme&lt;/a&gt;&lt;br /&gt;
    Talks about F# with Quotations and LINQ expressions for expressing metaprogramming in F#&lt;br /&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://tomasp.net/blog/fsclassmeta.aspx"&gt;F# metaprogramming and classes&lt;/a&gt; - &lt;a href="http://tomasp.net/"&gt;Tomas Petricek&lt;/a&gt;&lt;br /&gt;
    Talks about Class Quotations and basic metaprogramming capabilities in F# and its limitations&lt;br /&gt;
    &lt;/li&gt;
&lt;/ul&gt;
I hope when I get a further chance, I'll dig into it a bit more here.  Until next time...
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/16/121296.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/16/121296.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121296"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121296" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121296.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/16/121296.aspx</guid>
            <pubDate>Wed, 16 Apr 2008 21:19:20 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121296.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/16/121296.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121296.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121296.aspx</trackback:ping>
        </item>
        <item>
            <title>Adventures in F# - F# 101 Part 8 (Mutables and Reference Cells)</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/15/121272.aspx</link>
            <description>Time for another adventure in F#, covering some of the basics of functional programming and F# in particular.  Today we'll manage to look more at regular .NET integration and .NET programming.  With the previous efforts, we've looked more at &lt;a href="http://en.wikipedia.org/wiki/Functional_programming"&gt;functional programming&lt;/a&gt; and in turn F# specific things, but want to show that you can do anything normally in F# that you can in C#.  To me, F# is the perfect all-purpose language because it can do a lot of the things C# can do, but in turn, F# can do things much more elegantly than C# can, such as &lt;a href="http://en.wikipedia.org/wiki/Pattern_matching"&gt;Pattern Matching&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Where We Are&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Before we begin today, let's catch up to where we are today:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-1.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-1.aspx"&gt;Part 1 - Basic functional programming&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-2.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-2.aspx"&gt;Part 2 - Currying and Tuples&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-3.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-3.aspx"&gt;Part 3 - Scope, Recursion and Anonymous Functions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-4.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-4.aspx"&gt;Part 4 - History of F#, Operators and Lists&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-5-pattern-matching.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-5-pattern-matching.aspx"&gt;Part 5 - Pattern Matching&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/21/adventures-in-f-f-101-part-6-lazy-evaluation.aspx"&gt;Part 6 - Lazy Evaluation&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/04/02/adventures-in-f-f-101-part-7-creating-types.aspx"&gt;Part 7 - Creating Types&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
Today's topic will be covering imperative and object oriented programming in F#.  There is a lot to cover, so let's get started.  But there are a few administrative things to get out of the way first.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Learning F# ala Ted Neward?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.tedneward.com/"&gt;Ted Neward&lt;/a&gt; recently announced on &lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=332"&gt;DotNetRocks Episode 332&lt;/a&gt;  that he's in the process of creating a class for F# for &lt;a href="http://www.pluralsight.com/"&gt;Pluralsight&lt;/a&gt;.  That should be interesting to those who are interested in this series, as well as F# in general.  Right now the community is rather small, so efforts like this should be rather rewarding I would hope.  Ted's a pretty brilliant guy, so I'd imagine only the best.  I'm hoping more details come out soon.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Pattern Matching in C#&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Part of this series is intended to bring such concepts as Pattern Matching, &lt;a href="http://en.wikipedia.org/wiki/Currying"&gt;Currying&lt;/a&gt; and other Functional Programming concepts to the C# developer.  After all, the more C# language evolves, the more it seems to fall into the Functional Programming category.  In previous posts, I showed how to relate currying to C# and it was less elegant than F# to say the least.&lt;br /&gt;
&lt;br /&gt;
But, let's look at Pattern Matching.  &lt;a href="http://community.bartdesmet.net/blogs/bart/"&gt;Bart De Smet&lt;/a&gt; has been posting recently on his blog about bringing the beauty of pattern matching to C#.  So far it's been a good six posts into it and I urge you to go ahead and take a look at this series.  &lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/06/pattern-matching-in-c-part-0.aspx"&gt;Pattern Matching in C# - Part 0&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/07/pattern-matching-in-c-part-1.aspx"&gt;Pattern Matching in C# - Part 1&lt;/a&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/06/pattern-matching-in-c-part-0.aspx"&gt;&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/08/pattern-matching-in-c-part-2.aspx"&gt;Pattern Matching in C# - Part 2&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/09/pattern-matching-in-c-part-3.aspx"&gt;Pattern Matching in C# - Part 3&lt;/a&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/06/pattern-matching-in-c-part-0.aspx"&gt;&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/10/pattern-matching-in-c-part-4.aspx"&gt;Pattern Matching in C# - Part 4&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/11/pattern-matching-in-c-part-5.aspx"&gt;Pattern Matching in C# - Part 5&lt;br /&gt;
    &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/14/pattern-matching-in-c-part-6.aspx"&gt;Pattern Matching in C# - Part 6&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2008/04/15/pattern-matching-in-c-part-7.aspx"&gt;Pattern Matching in C# - Part 7&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
But when you read the series, it's all about getting into the low level and compiling expression trees to make the same simple beauty that is F#.  Sure, it can be done in C#, but nowhere near as elegant.  Performance is another issue that comes to mind with these.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Imperative Programming in F#&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This section I'll lay out some of the basics of imperative style programming before I get into the full object oriented approach to programming.  So, we'll cover just a few topics and then I'll feel comfortable moving onto the real parts of creating classes and such.  We'll cover such things as void types and mutability in this section.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;The unit Type&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
One of the first things I forgot to mention when describing F# functions and values in the unit type.  Think of this as the void type in C# that you are used to.  It's the type that doesn't accept or return a value.  First, let's look at the typical C# program with the void type for Hello World.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;\red255\green255\blue0;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2     \cf3 class\cf1  \cf4 Program\par ??\cf1     \{\par ??        \cf3 static\cf1  \cf3 void\cf1  Main(\cf3 string\cf1 [] args)\par ??        \{\par ??            \cf4 Console\cf1 .WriteLine(\cf5 "Hello World"\cf1 );\par ??        \}\par ??    \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;Program&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; Main(&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: yellow;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: lime;"&gt;"Hello World"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
Now, let's go ahead and look at it from the F# perspective. &lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;main() =&lt;br /&gt;
  printfn &lt;span style="color: rgb(0, 255, 0);"&gt;"Hello World"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
As you will see when you hover over our code is that it is a unit type.  That in itself isn't all that interesting.   But, what we'll run into is problems when functions return a value, but we're not all that interested in them.  What happens?  Well, F# will complain that your return value isn't compatible with the unit type, which is essentially true.  So, how do you get around that?  Let's walk through a simple unit test of a Stack written in F# and unit testing with the &lt;a href="http://codeplex.com/xunit"&gt;xUnit.net&lt;/a&gt; framework.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
#R &lt;span style="color: rgb(0, 255, 0);"&gt;@"D:\Tools\xunit-build-1252\xunit.dll"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;open &lt;/span&gt;System&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;open &lt;/span&gt;System.Collections.Generic&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;open &lt;/span&gt;Xunit&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;type &lt;/span&gt;Stack&amp;lt;'t&amp;gt; = &lt;span style="color: rgb(255, 153, 0);"&gt;class&lt;/span&gt;&lt;br /&gt;
  &lt;span style="color: rgb(255, 153, 0);"&gt;val &lt;/span&gt;elements : LinkedList&amp;lt;'t&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &lt;span style="color: rgb(255, 153, 0);"&gt;new&lt;/span&gt;() = { elements = &lt;span style="color: rgb(255, 153, 0);"&gt;new &lt;/span&gt;LinkedList&amp;lt;'t&amp;gt;() }&lt;br /&gt;
 &lt;br /&gt;
  &lt;span style="color: rgb(255, 153, 0);"&gt;member &lt;/span&gt;x.IsEmpty&lt;br /&gt;
    &lt;span style="color: rgb(255, 153, 0);"&gt;with &lt;/span&gt;get() = x.elements.Count = 0&lt;br /&gt;
   &lt;br /&gt;
  &lt;span style="color: rgb(255, 153, 0);"&gt;member &lt;/span&gt;x.Push element =&lt;br /&gt;
    x.elements.AddFirst(element:'t)&lt;br /&gt;
   &lt;br /&gt;
  &lt;span style="color: rgb(255, 153, 0);"&gt;member &lt;/span&gt;x.Top&lt;br /&gt;
    &lt;span style="color: rgb(255, 153, 0);"&gt;with &lt;/span&gt;get() =&lt;br /&gt;
      &lt;span style="color: rgb(255, 153, 0);"&gt;if &lt;/span&gt;x.elements.Count = 0 &lt;span style="color: rgb(255, 153, 0);"&gt;then&lt;/span&gt;&lt;br /&gt;
        raise (InvalidOperationException("cannot top an empty stack"))&lt;br /&gt;
      x.elements.First.Value&lt;br /&gt;
     &lt;br /&gt;
  &lt;span style="color: rgb(255, 153, 0);"&gt;member &lt;/span&gt;x.Pop() =&lt;br /&gt;
    let top = x.Top&lt;br /&gt;
    x.elements.RemoveFirst()&lt;br /&gt;
    top&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
[&amp;lt;Fact&amp;gt;]  &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;PopEmpty () =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;stack = &lt;span style="color: rgb(255, 153, 0);"&gt;new&lt;/span&gt; Stack&amp;lt;string&amp;gt;()&lt;br /&gt;
  Assert.Throws&amp;lt;InvalidOperationException&amp;gt;(&lt;span style="color: rgb(255, 153, 0);"&gt;fun &lt;/span&gt;() -&amp;gt; stack.Pop() |&amp;gt; ignore )&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
The real interesting part you should pay attention to is the last line.  As you can see, I am using the forward operator to indicate that I really don't care what the function returns, just that I'm interested in that it executes.  This is most likely during such functions that have some sort of side effect to them.  I could also use the ignore function instead of the forward operator such as this:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;[&amp;lt;Fact&amp;gt;]  &lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;let &lt;/span&gt;PopEmpty () =&lt;br /&gt;
  &lt;span style="color: rgb(255, 153, 0);"&gt;let &lt;/span&gt;stack &lt;span style="color: rgb(255, 153, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;=&lt;/span&gt; new &lt;/span&gt;Stack&amp;lt;string&amp;gt;()&lt;br /&gt;
  Assert.Throws&amp;lt;InvalidOperationException&amp;gt;(&lt;span style="color: rgb(255, 153, 0);"&gt;fun &lt;/span&gt;() -&amp;gt; ignore(stack.Pop()) )&lt;br /&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
This is very helpful in these cases where we really don't care about the return value, instead want to mutate the state of our given object, such as removing a value from a collection and so on.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Mutables&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As I said in many posts before, by default all "variables" by which I mean values in F# are immutable.  This is a standard in functional programming and all in the ML family.  You can easily redefine a value by using the let keyword, but not actually mutate its state.  But, since F# is a multi-purpose language on the .NET platform, mutable state can be had.  To take advantage of this, mark your value as mutable.  Then to change the value, just use the &amp;lt;- operator to reassign the value.  Below is a simple example of this:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;let mutable&lt;/span&gt; answer = 42&lt;br /&gt;
printfn &lt;span style="color: rgb(0, 255, 0);"&gt;"Answer is %i"&lt;/span&gt; answer&lt;br /&gt;
answer &amp;lt;- 8&lt;br /&gt;
printfn &lt;span style="color: rgb(0, 255, 0);"&gt;"Answer is %i"&lt;/span&gt; answer&lt;br /&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
A key difference from the reassignment is that you cannot change the value type.  Whereas I can redefine answer by keep using the let keyword, I can only keep my answer in this above example of the int type.  &lt;br /&gt;
&lt;br /&gt;
This can also apply to record types as well where you can change the fields.  In the last installment, we talked about record types.  Well, by default there as well, the fields for the record type are immutable.  But, as with before, that can be changed.  I of course like to caution people that mutable state takes a lot of the value proposition away from the side effect free programming that you gain with F# by default.  But, nevertheless, you can still do it as noted below:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;type &lt;/span&gt;Person = { FirstName : string; &lt;span style="color: rgb(255, 153, 0);"&gt;mutable &lt;/span&gt;LastName : string; &lt;span style="color: rgb(255, 153, 0);"&gt;mutable &lt;/span&gt;IsMarried : bool }&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;let &lt;/span&gt;friend = { FirstName = "Courtney"; LastName = "Cox"; IsMarried = &lt;span style="color: rgb(255, 153, 0);"&gt;false &lt;/span&gt;}&lt;br /&gt;
friend.LastName &amp;lt;- "Cox-Arquette"&lt;br /&gt;
friend.IsMarried &amp;lt;- true &lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
What I was able to do was define a Person record and change a couple of fields while using the &amp;lt;- operator and defining the fields as mutable.  Yes, I could have used some scientific calculation or something, but this was easy.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Reference Cells&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The last thing I want to touch on in this post is reference cells.  You can think of these much as pointers in other languages or reference types.  These of course can be of any type.  The idea behind using these is to make updating fields as easy as possible.  As with mutable fields, you cannot change the type once it has been assigned.  To use these, you need to remember three basic operators&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;ref &lt;/span&gt;- Allocates a reference cell&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;:=&lt;/span&gt; - Mutates a reference cell&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;!&lt;/span&gt; - Reads the reference cell&lt;br /&gt;
    &lt;/li&gt;
&lt;/ul&gt;
Below is a quick example of mutation through reference cells:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 153, 0);"&gt;let &lt;/span&gt;x = ref 2&lt;br /&gt;
x := !x + 25&lt;br /&gt;
printfn &lt;span style="color: rgb(0, 255, 0);"&gt;"%i"&lt;/span&gt; !x&lt;br /&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
What the code example above lets me do is define a reference to the number 2.  Then I can change that reference by reading the current x value and adding 25.  Then I mutate the existing x value with the result.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is just meant to be a brief overview to some imperative programming constructs that you might see in .NET, Java, C, C++ and so on.  F# is a first class language all the way with constructs that support these things as well as your normal functional programming constructs.  I hope we get to cover some of this at &lt;a href="http://altdotnet.org/events/seattle"&gt;ALT.NET Open Spaces, Seattle&lt;/a&gt; at some point because I'm sure a lot of people will be interested.  Until next time...
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/15/121272.aspx"&gt;&lt;img border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/15/121272.aspx" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121272"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121272" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121272.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/15/121272.aspx</guid>
            <pubDate>Tue, 15 Apr 2008 23:08:37 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121272.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/15/121272.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121272.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121272.aspx</trackback:ping>
        </item>
        <item>
            <title>Relooking at xUnit.net RC2</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx</link>
            <description>&lt;span style="font-weight: bold;"&gt;UPDATE: More posts on the subject&lt;br /&gt;
&lt;/span&gt;
&lt;ul&gt;
    &lt;li style="font-weight: bold;"&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/04/10/xunit-net-rc3-just-released.aspx"&gt;xUnit.net RC3 Just Released&lt;/a&gt;&lt;br /&gt;
    &lt;/li&gt;
&lt;/ul&gt;
Earlier this week, I wrote about the latest release of xUnit.net RC2.  Since that time, &lt;a href="http://bradwilson.typepad.com/"&gt;Brad Wilson&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/jamesnewkirk/"&gt;Jim Newkirk&lt;/a&gt; released a new version to fix some of the issues with regards to &lt;a href="http://www.testdriven.net/"&gt;TestDriven.NET&lt;/a&gt; integration and &lt;a href="http://asp.net/mvc/"&gt;ASP.NET MVC&lt;/a&gt; integration.    You can read more about the issues &lt;a href="http://bradwilson.typepad.com/blog/2008/04/xunitnet-rc2--1.html"&gt;here&lt;/a&gt;.  As always you can get the latest bits &lt;a href="http://www.codeplex.com/xunit/Release/ProjectReleases.aspx?ReleaseId=12209"&gt;here&lt;/a&gt;.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;The Installer&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you browse to the releases page of xUnit.net, you will notice an installer.  This installer will help integrate xUnit.net with &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper 3.1&lt;/a&gt; for Visual Studio 2005 and 2008, TestDriven.NET and ASP.NET MVC.  Just click the installer and a screen like below will show.  Note that I have &lt;a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+Nightly+Builds"&gt;Resharper 4.0 nightly builds&lt;/a&gt; instead of 3.1, so those features aren't activated just yet, unfortunately.  &lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://weblogs.asp.net/blogs/podwysocki/xunitnet_installer_aspnetmvc.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
Since I didn't have anything else but ASP.NET MVC Preview 2 installed, that's all I got enabled.  It only takes a few seconds to enable.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;ASP.NET MVC&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now that I got the ASP.NET MVC plugin installed for xUnit, I can go ahead and open Visual Studio 2008 and create a new ASP.NET MVC application.  When it automatically creates the test project for me, I have the option now of using xUnit.net instead of that lesser one that came in here by default.&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://weblogs.asp.net/blogs/podwysocki/aspnet_mvc_xunittests.png" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
Once I do that, it will create some tests of the HomeController and Routes by default as noted below:&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://weblogs.asp.net/blogs/podwysocki/aspnet_mvc_solution.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
But in order for this to work out of the box, there is some work you need to do.  Your tests will not compile by default because you need to change the namespace includes on top to include your application's namespace.  Not a huge issue mind you, but a little more work than usual.  Here's what it will look like:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green128\blue0;\red40\green40\blue40;\red255\green255\blue255;\red0\green255\blue0;\red255\green255\blue0;}??\fs16 \cf1\cb2\highlight2 using\cf3  MVC_APPLICATION_NAMESPACE.Controllers; \cf4 // This using directive needs to point to the namespace of your MVC project\par ??\cf1 using\cf3  Xunit;\par ??\par ??\cf1 namespace\cf3  PetShopTests.Controllers\par ??\{\par ??    \cf1 public\cf3  \cf1 class\cf3  \cf5 HomeControllerFacts\par ??\cf3     \{\par ??        \cf1 public\cf3  \cf1 class\cf3  \cf5 Index\par ??\cf3         \{\par ??            [\cf5 Fact\cf3 ]\par ??            \cf1 public\cf3  \cf1 void\cf3  RendersTheIndexView()\par ??            \{\par ??                \cf5 TestableHomeController\cf3  controller = \cf1 new\cf3  \cf5 TestableHomeController\cf3 ();\par ??\par ??                controller.Index();\par ??\par ??                \cf5 Assert\cf3 .Equal(\cf4 "Index"\cf3 , controller.RenderView_ViewName);\par ??            \}\par ??        \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; MVC_APPLICATION_NAMESPACE.Controllers; &lt;span style="color: lime;"&gt;// This using directive needs to point to the namespace of your MVC project&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; Xunit;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;namespace&lt;/span&gt; PetShopTests.Controllers&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;HomeControllerFacts&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;Index&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            [&lt;span style="color: yellow;"&gt;Fact&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; RendersTheIndexView()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;TestableHomeController&lt;/span&gt; controller = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;TestableHomeController&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                controller.Index();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(&lt;span style="color: lime;"&gt;"Index"&lt;/span&gt;, controller.RenderView_ViewName);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
So, all you need to do is replace the &lt;span style="font-weight: bold;"&gt;MVC_APPLICATION_NAMESPACE&lt;/span&gt; with your own namespace and problem solved!  But out of the box, you have some working unit tests and some good guidance on how to get started.  If you're curious on how the integration actually works, check out this post &lt;a href="http://blogs.msdn.com/webdevtools/archive/2008/03/06/asp-net-mvc-test-framework-integration-demo.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;GUI Runner&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As Brad had stated earlier, there is a simple, yet effective GUI runner for xUnit.net.  So far there's not much to it, other than to load an assembly and run all associated tests.  To give you an example, I wrote some F# code and now I want to run some tests against it.  So, here is the code I used for these simple tests.  Yes, you can go ahead and yell at me for doing OO things in a functional language, but it's here to prove a point that you can.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
#R @&lt;span style="color: rgb(0, 255, 0);"&gt;"E:\Tools\xunit-build-1223-samples\Samples\xunit\xunit.dll" &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;System&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;System.Collections.Generic&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Xunit&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type &lt;/span&gt;Stack&amp;lt;'t&amp;gt; = &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt;&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;val&lt;/span&gt; elements : LinkedList&amp;lt;'t&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  new() = { elements = &lt;span style="color: rgb(255, 128, 0);"&gt;new &lt;/span&gt;LinkedList&amp;lt;'t&amp;gt;() }&lt;br /&gt;
  &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.IsEmpty&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;with &lt;/span&gt;get() = x.elements.Count = 0&lt;br /&gt;
    &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Push element =&lt;br /&gt;
    x.elements.AddFirst(element:'t)&lt;br /&gt;
    &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Top&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;with &lt;/span&gt;get() =&lt;br /&gt;
      &lt;span style="color: rgb(255, 128, 0);"&gt;if &lt;/span&gt;x.elements.Count = 0 &lt;span style="color: rgb(255, 128, 0);"&gt;then&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
        raise (InvalidOperationException(&lt;span style="color: rgb(0, 255, 0);"&gt;"cannot top an empty stack"&lt;/span&gt;))&lt;br /&gt;
      x.elements.First.Value&lt;br /&gt;
      &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Pop = &lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;top = x.Top&lt;br /&gt;
    x.elements.RemoveFirst()&lt;br /&gt;
    top&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
[&amp;lt;Fact&amp;gt;]   &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;NoElementsShouldBeEmpty () =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;stack = new Stack&amp;lt;string&amp;gt;()&lt;br /&gt;
  Assert.True(stack.IsEmpty)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;[&amp;lt;Fact&amp;gt;]&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;PushAnElementShouldNotBeEmpty() =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;stack = new Stack&amp;lt;string&amp;gt;()&lt;br /&gt;
  stack.Push(&lt;span style="color: rgb(0, 255, 0);"&gt;"first element"&lt;/span&gt;)&lt;br /&gt;
  Assert.False(stack.IsEmpty)&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
And now, open the xunit.gui.exe and select your assembly you want to run.  I chose my fsharpsamples.dll that I've been working with on my F# samples.  Now, let's give these two tests a run to see how they do.&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://weblogs.asp.net/blogs/podwysocki/xunitnet_guirunner_greenlight.png" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, not much information is given to me other than the number of passed tests, the time taken and my assembly under test.  Not much information, but enough to get started.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, a bit of progress has been made on xUnit.net and here's hoping the version 1.0 full release is coming soon.  As I look at it more and more, I'm definitely starting to like it.  I haven't had to create as many extensions as I would have to do with MSTest such as Assert.Throws&amp;lt;T&amp;gt; and so on.  So, I encourage you to go ahead and once again, give it a look and give feedback to the team.  Until next time... &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121048"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121048" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121048.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx</guid>
            <pubDate>Fri, 04 Apr 2008 22:34:24 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121048.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/04/121048.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121048.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121048.aspx</trackback:ping>
        </item>
        <item>
            <title>Adventures in F# - F# 101 Part 7 (Creating Types)</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/03/121002.aspx</link>
            <description>Time for another adventure in F#, covering some of the basics of functional programming and F# in particular.  This is intended at looking at the foundations of F# as well as how it relates to .NET and IL on the back end.  I realize I need to spread more of the F# goodness around, so I'm hoping that I can work to bring it at least to the &lt;a href="http://www.lisperati.com/fringedc.html"&gt;FringeDC user group&lt;/a&gt;.  Their main meetings are every three months, so hopefully I'll get some time in to do that.   Once I get that set up, I'll be sure to let everyone know.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Where We Are&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Before we begin today, let's catch up to where we are today:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-1.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-1.aspx"&gt;Part 1 - Basic functional programming&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-2.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-2.aspx"&gt;Part 2 - Currying and Tuples&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-3.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-3.aspx"&gt;Part 3 - Scope, Recursion and Anonymous Functions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-4.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-4.aspx"&gt;Part 4 - History of F#, Operators and Lists&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a mce_href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-5-pattern-matching.aspx" href="http://weblogs.asp.net/podwysocki/archive/2008/03/17/adventures-in-f-f-101-part-5-pattern-matching.aspx"&gt;Part 5 - Pattern Matching&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/03/21/adventures-in-f-f-101-part-6-lazy-evaluation.aspx"&gt;Part 6 - Lazy Evaluation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
Today's topic will be covering creating custom types in F#.  There is a lot to cover, so let's get started.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Types of Types?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you're familiar with OCaml, the type system in F# should look rather familiar.  For a brief introduction to how OCaml works, check out Dr. Jon Harrop's OCaml for Scientists introduction &lt;a href="http://www.ffconsultancy.com/products/ocaml_journal/free/introduction.html"&gt;here&lt;/a&gt;.  We have several categories of types in base F#.  The first category is the tuples or records, and the second type are unions.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Tuples&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The most simple type in F# is a &lt;a href="http://en.wikipedia.org/wiki/Tuple"&gt;tuple&lt;/a&gt;.  A tuple is a compound type composed of a fixed sequence of other types.  Each value is separated by a comma and can be referred to by a single identifier.  The values from the tuple can be retrieved by putting commas on the other side of the equals.  Below is a quick sample of this concept:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;coin = &lt;span style="color: rgb(0, 255, 0);"&gt;"heads"&lt;/span&gt;, &lt;span style="color: rgb(0, 255, 0);"&gt;"tails"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;c1, _ = coin&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;_, c2 = coin&lt;br /&gt;
&lt;br /&gt;
print_string c1&lt;br /&gt;
print_string c2&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
What I did to look up the values was to use the _ to indicate I wasn't interested in the other values.  Hence my c1 got me heads and c2 got me tails.  As always, I'm always curious how it compiles down to C# and how it gets represented in IL, so let's take a look at the coin type that I created.&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://weblogs.asp.net/blogs/podwysocki/fsharp_tuple_coin.png" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
Nothing really fancy, as we created a tuple of type string and string which held our "heads" and "tails" value.  Like I said before, tuples are the simplest type in F#.  In fact, as you saw above I didn't even need to use the type keyword to specify I was creating a new type.  However, I can choose to use the type keyword so that I can create a type alias which can be very useful for method signature constraint.  Below is a simple sample of doing that.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Point3D = double * double * double&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;pointPrinter(p : Point3D) =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x, y, z = p &lt;span style="color: rgb(255, 128, 0);"&gt;in&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;/span&gt;&lt;br /&gt;
  &lt;span style="color: rgb(0, 255, 0);"&gt;"x:"&lt;/span&gt; + x.ToString() + &lt;span style="color: rgb(0, 255, 0);"&gt;" y:"&lt;/span&gt; + y.ToString() + &lt;span style="color: rgb(0, 255, 0);"&gt;" z:" &lt;/span&gt;+ z.ToString() &lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;pointString = pointPrinter(2.3, 5.3, 9.8)&lt;br /&gt;
print_string pointString&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
As you can see from above, I created a 3D point which contains an x, y and z axis.  Then I constrained the pointPrinter function to take that as a constraint so that I can format it properly.  Then of course I do all the great things I normally would do by printing it out to the console.  But, if you want to take a look at what this pointPrinter function does behind the scenes, wonder no longer.&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://weblogs.asp.net/blogs/podwysocki/fsharp_tuple_phonenumber.png" alt="" /&gt;&lt;img alt="" src="http://weblogs.asp.net/blogs/podwysocki/fsharp_tuple_point.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
Quite an interesting mouthful, I must admit, but that's what you get when you deal with immutable types such as strings.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Records&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Record types are also a user defined data structure within F#.  These are similar to tuples, but differ because each piece of data (field) inside a record must be named as well as the keyword type must be used.  Think of this much as a .NET class with simple properties.  What's interesting is that these fields that it creates for us aren't forced to be unique.  Let's go ahead and show a simple example of a Person record that we may want to create.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;System&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Person = &lt;br /&gt;
  {&lt;br /&gt;
    FirstName : string;&lt;br /&gt;
    MiddleName : string;&lt;br /&gt;
    LastName : string;&lt;br /&gt;
    DateOfBirth : DateTime;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;person1 = { FirstName=&lt;span style="color: rgb(0, 255, 0);"&gt;"Robert"&lt;/span&gt;; MiddleName=&lt;span style="color: rgb(0, 255, 0);"&gt;"William"&lt;/span&gt;; LastName=&lt;span style="color: rgb(0, 255, 0);"&gt;"Jones"&lt;/span&gt;; DateOfBirth = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;DateTime(1960, 12, 12); }&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;person2 = &lt;br /&gt;
  { &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Person&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;with&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;FirstName = &lt;span style="color: rgb(0, 255, 0);"&gt;"William"&lt;/span&gt;&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;and&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;MiddleName = &lt;span style="color: rgb(0, 255, 0);"&gt;"Franklin"&lt;/span&gt;&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;and&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;LastName = &lt;span style="color: rgb(0, 255, 0);"&gt;"Smith" &lt;/span&gt;&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;and&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;DateOfBirth = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;DateTime(1970, 1, 23) &lt;br /&gt;
  }&lt;/p&gt;
&lt;br /&gt;
&lt;p style="margin: 0px;"&gt;print_string person1.FirstName&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;print_string person2.FirstName&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
What I have done is created a Person record with a FirstName, MiddleName, LastName and a DateOfBirth field.  Pretty simple.  Now, we have two ways of creating an instance of this type.  When I created person1, I just simply just set each field separated by a semicolon.  On the other hand, since I'm not explicitly naming a type, there could be conflicts due to multiple types containing the same fields.  Should I want to be more explicit, I can specify it using the longhand way with using the new operator and setting each property with the with keyword and followed by an and on each subsequent line to fill in all the other values.  Such a conflict would look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;point2D = { X:double; Y:double }&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;coordinate2D = { X:double; Y:double }&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;myPoint = { X = 2.5; Y = 3.2; }&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
What the above sample will default to is that myPoint will be of type coordinate2D.  Hover over and let Intellisense do its magic.  Interesting, huh?  That's why we should be explicit about our data structures should something like this arise.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Discriminated Unions&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The next category of F# type that will be discussed is the &lt;a href="http://en.wikipedia.org/wiki/Discriminated_union"&gt;discriminated union&lt;/a&gt;.  This type is a data structure that can bring together values but have different meanings or structures.  Only one of these types can be used at once, however.  Think of it more of a type which is almost "case" like.  Each piece of that is called a discriminator.  A quick example of this would be something like distance where it could be measured in miles or kilometers, but not both at the same time.  The structure of this data is the same, but have different meanings to the program.&lt;br /&gt;
&lt;br /&gt;
Let's look at some quick examples of this:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Distance = &lt;br /&gt;
  | Kilometer &lt;span style="color: rgb(255, 128, 0);"&gt;of&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt; double&lt;br /&gt;
  | Mile &lt;span style="color: rgb(255, 128, 0);"&gt;of&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt; double&lt;br /&gt;
  &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;distance1 = Mile 26.2&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;distance2 = Kilometer 10.0&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;convertDistanceToMile x =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;match&lt;/span&gt; x &lt;span style="color: rgb(255, 128, 0);"&gt;with&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt;&lt;br /&gt;
  | Mile x -&amp;gt; x&lt;br /&gt;
  | Kilometer x -&amp;gt; x * 1.609344&lt;br /&gt;
  &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;convertDistanceToKilometer x =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;match&lt;/span&gt; x &lt;span style="color: rgb(255, 128, 0);"&gt;with&lt;/span&gt;&lt;br /&gt;
  | Mile x -&amp;gt; x * 0.621371192&lt;br /&gt;
  | Kilometer x -&amp;gt; x&lt;br /&gt;
  &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;convertedDistance1 = convertDistanceToKilometer distance1&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;convertedDistance2 = convertDistanceToMile distance2&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
As you can see from above, I created a Distance discriminated union that defines both miles and kilometers.  Both discriminators are of type double.  So, I wrote a function to convert from one to the other.  It's just a simple pattern matching statement.  If you've read my previous posts, you should be caught up to date with this.&lt;br /&gt;
&lt;br /&gt;
I could also parameterize this data differently, meaning that each discriminator can hold a different value.  &lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Carrier = string&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Route = int&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Make = string&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Model = string&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Year = int&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;ModeOfTransport =&lt;br /&gt;
  | Airplane &lt;span style="color: rgb(255, 128, 0);"&gt;of&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt; Carrier * Route&lt;br /&gt;
  | Bus &lt;span style="color: rgb(255, 128, 0);"&gt;of&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Carrier * Route&lt;br /&gt;
  | Car &lt;span style="color: rgb(255, 128, 0);"&gt;of&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Make * Model&lt;br /&gt;
  &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;mode1 = Car(&lt;span style="color: rgb(0, 255, 0);"&gt;"Audi"&lt;/span&gt;, &lt;span style="color: rgb(0, 255, 0);"&gt;"A4"&lt;/span&gt;)&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;mode2 = Airplane(&lt;span style="color: rgb(0, 255, 0);"&gt;"United"&lt;/span&gt;, 222)&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
As you can see, I type aliased a few things such as Carrier, Route, Make, Model and so on.  After that, I defined my ModeOfTransport to be by bus, car or airplane.  A pretty simple example.  &lt;br /&gt;
&lt;br /&gt;
I can also specify the type of arguments later, by specifying them as generics.  One of them you may have already run across is the option type.  To declare one, just use the &amp;lt;'a&amp;gt; or whichever letter you so choose.  Let do a recursive example of a tree.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Tree&amp;lt;'t&amp;gt; =&lt;br /&gt;
  | TreeNode &lt;span style="color: rgb(255, 128, 0);"&gt;of&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt; 't Tree * 't Tree&lt;br /&gt;
  | TreeValue &lt;span style="color: rgb(255, 128, 0);"&gt;of&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt; 't&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;tree =&lt;br /&gt;
  TreeNode(&lt;br /&gt;
    TreeNode(TreeValue 0, TreeValue 1),&lt;br /&gt;
    TreeNode(TreeValue 2, TreeValue 3))&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
From the above statement, I created a tree of nodes quite easily using this union type.  These types can get complicated quickly, however when you get into language oriented programming, so we're just dipping our toes in at the moment.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;.NET Types?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Yes, you can also create .NET types as well just as easily, although with a few major details.  For example, the mutable types which is not by default in F#.  I'll cover that in the next post.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt; Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, there are a few basic types in F#.  They are mostly for holding analytical data, traversing them and so on.  These are interesting and serve as the basis of what you will do in F# when you need to store and analyze data, especially custom types.  In the next installment, I hope to cover some .NET specific topics such as creating .NET types.  Until next time... &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/03/121002.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/03/121002.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121002"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121002" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/121002.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/03/121002.aspx</guid>
            <pubDate>Thu, 03 Apr 2008 23:37:44 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/121002.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/03/121002.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/121002.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/121002.aspx</trackback:ping>
        </item>
        <item>
            <title>Covering NUnit 2.4.7</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx</link>
            <description>It's interesting that a flurry of releases of testing frameworks have been released lately with &lt;a href="http://www.gallio.org/"&gt;Gallio&lt;/a&gt;, &lt;a href="http://codeplex.com/xunit"&gt;xUnit.net&lt;/a&gt; and of course &lt;a href="http://nunit.com/index.php"&gt;NUnit&lt;/a&gt;.&lt;a href="http://blogs.nunit.com/"&gt;  Charlie Poole&lt;/a&gt; recently announced on a lot of the discussion boards I belong to recently that &lt;a href="http://nunit.com/index.php?p=download"&gt;NUnit 2.4.7&lt;/a&gt; was recently released.  You can read all about what's been added &lt;a href="http://nunit.com/index.php?p=releaseNotes&amp;amp;r=2.4.7"&gt;here &lt;/a&gt;with the release notes.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;What's New and Interesting?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
What's interesting about this release?  Well, NUnit no longer depends on log4net, thus getting rid of some dependency issues with regards to the applications under test.  What's also interesting is that addition of the RowTest extension to allow  multiple sets of arguments to be given to a test.  This is the first one that's ever been incorporated into the core of NUnit.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Static Tests in NUnit?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As &lt;a href="http://weblogs.asp.net/astopford/"&gt;Andy Stopford&lt;/a&gt; noted in my blog yesterday regarding xUnit.net, &lt;a href="http://sourceforge.net/mailarchive/forum.php?thread_name=004401c887ad%249e816030%246501a8c0%40ferrari&amp;amp;forum_name=nunit-developer"&gt;Charlie recently checked in code&lt;/a&gt; to allow static methods for static methods to be tests as well as Setup and TearDown to be static as well.  Jim Newkirk, the man behind NUnit and co-creator of xUnit.net, favors that approach of allowing statics.  To me, I don't care as much with regards to Startup and TearDown with statics as most of my statics for testing F# is side effect free programming.  As it should be with functional programming.  Anyhow, what I'd like to see in NUnit is the support for something that I can do in xUnit.net:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
#R &lt;span style="color: rgb(0, 255, 0);"&gt;@"D:\Program Files\NUnit 2.4.7\bin\nunit.core.dll"&lt;/span&gt;&lt;br /&gt;
#R &lt;span style="color: rgb(0, 255, 0);"&gt;@"D:\Program Files\NUnit 2.4.7\bin\nunit.framework.dll"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;NUnit.Framework&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;rec&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;fib n =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;match&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;n &lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;with&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
  | 0 | 1 &lt;span style="color: rgb(255, 128, 0);"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt; 0&lt;br /&gt;
  | n &lt;span style="color: rgb(255, 128, 0);"&gt;-&amp;gt;&lt;/span&gt; fib(n-2) + fib(n-1)&lt;br /&gt;
  | n &lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;when&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt; n &amp;lt; 0 &lt;span style="color: rgb(255, 128, 0);"&gt;-&amp;gt;&lt;/span&gt; failwith &lt;span style="color: rgb(0, 255, 0);"&gt;"Cannot be less than zero"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
[&amp;lt;TestFixture&amp;gt;]&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt;FibOfOneShouldReturnZero() =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;/span&gt;fibResult = fib(1)&lt;br /&gt;
  Assert.AreEqual(fibResult, 0)&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
If I saw something like this, I'd be a happy man.  But until then, I can dream...&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Go ahead and pick up your copy today of NUnit.  It's been the old standby for many of my projects throughout my career and served me quite well.  Next time I'll cover Gallio a little bit as I have neglected it, but it's a huge release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120934"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120934" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/Podwysocki/aggbug/120934.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Matthew Podwysocki</dc:creator>
            <guid>http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx</guid>
            <pubDate>Tue, 01 Apr 2008 21:34:37 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/Podwysocki/comments/120934.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/Podwysocki/archive/2008/04/01/120934.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/Podwysocki/comments/commentRss/120934.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/Podwysocki/services/trackbacks/120934.aspx</trackback:ping>
        </item>
        <item>
            <title>XUnit.net RC2 Released</title>
            <link>http://geekswithblogs.net/Podwysocki/archive/2008/03/31/120904.aspx</link>
            <description>&lt;span style="font-weight: bold;"&gt;UPDATE: More posts on the subject&lt;br /&gt;
&lt;/span&gt;
&lt;ul&gt;
    &lt;li style="font-weight: bold;"&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/04/10/xunit-net-rc3-just-released.aspx"&gt;xUnit.net RC3 Just Released&lt;/a&gt;&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://weblogs.asp.net/podwysocki/archive/2008/04/04/relooking-at-xunit-net-rc2.aspx" style="font-weight: bold;"&gt;Relooking at xUnit.net RC2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;
UPDATE: xUnit.NET RC2 New Drop includes ASP.NET MVC support and better GUI runner.  Details &lt;a href="http://bradwilson.typepad.com/blog/2008/04/xunitnet-rc2--1.html"&gt;here&lt;/a&gt;.&lt;br /&gt;
UPDATE: Added Static Methods mention and F# - Thanks to &lt;a href="http://devhawk.net"&gt;DevHawk&lt;/a&gt;!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I've been a big fan of such testing frameworks as &lt;a href="http://www.nunit.org/"&gt;NUnit&lt;/a&gt; and &lt;a href="http://www.mbunit.com/"&gt;MbUnit&lt;/a&gt;, but recently I've found myself getting pulled more towards &lt;a href="http://codeplex.com/xunit"&gt;xUnit.net&lt;/a&gt; at least to play around with for any of my code samples that I write for this blog and on my own time.  I'm not really a fan of MSTest and many I think would agree about its deficiencies.  I won't go as far as say &lt;a href="http://jayflowers.com/joomla/"&gt;Jay Flowers&lt;/a&gt; and wear the shirt though...&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Another Release?&lt;/span&gt;&lt;br style="font-weight: bold;" /&gt;
&lt;br /&gt;
Recently, &lt;a href="http://bradwilson.typepad.com/"&gt;Brad Wilson&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/jamesnewkirk/default.aspx"&gt;Jim Newkirk&lt;/a&gt; recently announced the release of &lt;a href="http://codeplex.com/xunit"&gt;xUnit.net RC2&lt;/a&gt; on CodePlex.  I'd encourage you download the latest bits &lt;a href="http://www.codeplex.com/xunit/Release/ProjectReleases.aspx?ReleaseId=9681"&gt;here&lt;/a&gt;.  For those wondering what changes happened between RC1 and RC2, Brad has a good writeup on his blog &lt;a href="http://bradwilson.typepad.com/blog/2008/03/xunitnet-10-rc2.html"&gt;here&lt;/a&gt;.  What's interesting about this is the removal of the Assert class methods which take a user defined message should it fail.  I was never really a fan of those in the first place though.  &lt;br /&gt;
&lt;br /&gt;
Another interesting added features was the IUserFixture&amp;lt;T&amp;gt; which allows you to have a startup and teardown for your fixtures in a separate class and therefore reusable, unlike the current way of using no parameter constructors as your startup and the IDisposable.Dispose for your teardown.  See the tests in the FixtureExample for details.  But here's a snipped version of that code:&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;\red255\green255\blue0;\red43\green145\blue175;\red0\green255\blue0;\red163\green21\blue21;}??\fs16 \cf1\cb2\highlight2     \cf3 public\cf1  \cf3 class\cf1  \cf4 DatabaseFixture\cf1  : \cf5 IDisposable\par ??\cf1     \{\par ??        \cf4 SqlConnection\cf1  connection;\par ??        \cf3 int\cf1  fooUserID;\par ??\par ??        \cf3 public\cf1  DatabaseFixture()\par ??        \{\par ??            \cf3 string\cf1  connectionString = \cf4 ConfigurationManager\cf1 .ConnectionStrings[\cf6 "DatabaseFixture"\cf1 ].ConnectionString;\par ??            connection = \cf3 new\cf1  \cf4 SqlConnection\cf1 (connectionString);\par ??            connection.Open();\par ??\par ??            \cf3 string\cf1  sql = \cf7 @"INSERT INTO Users VALUES ('foo', 'bar'); SELECT SCOPE_IDENTITY();"\cf1 ;\par ??\par ??            \cf3 using\cf1  (\cf4 SqlCommand\cf1  cmd = \cf3 new\cf1  \cf4 SqlCommand\cf1 (sql, connection))\par ??                fooUserID = \cf4 Convert\cf1 .ToInt32(cmd.ExecuteScalar());\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf4 SqlConnection\cf1  Connection\par ??        \{\par ??            \cf3 get\cf1  \{ \cf3 return\cf1  connection; \}\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf3 int\cf1  FooUserID\par ??        \{\par ??            \cf3 get\cf1  \{ \cf3 return\cf1  fooUserID; \}\par ??        \}\par ??\par ??        \cf3 public\cf1  \cf3 void\cf1  Dispose()\par ??        \{\par ??            \cf3 string\cf1  sql = \cf7 @"DELETE FROM Users WHERE ID = @id;"\cf1 ;\par ??\par ??            \cf3 using\cf1  (\cf4 SqlCommand\cf1  cmd = \cf3 new\cf1  \cf4 SqlCommand\cf1 (sql, connection))\par ??            \{\par ??                cmd.Parameters.AddWithValue(\cf6 "@id"\cf1 , fooUserID);\par ??                cmd.ExecuteNonQuery();\par ??            \}\par ??\par ??            connection.Close();\par ??        \}\par ??    \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;DatabaseFixture&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IDisposable&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: yellow;"&gt;SqlConnection&lt;/span&gt; connection;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;int&lt;/span&gt; fooUserID;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; DatabaseFixture()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; connectionString = &lt;span style="color: yellow;"&gt;ConfigurationManager&lt;/span&gt;.ConnectionStrings[&lt;span style="color: lime;"&gt;"DatabaseFixture"&lt;/span&gt;].ConnectionString;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            connection = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;SqlConnection&lt;/span&gt;(connectionString);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            connection.Open();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; sql = &lt;span style="color: rgb(163, 21, 21);"&gt;@"INSERT INTO Users VALUES ('foo', 'bar'); SELECT SCOPE_IDENTITY();"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; (&lt;span style="color: yellow;"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;SqlCommand&lt;/span&gt;(sql, connection))&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                fooUserID = &lt;span style="color: yellow;"&gt;Convert&lt;/span&gt;.ToInt32(cmd.ExecuteScalar());&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: yellow;"&gt;SqlConnection&lt;/span&gt; Connection&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;get&lt;/span&gt; { &lt;span style="color: rgb(255, 128, 0);"&gt;return&lt;/span&gt; connection; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;int&lt;/span&gt; FooUserID&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;get&lt;/span&gt; { &lt;span style="color: rgb(255, 128, 0);"&gt;return&lt;/span&gt; fooUserID; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; Dispose()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; sql = &lt;span style="color: rgb(163, 21, 21);"&gt;@"DELETE FROM Users WHERE ID = @id;"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; (&lt;span style="color: yellow;"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;SqlCommand&lt;/span&gt;(sql, connection))&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                cmd.Parameters.AddWithValue(&lt;span style="color: lime;"&gt;"@id"&lt;/span&gt;, fooUserID);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                cmd.ExecuteNonQuery();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            connection.Close();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
What the above code allows us to do is to define a class that holds the data from the initialization of the first test, to the cleanup after the last test.  Our state is therefore maintained in a reusable manner.  As you will note, the startup logic resides in the default no parameter constructor and all teardown logic is in the IDisposable.Dispose method.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;\red255\green255\blue0;\red43\green145\blue175;\red0\green255\blue0;}??\fs16 \cf1\cb2\highlight2     \cf3 public\cf1  \cf3 class\cf1  \cf4 FixtureTests\cf1  : \cf5 IUseFixture\cf1 &amp;lt;\cf4 DatabaseFixture\cf1 &amp;gt;\par ??    \{\par ??        \cf4 DatabaseFixture\cf1  database;\par ??\par ??        \cf3 public\cf1  \cf3 void\cf1  SetFixture(\cf4 DatabaseFixture\cf1  data)\par ??        \{\par ??            database = data;\par ??        \}\par ??\par ??        [\cf4 Fact\cf1 ]\par ??        \cf3 public\cf1  \cf3 void\cf1  ConnectionIsEstablished()\par ??        \{\par ??            \cf4 Assert\cf1 .NotNull(database.Connection);\par ??        \}\par ??\par ??        [\cf4 Fact\cf1 ]\par ??        \cf3 public\cf1  \cf3 void\cf1  FooUserWasInserted()\par ??        \{\par ??            \cf3 string\cf1  sql = \cf6 "SELECT COUNT(*) FROM Users WHERE ID = @id;"\cf1 ;\par ??\par ??            \cf3 using\cf1  (\cf4 SqlCommand\cf1  cmd = \cf3 new\cf1  \cf4 SqlCommand\cf1 (sql, database.Connection))\par ??            \{\par ??                cmd.Parameters.AddWithValue(\cf6 "@id"\cf1 , database.FooUserID);\par ??\par ??                \cf3 int\cf1  rowCount = \cf4 Convert\cf1 .ToInt32(cmd.ExecuteScalar());\par ??\par ??                \cf4 Assert\cf1 .Equal(1, rowCount);\par ??            \}\par ??        \}\par ??    \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt; &lt;span style="color: yellow;"&gt;FixtureTests&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IUseFixture&lt;/span&gt;&amp;lt;&lt;span style="color: yellow;"&gt;DatabaseFixture&lt;/span&gt;&amp;gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: yellow;"&gt;DatabaseFixture&lt;/span&gt; database;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; SetFixture(&lt;span style="color: yellow;"&gt;DatabaseFixture&lt;/span&gt; data)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            database = data;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;   &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        [&lt;span style="color: yellow;"&gt;Fact&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; FooUserWasInserted()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt; sql = &lt;span style="color: lime;"&gt;"SELECT COUNT(*) FROM Users WHERE ID = @id;"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            &lt;span style="color: rgb(255, 128, 0);"&gt;using&lt;/span&gt; (&lt;span style="color: yellow;"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;SqlCommand&lt;/span&gt;(sql, database.Connection))&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                cmd.Parameters.AddWithValue(&lt;span style="color: lime;"&gt;"@id"&lt;/span&gt;, database.FooUserID);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: rgb(255, 128, 0);"&gt;int&lt;/span&gt; rowCount = &lt;span style="color: yellow;"&gt;Convert&lt;/span&gt;.ToInt32(cmd.ExecuteScalar());&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;                &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Equal(1, rowCount);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;            }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
Then we can go ahead with our tests, while using the SqlConnection as defined on our DatabaseFixture.  After we're done with our test, it goes ahead and calls Dispose on the fixture.  I tend to like this approach and it's definitely growing on me.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Why xUnit.net?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
For those new to xUnit.net, there are some decent links to help you along.  Some of the more interesting ones can be found here:&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.codeplex.com/xunit/Wiki/View.aspx?title=Comparisons&amp;amp;referringTitle=Home"&gt;Comparison to MbUnit, NUnit and MSTest&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.codeplex.com/xunit/Wiki/View.aspx?title=HowToUseResharper&amp;amp;referringTitle=Home"&gt;Running Resharper with xUnit.net&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://blog.benhall.me.uk/2008/01/introduction-to-xunit.html"&gt;An introduction to xUnit.net&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://blog.benhall.me.uk/2008/01/introduction-to-xunitnet-extensions.html"&gt;An introduction to xUnit.net extensions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://blog.benhall.me.uk/2008/01/creating-your-own-xunit-extension.html"&gt;Create your own xUnit.net extension&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
But, why am I interested in it?  Well, let's just say that I think it tackles things in a slightly different manner.  I think one of the key pieces that I really like is the Assert.Throws instead of the clumsy ExpectedExceptionAttribute which you must clutter your tests with on the top.  I would rather assert that such a thing happened programmatically, so that I may analyze the exception.  I can also specify which line I expect during my test will throw the exception, instead of taking on blind faith that my test threw an exception.  It may be of the right type, but that may not have been the one you wanted, thus giving a false sense of security.&lt;br /&gt;
&lt;br /&gt;
To use this, just simply use the Assert.Throws&amp;lt;TException&amp;gt;(Assert.ThrowsDelegate) which I've found to be very helpful.  Let's look at a quick test of that being used.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green255\blue0;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2     [\cf3 Fact\cf1 ]\par ??    \cf4 public\cf1  \cf4 void\cf1  PopEmptyStack()\par ??    \{\par ??        \cf3 Stack\cf1 &amp;lt;\cf4 string\cf1 &amp;gt; stack = \cf4 new\cf1  \cf3 Stack\cf1 &amp;lt;\cf4 string\cf1 &amp;gt;();\par ??        \cf3 Assert\cf1 .Throws&amp;lt;\cf3 InvalidOperationException\cf1 &amp;gt;(() =&amp;gt; stack.Pop());\par ??    \}}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;    [&lt;span style="color: yellow;"&gt;Fact&lt;/span&gt;]&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    &lt;span style="color: rgb(255, 128, 0);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(255, 128, 0);"&gt;void&lt;/span&gt; PopEmptyStack()&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: yellow;"&gt;Stack&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt;&amp;gt; stack = &lt;span style="color: rgb(255, 128, 0);"&gt;new&lt;/span&gt; &lt;span style="color: yellow;"&gt;Stack&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(255, 128, 0);"&gt;string&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;        &lt;span style="color: yellow;"&gt;Assert&lt;/span&gt;.Throws&amp;lt;&lt;span style="color: yellow;"&gt;InvalidOperationException&lt;/span&gt;&amp;gt;(() =&amp;gt; stack.Pop());&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;    }&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
As you can see, we're pretty explicit about what line will throw the exception, and that's really the key to this scenario.  There are a good number of samples provided on the releases page that you should check out.  As always with most products that I talk about, I highly recommend reading the tests to really fully understand what's going on underneath the covers.  Not only does it help you understand the intent of the program, but you can learn about good coding techniques, design patterns, testing patterns and so on.&lt;br /&gt;
&lt;br /&gt;
Another point that xUnit.net separates itself from the pack is the ability to decorate static methods as facts.  This frees you from having to create an instance of your test class in order to call them.  Harry Pierson, aka DevHawk, demonstrates its use with regards to F# and testing the parse buffer &lt;a href="http://devhawk.net/2007/12/12/Practical+F+Parsing+Unit+Testing.aspx"&gt;here&lt;/a&gt;.  It definitely opened my eyes and a few more avenues as I pursue more F# related work items in the future.  Here's just a quick and dirty sample of showing how you can use xUnit.net with F# quite easily, just as Harry's post did.&lt;br /&gt;
&lt;br /&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Monaco;}}{\colortbl;??\red255\green255\blue255;\red40\green40\blue40;\red255\green128\blue0;}??\fs16 \cf1\cb2\highlight2 #light\par ??\par ??\cf3 let\cf1  \cf3 rec\cf1  fib n = \par ??  \cf3 match\cf1  n \cf3 with\par ??\cf1   | 0 \cf3 -&amp;gt;\cf1  1\par ??  | 1 \cf3 -&amp;gt;\cf1  1\par ??  | x \cf3 -&amp;gt;\cf1  fib(n - 2) + fib(n - 1)\par ??  \par ??print_any (fib (-1))}
--&gt;
&lt;div style="background: rgb(40, 40, 40) none repeat scroll 0% 50%; font-family: Monaco; font-size: 8pt; color: white; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;#light&lt;br /&gt;
&lt;br /&gt;
#R @&lt;span style="color: rgb(0, 255, 0);"&gt;"E:\Tools\xunit-build-1223-samples\Samples\xunit\xunit.dll" &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;System&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;System.Collections.Generic&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;open&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;Xunit&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;type &lt;/span&gt;Stack&amp;lt;'t&amp;gt; = &lt;span style="color: rgb(255, 128, 0);"&gt;class&lt;/span&gt;&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;val&lt;/span&gt; elements : LinkedList&amp;lt;'t&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  new() = { elements = &lt;span style="color: rgb(255, 128, 0);"&gt;new &lt;/span&gt;LinkedList&amp;lt;'t&amp;gt;() }&lt;br /&gt;
  &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.IsEmpty&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;with &lt;/span&gt;get() = x.elements.Count = 0&lt;br /&gt;
    &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Push element =&lt;br /&gt;
    x.elements.AddFirst(element:'t)&lt;br /&gt;
    &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Top&lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;with &lt;/span&gt;get() =&lt;br /&gt;
      &lt;span style="color: rgb(255, 128, 0);"&gt;if &lt;/span&gt;x.elements.Count = 0 &lt;span style="color: rgb(255, 128, 0);"&gt;then&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
        raise (InvalidOperationException(&lt;span style="color: rgb(0, 255, 0);"&gt;"cannot top an empty stack"&lt;/span&gt;))&lt;br /&gt;
      x.elements.First.Value&lt;br /&gt;
      &lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;member&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;x.Pop = &lt;br /&gt;
    &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;top = x.Top&lt;br /&gt;
    x.elements.RemoveFirst()&lt;br /&gt;
    top&lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
[&amp;lt;Fact&amp;gt;]   &lt;br /&gt;
&lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;NoElementsShouldBeEmpty () =&lt;br /&gt;
  &lt;span style="color: rgb(255, 128, 0);"&gt;let&lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt; &lt;span style="color: rgb(255, 255, 255);"&gt;&lt;/span&gt;&lt;/span&gt;stack = new Stack&amp;lt;string&amp;gt;()&lt;br /&gt;
  Assert.True(stack.IsEmpty)&lt;br /&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br /&gt;
If you notice, the FactAttribute is placed on a static method called NoElementsShouldBeEmpty and sure enough it works like a champ through xUnit.net.  I like this approach instead of the pomp and circumstance required for creating classes as shown above with my Stack class.  Note the use of the empty parans which forces it to be a void method with no values passed either.  But if you run it through the xunit.console sure enough it succeeds like a champ.&lt;br /&gt;
&lt;br /&gt;
What are we missing though?  Well, I'm in favor of having a standalone GUI Test Runner much like NUnit and MbUnit have.  In fact, Brad has started this and you can get these features from the latest commits &lt;a href="http://www.codeplex.com/xunit/SourceControl/ListDownloadableCommits.aspx"&gt;here&lt;/a&gt;.  Mind you I haven't gotten it to work just right yet, but it's a work in progress.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
There is a lot to like about xUnit.net and takes a lot of lessons learned from the use of NUnit, MbUnit and others and I think they're doing a good job incorporating issues.  This project isn't as active as MbUnit and NUnit, but it's definitely one to keep an eye on.  Recent releases of NUnit and Gallio Automation Platform will probably be also covered in the short while as well as they have a lot to offer.  Until next time... &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=