<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4585464309698708237</id><updated>2011-08-15T15:37:54.408-04:00</updated><category term='ruby'/><category term='rest'/><category term='wcf'/><category term='C#'/><category term='Mocks'/><category term='LINQ'/><category term='functionalprogramming'/><category term='datastructs'/><category term='f#'/><category term='ironruby'/><category term='gisserver'/><category term='ArcObjects'/><category term='.net'/><category term='testing'/><category term='msmvc'/><category term='Unit Testing'/><category term='fsunit'/><title type='text'>Consumed by Code</title><subtitle type='html'>Code is a predator and I'm its prey.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-8488426651300513126</id><published>2009-12-14T22:29:00.005-05:00</published><updated>2009-12-15T11:01:50.628-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fsunit'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>Towards FsUnit 1.0</title><content type='html'>&lt;p&gt;I have been giving a lot of consideration recently to an &lt;a href="http://code.google.com/p/fsunit/"&gt;FsUnit&lt;/a&gt; 1.0 release and the direction of the project. The 0.6 release was meant to steer the project more in the direction of Behavioral-Driven Development but there is already a much better project out there for F# and BDD, &lt;a href="http://code.google.com/p/natural/"&gt;NaturalSpec&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;FsUnit 1.0 will instead be geared for more classical unit-testing and it now has two explicit goals: 1) to make unit-testing with F# more functional in nature and 2) to leverage existing unit-testing frameworks while at the same time exploring new possibilities offered by the F# language.&lt;/p&gt;  &lt;p&gt;The target audience for this project is the F# developer (new and veteran alike) who wishes to use the same unit-testing framework that they’re already knowledgeable about: &lt;a href="http://www.nunit.org/index.php"&gt;NUnit&lt;/a&gt;, &lt;a href="http://www.mbunit.com/"&gt;MbUnit&lt;/a&gt;, &lt;a href="http://www.codeplex.com/xunit"&gt;xUnit&lt;/a&gt;, and MsTest. The new 0.9 release supports only NUnit but the others will be added soon.&lt;/p&gt;  &lt;p&gt;The core syntax is pretty much the same as it has always been:&lt;/p&gt;  &lt;pre class="f#" name="code"&gt;1 |&amp;gt; should equal 1&lt;br /&gt;&lt;br /&gt;1 |&amp;gt; should not (equal 2)&lt;br /&gt;&lt;br /&gt;[1] |&amp;gt; should contain 1&lt;br /&gt;&lt;br /&gt;true |&amp;gt; should be True&lt;/pre&gt;&lt;p&gt;But tests are once again contained within a test fixture and executed with a test runner. Here is the code for one of the project examples (UPDATE: removed non-standard use of self-identifier per reader's comments. Thanks, Alan!):&lt;/p&gt;&lt;pre class="f#" name="code"&gt;type LightBulb(state) =&lt;br /&gt;    member x.On = state&lt;br /&gt;    override x.ToString() =&lt;br /&gt;        match x.On with&lt;br /&gt;        | true  -&amp;gt; &amp;quot;On&amp;quot;&lt;br /&gt;        | false -&amp;gt; &amp;quot;Off&amp;quot;&lt;br /&gt;&lt;br /&gt;[&amp;lt;TestFixture&amp;gt;] &lt;br /&gt;type ``Given a LightBulb that has had its state set to true`` ()=&lt;br /&gt;    let lightBulb = new LightBulb(true)&lt;br /&gt;&lt;br /&gt;    [&amp;lt;Test&amp;gt;] member test.&lt;br /&gt;     ``when I ask whether it is On it answers true.`` ()=&lt;br /&gt;            lightBulb.On |&amp;gt; should be True&lt;br /&gt;&lt;br /&gt;    [&amp;lt;Test&amp;gt;] member test.&lt;br /&gt;     ``when I convert it to a string it becomes &amp;quot;On&amp;quot;.`` ()=&lt;br /&gt;            string lightBulb |&amp;gt; should equal &amp;quot;On&amp;quot;&lt;br /&gt;&lt;br /&gt;[&amp;lt;TestFixture&amp;gt;]&lt;br /&gt;type ``Given a LightBulb that has had its state set to false`` ()=&lt;br /&gt;    let lightBulb = new LightBulb(false)&lt;br /&gt;    &lt;br /&gt;    [&amp;lt;Test&amp;gt;] member test.&lt;br /&gt;     ``when I ask whether it is On it answers false.`` ()=&lt;br /&gt;            lightBulb.On |&amp;gt; should be False&lt;br /&gt;    &lt;br /&gt;    [&amp;lt;Test&amp;gt;] member test.&lt;br /&gt;     ``when I convert it to a string it becomes &amp;quot;Off&amp;quot;.`` ()=&lt;br /&gt;            string lightBulb |&amp;gt; should equal &amp;quot;Off&amp;quot;&lt;/pre&gt;&lt;p&gt;I’m curious as to what people think about the use of back-ticked method names. I, for one, find it very helpful to be able to write in plain prose instead of CamelCase’d or snake_case’d method names.&lt;/p&gt;&lt;p&gt;Stay tuned to this blog for more information as FsUnit reaches a 1.0 release.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-8488426651300513126?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/8488426651300513126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=8488426651300513126' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/8488426651300513126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/8488426651300513126'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2009/12/towards-fsunit-10.html' title='Towards FsUnit 1.0'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-8111810139473852845</id><published>2009-01-26T10:24:00.005-05:00</published><updated>2009-08-21T13:42:35.219-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><title type='text'>F# and WCF: Data Contracts</title><content type='html'>F# offers the WCF developer a number of options for defining data contracts. You can use standard classes, constructed classes, or record types to define your data contracts. The key thing to remember is that the &lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx"&gt;DataContractSerializer&lt;/a&gt; requires writeable properties. Let's take a look at a simple data contract defined in each of the three ways mentioned.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Standard Types&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="f#" name="code"&gt;[&amp;lt;DataContract&amp;gt;]&lt;br /&gt;type MyDataContract =&lt;br /&gt;    val mutable x : string&lt;br /&gt;    &lt;br /&gt;    new() = { x = "" }&lt;br /&gt;    &lt;br /&gt;    [&amp;lt;DataMember&amp;gt;]&lt;br /&gt;    member this.MyDataMember&lt;br /&gt;        with get() = this.x&lt;br /&gt;        and set v = this.x &lt;- v&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Constructed Types&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="f#" name="code"&gt;[&amp;lt;DataContract&amp;gt;]&lt;br /&gt;type MyDataContract() =&lt;br /&gt;    let mutable x = ""&lt;br /&gt;    &lt;br /&gt;    [&amp;lt;DataMember&amp;gt;]&lt;br /&gt;    member this.MyDataMember&lt;br /&gt;        with get() = x&lt;br /&gt;        and set v = x &lt;- v&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Record Types&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="f#" name="code"&gt;[&amp;lt;DataContract&amp;gt;]&lt;br /&gt;type MyDataContract =&lt;br /&gt;    { [&amp;lt;DataMember&amp;gt;] mutable MyDataMember : string }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Of the three, I prefer to use record types to define my data contracts. A record type mirrors the intention behind defining a data contract where we are simply declaring a set of data fields by name and type. If you've used the &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx"&gt;XmlSerializer&lt;/a&gt; much, you are probably aware of the default constructor requirement. This restricted the use of record types since they do not get a default constructor. Thankfully, that restriction does not apply with the DataContractSerializer. In addition, you can remove the DataContract and DataMember attributes from your type definition if you are using &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=ab99342f-5d1a-413d-8319-81da479ab0d7&amp;displaylang=en"&gt;.NET 3.5 Service Pack 1&lt;/a&gt; although I wouldn't recommend that you do this on a routine basis.&lt;br /&gt;&lt;br /&gt;You should use the DataContract attribute to control the namespace and name of your contract. Thus, a good data contract in F# would look something like this:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;[&amp;lt;DataContract(&lt;br /&gt;    Namespace = "http://schemas.vernagus.blogspot.com/01/2009",&lt;br /&gt;    Name = "MyDataContract")&amp;gt;]&lt;br /&gt;type MyDataContract =&lt;br /&gt;    { [&amp;lt;DataMember&amp;gt;] mutable MyDataMember : string }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When we create an instance of our contract and serialize it, we get the following:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;&amp;lt;MyDataContract xmlns="http://schemas.vernagus.blogspot.com/01/2009"&lt;br /&gt;                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&amp;gt;&lt;br /&gt;  &amp;lt;MyDataMember&amp;gt;my value&amp;lt;/MyDataMember&amp;gt;&lt;br /&gt;&amp;lt;/MyDataContract&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In my next post I will explore more advanced data contract concepts like collections and enumerations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-8111810139473852845?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/8111810139473852845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=8111810139473852845' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/8111810139473852845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/8111810139473852845'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2009/01/f-and-wcf-data-contracts.html' title='F# and WCF: Data Contracts'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-6390126407979790144</id><published>2009-01-19T07:58:00.004-05:00</published><updated>2009-01-19T08:12:56.058-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><category scheme='http://www.blogger.com/atom/ns#' term='wcf'/><title type='text'>F# and WCF Examples</title><content type='html'>Ted Neward recently &lt;a href="http://blogs.tedneward.com/2009/01/18/Building+WCF+Services+With+F+Part+1.aspx"&gt;wrote&lt;/a&gt; about using F# to write WCF services. I share his enthusiasm; so much so that I'm using F# to write examples as I study for &lt;a href="http://www.microsoft.com/learning/en/us/exams/70-503.mspx"&gt;MCTS 70-503&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Good examples are hard to find. Most of the time books will give incomplete, or worse, erroneous examples. I have striven to boil each example down to just the essentials needed to get it to run. The examples use F# Interactive and each example is a fully encapsulated, self-sufficient demonstration of some WCF concept. To run an example, simply type &lt;code&gt;fsi --exec &amp;#60;script name&amp;#62;&lt;/code&gt;. You can see my examples here: &lt;a href="http://code.google.com/p/wcf-examples/source/browse/#svn/trunk/FSharpExamples"&gt;http://code.google.com/p/wcf-examples/source/browse/#svn/trunk/FSharpExamples&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I am planning to run a series of posts based on my experience in using F# to write WCF services. Stay tuned for that!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-6390126407979790144?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/6390126407979790144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=6390126407979790144' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6390126407979790144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6390126407979790144'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2009/01/f-and-wcf-examples.html' title='F# and WCF Examples'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-5968887883124697326</id><published>2008-09-18T07:53:00.009-04:00</published><updated>2009-08-21T13:43:15.892-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>Programming with State in F# (Part 2)</title><content type='html'>In my last post, I talked about the contrast between F# where state is locked by default and your run-of-the-mill imperative language where it is very difficult to lock state. We also saw that F# allows us to explicitly use mutable state when we choose to do so but the point is that programmer must make an explicit &lt;em&gt;choice&lt;/em&gt;. The theme of this series of posts is that F#'s answer to the "whether to use state or not to use state" question is the best: we try not to use state where we can get away with it but when we have to use state we make that decision explicitly and carefully.&lt;br /&gt;&lt;br /&gt;I just want to talk about one example from the F# Core library. Here is an example from the Seq module:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;let length (ie : seq&lt;'a&gt;)    = &lt;br /&gt;    use e = ie.GetEnumerator() &lt;br /&gt;    let mutable state = 0 &lt;br /&gt;    while e.MoveNext() do&lt;br /&gt;        state &lt;-  state + 1;&lt;br /&gt;    state&lt;/pre&gt;The &lt;code&gt;length&lt;/code&gt; function takes any sequence and returns an int. The first line of the function retrieves the enumerator for the sequence. The second line declares a mutable identifier clearly labeled &lt;code&gt;state&lt;/code&gt;. The rest of the function simply moves through the enumerator incrementing the count. Finally, the function returns the final count. Do the internals of the &lt;code&gt;length&lt;/code&gt; function surprise you? This example is very similar to how a length might be determined in an imperative context and it highlights my favorite feature of F#: it's your choice. You certainly can implement &lt;code&gt;length&lt;/code&gt; with a recursive function and an accumulating value but would it be as fast as the version shown above? Would it be as easy to understand? You decide.&lt;br /&gt;&lt;br /&gt;Choices abound when using F# and one of the most important choices you can make will be whether or not to use state. The point of these last two posts are to highlight this quality of F#. State is generally discouraged but it is always available should you choose to use it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-5968887883124697326?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/5968887883124697326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=5968887883124697326' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/5968887883124697326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/5968887883124697326'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/09/programming-with-state-in-f-part-2.html' title='Programming with State in F# (Part 2)'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-559248403137374080</id><published>2008-09-17T09:47:00.007-04:00</published><updated>2009-08-21T13:44:57.889-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>Programming with State in F# (Part 1)</title><content type='html'>There is frequent talk these days about the use of state in programs--how to limit it and whether it should be used at all. The rising importance of concurrency and functional languages have a lot to do with this but state is hardly going to go away any time soon. For instance, Kent Beck writes favorably about state in his recent book, &lt;a href="http://www.informit.com/store/product.aspx?isbn=0321413091&amp;rll=1"&gt;Implementation Patterns&lt;/a&gt;: &lt;blockquote&gt;I think state is a valuable metaphor for us since our brains are structured and conditioned to deal with changing state. Single assignment or variableless programming forces us to discard too many effective thinking strategies to be an attractive choice.&lt;/blockquote&gt;Kent goes on to show his readers a set of patterns that can be used to manage and communicate state in a safe and effective manner. I agree that state is a valuable metaphor in programming but what is a programmer to do if they also see value in single assignment or "stateless" programming? I think F# offers the most compelling answer to this question and I'll explain why.&lt;br /&gt;&lt;br /&gt;You declare a value in F# with the &lt;code&gt;let&lt;/code&gt; keyword:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;&gt; let x = 1;;&lt;br /&gt;&lt;br /&gt;val x : int&lt;/pre&gt;We can later retrieve the value, 1, using our identifier, &lt;/code&gt;x&lt;/code&gt;:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;&gt; x;;&lt;br /&gt;&lt;br /&gt;val it : int = 1&lt;/pre&gt;Suppose, however, that we wanted to change the value assigned to &lt;code&gt;x&lt;/code&gt;. We would use the assignment operator like so:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;&gt; x &lt;- 2;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#FF0000"&gt;  x &lt;- 2;;&lt;br /&gt;  ^^^^^^^&lt;br /&gt;&lt;br /&gt;stdin(13,1): error FS0027: This value is not mutable.&lt;/span&gt;&lt;/pre&gt;As you can see, identifiers are immutable by default in F#. Once declared, they cannot be changed. This behavior extends to more complex value types. Consider this example:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;&gt; open System.Drawing;;&lt;br /&gt;&gt; let p1 = new Point(0,0);;&lt;br /&gt;&lt;br /&gt;val p1 : Point&lt;br /&gt;&lt;br /&gt;&gt; p1.X &lt;- 1;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#FF0000"&gt;  p1.X &lt;- 1;;&lt;br /&gt;  ^^^&lt;br /&gt;&lt;br /&gt;stdin(24,1): error FS0191: A value must be local and mutable in order to mutate&lt;br /&gt;the contents of a value type, e.g. 'let mutable x = ...'.&lt;/span&gt;&lt;/pre&gt;Even though the X property of System.Drawing.Point is settable, F# treats our Point as if it is immutable. We can see how the default behavior of F# compels the programmer to limit his use of state; that's just the way that it should be. By contrast, it takes &lt;em&gt;a lot&lt;/em&gt; of forethought to limit state in an imperative language.&lt;br /&gt;&lt;br /&gt;You can opt-in to the use of state by using the &lt;code&gt;mutable&lt;/code&gt; keyword:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;&gt; let mutable p2 = new Point(0,0);;&lt;br /&gt;&lt;br /&gt;val mutable p2 : Point&lt;br /&gt;&lt;br /&gt;&gt; p2.X;;&lt;br /&gt;&lt;br /&gt;val it : int = 0&lt;br /&gt;&lt;br /&gt;&gt; p2.X &lt;- 1;;&lt;br /&gt;&lt;br /&gt;val it : unit = ()&lt;br /&gt;&lt;br /&gt;&gt; p2.X;;&lt;br /&gt;&lt;br /&gt;val it : int = 1&lt;/pre&gt;When you declare an identifier as mutable, you get a variable just like you may be used to in C# or Visual Basic. You can even change the reference entirely:&lt;br /&gt;&lt;pre class="f#" name="code"&gt;&gt; p2 &lt;- new Point(1,1);;&lt;br /&gt;&lt;br /&gt;val it : unit = ()&lt;br /&gt;&lt;br /&gt;&gt; p2;;&lt;br /&gt;&lt;br /&gt;val it : Point = {X=1,Y=1} {IsEmpty = false;&lt;br /&gt;                            X = 1;&lt;br /&gt;                            Y = 1;}&lt;/pre&gt;To conclude this post, I hope to have shown some very basic examples of how F# forces you to think about where you are using state and why. This is a very good thing and in my next post, we will explore the use of state in functions and types.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-559248403137374080?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/559248403137374080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=559248403137374080' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/559248403137374080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/559248403137374080'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/09/programming-with-state-in-f-part-1.html' title='Programming with State in F# (Part 1)'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-3166897363381183476</id><published>2008-09-08T21:07:00.007-04:00</published><updated>2008-09-14T14:34:45.636-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>Book Samples in F#</title><content type='html'>I'm fairly new to functional programming but I &lt;i&gt;am&lt;/i&gt; on my second reading of a couple of great titles: &lt;a href="http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;tid=4787"&gt;The Little MLer&lt;/a&gt; and &lt;a href="http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=0521663504"&gt;Purely Functional Data Structures&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Both of these books contain code samples in Standard ML (SML) (the latter contains a Haskell appendix). Readers with a background in functional languages would have no problem translating from SML to OCaml and F# but for newcomers this can be a very complicated endeavor and it greatly detracts from the reading.&lt;br /&gt;&lt;br /&gt;When I first read these books I failed to find any code examples in F# and I even struggled to find OCaml samples based on the books. In order to encourage newcomers to F# to take up a study of functional programming, I have started a &lt;a href="http://code.google.com/p/book-samples-in-fsharp/"&gt;project&lt;/a&gt; on Google Code to address this need. The project will host relative ports of code samples from various books.&lt;br /&gt;&lt;br /&gt;I do not intend for the ports to be literal translations. There are, for instance, constructs in SML that simply aren't available in F#. But the samples should convey the spirit of the book even if they use different means to achieve that end.&lt;br /&gt;&lt;br /&gt;If you have samples or suggestions, corrections, or improvements for the samples, please get in touch!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-3166897363381183476?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/3166897363381183476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=3166897363381183476' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3166897363381183476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3166897363381183476'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/09/book-samples-in-f.html' title='Book Samples in F#'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-5502712142061414473</id><published>2008-09-04T09:05:00.003-04:00</published><updated>2008-09-04T09:23:39.028-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fsunit'/><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>FsUnit 0.6.0</title><content type='html'>I've just wrapped up a 0.6.0 release of the &lt;a href="http://code.google.com/p/fsunit/"&gt;FsUnit&lt;/a&gt; specification framework for F#! I'm really starting to appreciate the benefits of writing specifications or tests in a functional language. I hope that this project convinces others in the same way.&lt;br /&gt;&lt;br /&gt;The F# 1.9.6.0 release is a very important release. F# developers get much deeper support in Visual Studio, for one, and this led a complete overhaul of the tests behind FsUnit. I prefer to do test-driven development when I can, thus a rewrite of the tests meant a rewrite of the framework itself. Everything ended up pretty much the same as it was in the previous release (0.5.0) with a couple of minor changes.&lt;br /&gt;&lt;br /&gt;The first important change was better messages with failures and errors. The previous release didn't always provide informative messages. With this release, you should always receive enough information to identify the problem.&lt;br /&gt;&lt;br /&gt;The second important change involves better support for exceptions that may occur when running your specs. Exceptions should not prevent any other specification from running and should one occur, you should get a full stack trace along with the exception message.&lt;br /&gt;&lt;br /&gt;Finally, there was a slight change to the &lt;code&gt;spec&lt;/code&gt; function. Use of &lt;code&gt;spec&lt;/code&gt; still evaluates your specification, but it no longer adds it to the internal mutable results collection. I wanted to leave mutable state out of the framework wherever possible, thus, &lt;code&gt;spec&lt;/code&gt; now returns a &lt;code&gt;string * Result&lt;/code&gt; pair and programmers can choose to use or not to use state in their specifications. If you're lazy like me, you can use the &lt;code&gt;specs&lt;/code&gt; function to have FsUnit track your results for you.&lt;br /&gt;&lt;br /&gt;See the &lt;a href="http://code.google.com/p/fsunit/"&gt;project home page&lt;/a&gt;, the &lt;a href="http://code.google.com/p/fsunit/w/list"&gt;project wiki&lt;/a&gt;, or the included &lt;a href="http://code.google.com/p/fsunit/source/browse/#svn/trunk/Examples"&gt;examples&lt;/a&gt; for more information about the project. Please check it out and let me know how I can make it better!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-5502712142061414473?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/5502712142061414473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=5502712142061414473' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/5502712142061414473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/5502712142061414473'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/09/fsunit-060.html' title='FsUnit 0.6.0'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-6041554832931987420</id><published>2008-08-29T14:07:00.006-04:00</published><updated>2009-08-21T13:49:47.991-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ironruby'/><title type='text'>Marshaling the Ruby Way</title><content type='html'>This post is for the .NET developer who is looking at IronRuby but is otherwise unfamiliar with Ruby. As you learn Ruby, keep in mind a question that Ruby programmers like to ask themselves a lot, "What is the &lt;a href="http://rubyhacker.com/"&gt;Ruby Way&lt;/a&gt; of solving this problem?" Today the problem is marshaling an object and we're going to solve it the Ruby Way.&lt;br /&gt;&lt;br /&gt;If you're like most other .NET developers, you're probably thinking about &lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx"&gt;BinaryFormatters&lt;/a&gt; or perhaps you prefer &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx"&gt;XmlSerializers&lt;/a&gt;. Maybe you're thinking about &lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.ideserializationcallback.aspx"&gt;DeserializationCallbacks&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlignoreattribute.aspx"&gt;XmlIgnoreAttributes&lt;/a&gt; and where to put them. Stop right there! That's definitely &lt;b&gt;not&lt;/b&gt; the Ruby Way.&lt;br /&gt;&lt;br /&gt;Let's define a Ruby class:&lt;br /&gt;&lt;pre class="ruby" name="code"&gt;class Person&lt;br /&gt;  attr_reader :first_name, :last_name, :hobbies&lt;br /&gt;  &lt;br /&gt;  def initialize(first_name, last_name, *hobbies)&lt;br /&gt;    @first_name = first_name&lt;br /&gt;    @last_name = last_name&lt;br /&gt;    @hobbies = hobbies&lt;br /&gt;  end&lt;br /&gt;end&lt;/pre&gt;&lt;br /&gt;This is just a simple class with three read-only attributes: first_name, last_name, and hobbies. How would we create an instance of our class and marshal it the Ruby Way?&lt;pre class="ruby" name="code"&gt;ray = Person.new("Ray", "Vernagus", "programming", "walking")&lt;br /&gt;yml = ray.to_yaml&lt;br /&gt;puts yml&lt;/pre&gt;&lt;br /&gt;&lt;code&gt;to_yaml&lt;/code&gt;, what's that? &lt;a href="http://www.yaml.org/"&gt;YAML&lt;/a&gt; stands for "YAML ain't markup language." Did that make you smile? Now &lt;b&gt;that's&lt;/b&gt; the Ruby Way! ;) YAML is very simple but also very powerful. It's the kind of notation that you would write yourself if you were just jotting a class down on a piece of paper except that it's structured and standardized. Here's what our marshaled person looks like:&lt;br /&gt;&lt;pre class="code"&gt;--- !ruby/object:Person&lt;br /&gt;first_name: Ray&lt;br /&gt;hobbies: &lt;br /&gt;- programming&lt;br /&gt;- walking&lt;br /&gt;last_name: Vernagus&lt;/pre&gt;&lt;br /&gt;Not bad, aye? That's about as ugly as you're likely to see YAML get. I encourage you to learn more about YAML and to use it in place of XML every chance that you get.&lt;br /&gt;&lt;br /&gt;We can get our person back just as easily:&lt;br /&gt;&lt;pre class="ruby" name="code"&gt;p = YAML.load(yml)&lt;br /&gt;puts p.inspect&lt;/pre&gt;&lt;br /&gt;and this prints:&lt;br /&gt;&lt;pre class="ruby" name="code"&gt;#&amp;#60;Person:0x0000064 @first_name="Ray", @hobbies=["programming", "walking"], @last_name="Vernagus"&amp;#62;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is all running in IronRuby (batteries-included version).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-6041554832931987420?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/6041554832931987420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=6041554832931987420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6041554832931987420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6041554832931987420'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/08/marshaling-ruby-way.html' title='Marshaling the Ruby Way'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-7013683230700541222</id><published>2008-08-27T20:43:00.003-04:00</published><updated>2008-08-27T21:15:08.779-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ironruby'/><title type='text'>Threading in IronRuby (Part 2)</title><content type='html'>In my last post I pointed out some issues with the &lt;code&gt;Thread.new&lt;/code&gt; construct in IronRuby. One of the advantages of using IronRuby is that we have access to the .NET framework. In this post, we'll take a look at using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx"&gt;ThreadPool&lt;/a&gt; class in order to correct some of the issues that came up in the previous post.&lt;br /&gt;&lt;br /&gt;The first issue that we saw with the &lt;code&gt;Thread.new&lt;/code&gt; construct was that it launched the thread as soon as we declared it. When using the ThreadPool, we first declare a &lt;a href="http://msdn.microsoft.com/en-us/library/system.threading.waitcallback.aspx"&gt;callback&lt;/a&gt; object:&lt;br /&gt;&lt;pre class=code&gt;require "mscorlib"&lt;br /&gt;include System::Threading&lt;br /&gt;&lt;br /&gt;callback = WaitCallback.new { puts "pool thread" }&lt;/pre&gt;&lt;br /&gt;We declare a callback in a similar manner to a Thread, by passing a block to the constructor. In this case, however, we get a WaitCallback object that we can hold on to until we are ready to execute the block. You can run the code block by queuing it up in the ThreadPool:&lt;br /&gt;&lt;pre class="code"&gt;ThreadPool.queue_user_work_item callback&lt;/pre&gt;&lt;br /&gt;You may need to pause the main thread in order to see the line print to the console, giving us this as a full example:&lt;br /&gt;&lt;pre class="code"&gt;require "mscorlib"&lt;br /&gt;include System::Threading&lt;br /&gt;&lt;br /&gt;callback = WaitCallback.new { puts "pool thread" }&lt;br /&gt;ThreadPool.queue_user_work_item callback&lt;br /&gt;&lt;br /&gt;Thread.sleep 100&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The other issue that I mentioned concerning the &lt;code&gt;Thread.new&lt;/code&gt; construct was that it defaulted to a foreground thread. This isn't a problem when using the ThreadPool since all ThreadPool threads are background threads.&lt;br /&gt;&lt;br /&gt;A lot of this code is very un-Ruby-like. For instance, it would be nice to just write:&lt;br /&gt;&lt;pre class="code"&gt;ThreadPool.queue_user_work_item { puts "pool thread" }&lt;/pre&gt;&lt;br /&gt;Hopefully future versions of IronRuby will make it easier to pass blocks in place of delegates. That would definitely make these tasks feel more like Ruby.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-7013683230700541222?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/7013683230700541222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=7013683230700541222' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7013683230700541222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7013683230700541222'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/08/threading-in-ironruby-part-2.html' title='Threading in IronRuby (Part 2)'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-7528266510853443343</id><published>2008-08-25T21:32:00.005-04:00</published><updated>2008-08-26T06:59:34.455-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ironruby'/><title type='text'>Threading in IronRuby (Part 1)</title><content type='html'>I couldn't find much at all on the Web about threading in IronRuby. Here's a little introduction to some basic threading in IronRuby.&lt;br /&gt;&lt;br /&gt;In contrast to Ruby's less than ideal threading model (which is to change in 1.9), .NET has a rich threading model that we can tap into using IronRuby. We can create a new thread in IronRuby in the same way that we do in MRI Ruby:&lt;br /&gt;&lt;pre class="code"&gt;Thread.new { puts "child thread" }&lt;/pre&gt;&lt;br /&gt;In IronRuby, however, we're not talking "green" threads. Instead, we get a real .NET thread as demonstrated in this example:&lt;br /&gt;&lt;pre class="code"&gt;require "mscorlib"&lt;br /&gt;include System::Threading&lt;br /&gt;&lt;br /&gt;puts "##{Thread.current_thread.managed_thread_id} is the main thread."&lt;br /&gt;# #1 is the main thread.&lt;br /&gt;&lt;br /&gt;Thread.new { puts "##{Thread.current_thread.managed_thread_id} is a child thread." }&lt;br /&gt;# #3 is a child thread.&lt;/pre&gt;&lt;br /&gt;You may have noticed that we didn't have to do anything to launch the thread. This is undesirable if you need to, for instance, start a thread as a background thread. Since the default value for the &lt;a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground(VS.71).aspx"&gt;IsBackground&lt;/a&gt; property is false, the thread in the example above runs as a foreground thread. If your thread runs long enough, you can do this:&lt;br /&gt;&lt;pre class="code"&gt;require "mscorlib"&lt;br /&gt;include System::Threading&lt;br /&gt;&lt;br /&gt;t = Thread.new { Thread.sleep 1000 }&lt;br /&gt;puts "t.is_background = #{t.is_background}"&lt;br /&gt;# t.is_background = false&lt;br /&gt;&lt;br /&gt;t.is_background = true&lt;br /&gt;puts "t.is_background = #{t.is_background}"&lt;br /&gt;# t.is_background = true&lt;/pre&gt;&lt;br /&gt;Use of &lt;code&gt;Thread.new&lt;/code&gt; will probably suffice in only the simplest situations. IronRuby supports more advanced threading scenarios and we'll get started on that in the next post in this series!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-7528266510853443343?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/7528266510853443343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=7528266510853443343' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7528266510853443343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7528266510853443343'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/08/threading-in-ironruby-part-1.html' title='Threading in IronRuby (Part 1)'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-7761804552232136692</id><published>2008-08-09T21:05:00.003-04:00</published><updated>2008-08-09T21:15:14.384-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='msmvc'/><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>Get Going Quickly with F# and ASP.NET MVC</title><content type='html'>Want a quick way to get going with F# and ASP.NET MVC?&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Start a new MVC project.&lt;/li&gt;&lt;li&gt;Add an F# project to your solution with a source file in it.&lt;/li&gt;&lt;li&gt;Set the project type for your F# project to dll.&lt;/li&gt;&lt;li&gt;Set the output path to the bin folder of your MVC project.&lt;/li&gt;&lt;li&gt;Add a namespace declaration to your F# source file. The namespace must match your MVC project's namespace, for example, MvcApplication1.Controllers.&lt;/li&gt;&lt;li&gt;Write a controller in F# and compile your F# project.&lt;/li&gt;&lt;li&gt;Reference your F# output in your MVC project.&lt;/li&gt;&lt;/ol&gt;If everything's wired up correctly, you can visit the appropriate URL in your browser and your F# controller will get called!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-7761804552232136692?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/7761804552232136692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=7761804552232136692' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7761804552232136692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7761804552232136692'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/08/get-going-quickly-with-f-and-aspnet-mvc.html' title='Get Going Quickly with F# and ASP.NET MVC'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-7656017734190170708</id><published>2008-08-06T14:37:00.003-04:00</published><updated>2008-08-06T14:55:13.031-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rest'/><category scheme='http://www.blogger.com/atom/ns#' term='msmvc'/><title type='text'>ASP.NET MVC &amp; REST</title><content type='html'>Make that 4 too many acronyms...my apologies.&lt;br /&gt;&lt;br /&gt;I'm crazy about REST. It appeals to me in a number of ways and it's the primary reason behind my interest in ASP.NET MVC. I didn't know a thing about REST prior to Ruby on Rails v2.0 but then again I wasn't a web programmer prior to that. Now that I'm building web applications on a regular basis, I've been drawn to REST and Rails concepts.&lt;br /&gt;&lt;br /&gt;Which brings me to the topic of this post: REST on ASP.NET MVC (MSMVC)! It turns out that the MSMVC framework is very capable of following REST principles. The routing engine supports constraints based on HTTP methods and it's a no-brainer to also support overloaded POST. Here's a simple constraint to support a hidden &lt;code&gt;_method&lt;/code&gt; form input:&lt;br /&gt;&lt;pre class="code"&gt;public class FormMethodConstraint : IRouteConstraint {&lt;br /&gt;    string _method;&lt;br /&gt;&lt;br /&gt;    public FormMethodConstraint(string method) {&lt;br /&gt;        if (String.IsNullOrEmpty(method))&lt;br /&gt;            throw new ArgumentException("method cannot be null or empty.", "method");&lt;br /&gt;        _method = String.Format("^{0}$", method);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public bool Match(System.Web.HttpContextBase httpContext,&lt;br /&gt;            Route route, string parameterName,&lt;br /&gt;            RouteValueDictionary values,&lt;br /&gt;            RouteDirection routeDirection) {&lt;br /&gt;        var vals = httpContext.Request.Form.GetValues("_method");&lt;br /&gt;        if (vals == null) return false;&lt;br /&gt;&lt;br /&gt;        foreach (var val in vals)&lt;br /&gt;            if (Regex.IsMatch(val, _method, RegexOptions.IgnoreCase)) return true;&lt;br /&gt;        return false;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;With this class, you can write routes that support overloaded POST:&lt;br /&gt;&lt;pre class="code"&gt;source.MapRoute(&lt;br /&gt;    "FormDestroy",&lt;br /&gt;    "{controller}/{id}",&lt;br /&gt;    new { action = "Destroy" },&lt;br /&gt;    new { httpMethod = new HttpMethodConstraint("POST"),&lt;br /&gt;          formMethod = new FormMethodConstraint("DELETE") }&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, you can put a hidden input in your form with the name &lt;code&gt;_method&lt;/code&gt; and the value &lt;code&gt;DELETE&lt;/code&gt; and when the form is sent back the server, it will route to the Destroy() action on your controller!&lt;br /&gt;&lt;br /&gt;There's more RESTful goodness to come from me, I'm just getting started! :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-7656017734190170708?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/7656017734190170708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=7656017734190170708' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7656017734190170708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7656017734190170708'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/08/aspnet-mvc-rest.html' title='ASP.NET MVC &amp; REST'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-1571950484106080757</id><published>2008-07-25T22:50:00.007-04:00</published><updated>2008-07-26T07:22:07.897-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rest'/><category scheme='http://www.blogger.com/atom/ns#' term='gisserver'/><title type='text'>GIS Server REST and Quirks Mode</title><content type='html'>ESRI recently released their &lt;a href="http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jshelp_start.htm"&gt;REST API&lt;/a&gt; for &lt;a href="http://www.esri.com/software/arcgis/arcgisserver/"&gt;GIS Server&lt;/a&gt;. I finally got a chance to put the REST API to use today and I have to say that I &lt;span style="font-weight: bold;"&gt;love &lt;/span&gt;it thus far! This really changes the picture for developing web apps using GIS Server.&lt;br /&gt;&lt;br /&gt;I did, however, notice that the javascript examples produced by the REST services aren't &lt;a href="http://www.w3.org/TR/xhtml1/"&gt;XHTML&lt;/a&gt;. This has the side effect of forcing the browser into &lt;a href="http://www.quirksmode.org/css/quirksmode.html"&gt;quirks mode&lt;/a&gt;. You can see why this was likely intended by adding a DOCTYPE declaration to the top of one of the sample pages:&lt;br /&gt;&lt;pre class="code"&gt;&amp;#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;#62;&lt;/pre&gt;&lt;br /&gt;When you do this, the map disappears! The sample pages use a table layout with &lt;code&gt;style="height: 99%;"&lt;/code&gt; to expand the table row to fill the page. The problem with this approach is that it is only supported in quirks mode.&lt;br /&gt;&lt;br /&gt;I'm not an expert on CSS but I am able to get a map to fill the page without using a table layout or quirks mode. You should be able to just add this style declaration in the &amp;#60;head&amp;#62; section of your page:&lt;br /&gt;&lt;pre class="code"&gt;&amp;#60;style&amp;#62;&lt;br /&gt;   html, body, div#map {&lt;br /&gt;       height: 99%;&lt;br /&gt;   }&lt;br /&gt;   body {&lt;br /&gt;       margin: 0px; /* Used here for IE &amp; Mozilla */&lt;br /&gt;       padding: 0px; /* Used here for Opera */&lt;br /&gt;   }&lt;br /&gt;   div#map {&lt;br /&gt;       width: 99%;&lt;br /&gt;   }&lt;br /&gt;&amp;#60;/style&amp;#62;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using this approach, you don't have to embed your maps in a table layout &lt;b&gt;and&lt;/b&gt; you can write true XHTML.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-1571950484106080757?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/1571950484106080757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=1571950484106080757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/1571950484106080757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/1571950484106080757'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/07/gis-server-rest-and-quirks-mode.html' title='GIS Server REST and Quirks Mode'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-6198331792007431792</id><published>2008-07-24T10:12:00.004-04:00</published><updated>2008-07-25T22:49:39.310-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>FsUnit 0.5.0!</title><content type='html'>I'd like to announce the release of &lt;a href="http://code.google.com/p/fsunit/"&gt;FsUnit 0.5.0&lt;/a&gt;! What began as a stabilization release ended up as a complete rewrite. The core syntax is still the same, in fact, it got even better. One of the primary goals of FsUnit is to remain as clean as possible, from language constructs that is.&lt;br /&gt;&lt;br /&gt;This latest release actually removed the need for a pair of parens in many cases. So instead of:&lt;br /&gt;&lt;pre class="code"&gt;1 |&gt; should (equal 1)&lt;/pre&gt;&lt;br /&gt;you can now write:&lt;br /&gt;&lt;pre class="code"&gt;1 |&gt; should equal 1&lt;/pre&gt;&lt;br /&gt;Getting rid of parens at this level is pretty important to me so it's pleasure to bid them adieu!&lt;br /&gt;&lt;br /&gt;One of the other major changes was perhaps more for my sake than for the user's but then maybe not. Prior releases incorporated negation into the assertion bit itself. So if you wanted to say "1 should not equal 2" you had to write:&lt;br /&gt;&lt;pre class="code"&gt;1 |&gt; should (notEqual 2)&lt;/pre&gt;&lt;br /&gt;The &lt;code&gt;not'&lt;/code&gt; keyword makes it possible to negate any assertion in FsUnit:&lt;br /&gt;&lt;pre class="code"&gt;1 |&gt; should not' (equal 2)&lt;/pre&gt;This removed a lot of duplicate code and it also just about cut the number of specs for FsUnit itself in half.&lt;br /&gt;&lt;br /&gt;Finally, the last major change is the &lt;code&gt;spec&lt;/code&gt; keyword. This keyword is a shortcut for labeling and executing your specs. It also stores the result in a ResultStore object. With the &lt;code&gt;spec&lt;/code&gt; keyword, specs look like this:&lt;br /&gt;&lt;pre class="code"&gt;spec "A number should equal itself."&lt;br /&gt;  (1 |&gt; should equal 1)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I like the way that this looks very much and I'm going to try to keep this syntax stable between releases.&lt;br /&gt;&lt;br /&gt;Let me know what you think of the new release!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-6198331792007431792?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/6198331792007431792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=6198331792007431792' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6198331792007431792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6198331792007431792'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/07/fsunit-050.html' title='FsUnit 0.5.0!'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-4660229110871167762</id><published>2008-07-22T09:52:00.001-04:00</published><updated>2008-07-22T20:12:04.695-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='ArcObjects'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>Using LINQ with ArcObjects</title><content type='html'>Are you using .NET 3.5 to do &lt;a href="http:///"&gt;ArcObjects&lt;/a&gt; programming? Are you still manually enumerating through row or feature cursors? Listen up!&lt;br /&gt;&lt;br /&gt;It's really very simple to get LINQ running with ArcObjects. All you have to do is add an extension method to either ICursor or IFeatureCursor like so:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;public static class&lt;/span&gt; ICursorExtensions {&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public static&lt;/span&gt; IEnumerable&amp;#60;IRow&amp;#62; AsEnumerable(this ICursor source) {&lt;br /&gt;        &lt;span class="kwrd"&gt;Func&amp;#60;IRow&amp;#62;&lt;/span&gt; next = () =&gt; source.NextRow();&lt;br /&gt;        &lt;span class="kwrd"&gt;IRow&lt;/span&gt; current = next();&lt;br /&gt;        &lt;span class="kwrd"&gt;while&lt;/span&gt; (current != &lt;span class="kwrd"&gt;null&lt;/span&gt;) {&lt;br /&gt;            yield return current;&lt;br /&gt;            current = next();&lt;br /&gt;        } &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;With your new extension method in hand, you can unleash LINQ on your ArcObjects code. You can now write code like this:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;Int32&lt;/span&gt; count = cursor.AsEnumerable().Count();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Or, you could write a query expression against two cursor objects:&lt;br /&gt;&lt;pre class="code"&gt;&lt;/span class="kwrd"&gt;var&lt;/span&gt; resultSeq =&lt;br /&gt;    &lt;/span class="kwrd"&gt;from&lt;/span&gt; x &lt;/span class="kwrd"&gt;in&lt;/span&gt; cursor1.AsEnumerable()&lt;br /&gt;    &lt;/span class="kwrd"&gt;from&lt;/span&gt; y &lt;/span class="kwrd"&gt;in&lt;/span&gt; cursor2.AsEnumerable()&lt;br /&gt;    &lt;/span class="kwrd"&gt;where&lt;/span&gt; x.get_Value(0) = y.get_Value(0)&lt;br /&gt;    &lt;/span class="kwrd"&gt;select new&lt;/span&gt; { Left = x, Right = y };&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can do a similar thing in F#:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;type&lt;/span&gt; ICursor &lt;span class="kwrd"&gt;with&lt;/span&gt;&lt;br /&gt;    member c.AsEnumerable() =&lt;br /&gt;        &lt;span class="kwrd"&gt;seq&lt;/span&gt; { &lt;br /&gt;            &lt;span class="kwrd"&gt;let&lt;/span&gt; next = c.NextRow&lt;br /&gt;            &lt;span class="kwrd"&gt;let&lt;/span&gt; current = ref (next())&lt;br /&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt; !current &lt;&gt; null do&lt;br /&gt;                &lt;span class="kwrd"&gt;yield&lt;/span&gt; !current&lt;br /&gt;                &lt;span class="kwrd"&gt;do&lt;/span&gt; current := next()&lt;br /&gt;        }&lt;br /&gt;&lt;/span class="kwrd"&gt;let&lt;/span&gt; count = cursor.AsEnumerable() |&gt; Seq.length&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Sure beats manually manipulating an enumerator, doesn't it?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-4660229110871167762?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/4660229110871167762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=4660229110871167762' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4660229110871167762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4660229110871167762'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/07/using-linq-with-arcobjects.html' title='Using LINQ with ArcObjects'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-6649844314495902928</id><published>2008-07-21T21:41:00.000-04:00</published><updated>2008-07-22T10:56:50.409-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='functionalprogramming'/><title type='text'>Unit Testing in Functional Languages</title><content type='html'>I'm very interested in learning more about how people are doing unit-testing in functional languages. My personal experience has been with &lt;a href="http://www.xs4all.nl/~mmzeeman/ocaml/ounit-doc/OUnit.html"&gt;OUnit&lt;/a&gt; and &lt;a href="http://hunit.sourceforge.net/HUnit-1.0/Guide.html"&gt;HUnit&lt;/a&gt; for OCaml and Haskell respectively. These frameworks get the job done but they felt foreign to me when I was using them.&lt;br /&gt;&lt;br /&gt;Perhaps my feeling stemmed from an unfamiliarity with functional programming in general but I think it had more to do with the fact that these frameworks were trying to be just another xUnit. (Not &lt;a href="http://www.codeplex.com/xunit"&gt;XUnit&lt;/a&gt; but &lt;a href="http://en.wikipedia.org/wiki/XUnit"&gt;xUnit&lt;/a&gt;.) There's definitely a benefit to be had in reusing things that are already well-known but I think this gives short shrift to functional programs.&lt;br /&gt;&lt;br /&gt;My current thoughts on the matter are ultimately being expressed in the &lt;a href="http://code.google.com/p/fsunit/"&gt;FsUnit&lt;/a&gt; project where I plan to bring inspiration from my favorite frameworks. &lt;a href="http://rspec.info/"&gt;RSpec&lt;/a&gt; is probably at the top of the list which is apparent in my choice of keywords.&lt;br /&gt;&lt;br /&gt;Functional programming is a perfect fit for unit testing: no side-effects;  small, composable units; deterministic paths; idempotence. These are some of the most important qualities of programs that make them testable. Add to that a deep support for language-oriented programming and we have fertile ground for test-driven development and the likes.&lt;br /&gt;&lt;br /&gt;If you have experience unit testing in functional languages, I would love to get example code and/or resources.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-6649844314495902928?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/6649844314495902928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=6649844314495902928' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6649844314495902928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6649844314495902928'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/07/unit-testing-in-functional-languages.html' title='Unit Testing in Functional Languages'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-4752930432869547113</id><published>2008-07-20T14:54:00.001-04:00</published><updated>2008-07-20T15:07:33.845-04:00</updated><title type='text'>Terrarium 2 &amp; F#</title><content type='html'>The Terrarium project was recently updated and added to Codeplex as &lt;a href="http://www.codeplex.com/terrarium2"&gt;Terrarium 2&lt;/a&gt;. I attempted to run through the tutorial that comes with the SDK using F#. I did so with some trepidation because the "What is Terrarium" document warns us that support for other .NET languages is conditional on certain security features that are enforced by Terrarium. Some of the things that are disallowed by Terrarium are static methods, threading calls, and deconstructors.&lt;br /&gt;&lt;br /&gt;I had no luck getting the tutorial to run in F#. I always end up with either an exception on birth or a security violation. I was, however, able to get an F# creature to appear in my Terrarium after I stripped it down to just a shell of an Animal. But that's not very interesting is it?&lt;br /&gt;&lt;br /&gt;More to come on this as language support improves (something the SDK mentions will get better)!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-4752930432869547113?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/4752930432869547113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=4752930432869547113' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4752930432869547113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4752930432869547113'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/07/terrarium-2-f.html' title='Terrarium 2 &amp; F#'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-3456641091136845808</id><published>2008-07-16T21:29:00.000-04:00</published><updated>2008-07-16T21:40:21.737-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>Kill That Annoying Flicker</title><content type='html'>The DataSamples sample (pp. 291-303) in Expert F# has an annoying flicker that can be fixed by adding the following line of code after line 101:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;do&lt;/span&gt; base.SetStyle(ControlStyles.AllPaintingInWmPaint |||&lt;br /&gt;                 ControlStyles.UserPaint |||&lt;br /&gt;                 ControlStyles.DoubleBuffer,&lt;br /&gt;                 true)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you're writing the code yourself, put the above line after this line:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;do&lt;/span&gt; base.BackColor &lt;- Color.DarkBlue &lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-3456641091136845808?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/3456641091136845808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=3456641091136845808' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3456641091136845808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3456641091136845808'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2008/07/kill-that-annoying-flicker.html' title='Kill That Annoying Flicker'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-305855585402295092</id><published>2007-10-14T09:00:00.000-04:00</published><updated>2007-10-22T13:20:02.525-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><category scheme='http://www.blogger.com/atom/ns#' term='datastructs'/><title type='text'>Purely Functional Data Structures: An F# Binary Tree</title><content type='html'>Continuing my &lt;a href="http://vernagus.blogspot.com/search/label/datastructs"&gt;series&lt;/a&gt; on Purely Functional Data Structures, here's my F# implementation of a binary tree:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;#light&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;type&lt;/span&gt; Elem = int&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;type&lt;/span&gt; Tree = E | T of Tree * Elem * Tree&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let&lt;/span&gt; empty = E&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let rec&lt;/span&gt; mem = &lt;span class="kwrd"&gt;function&lt;/span&gt;&lt;br /&gt;    | x, E -&gt; false&lt;br /&gt;    | x, T(a, y, b) when x &lt; y -&gt; mem(x, a)&lt;br /&gt;    | x, T(a, y, b) when y &lt; x -&gt; mem(x, b)&lt;br /&gt;    | _ -&gt; true&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let rec&lt;/span&gt; insert = &lt;span class="kwrd"&gt;function&lt;/span&gt;&lt;br /&gt;    | x, E -&gt; T(E, x, E)&lt;br /&gt;    | x, T(a, y, b) when x &lt; y -&gt; T(insert(x, a), y, b)&lt;br /&gt;    | x, T(a, y, b) when y &lt; x -&gt; T(a, y, insert(x, b))&lt;br /&gt;    | _, s -&gt; s&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here's what the tree looks like in use:&lt;br /&gt;&lt;pre class="code"&gt;&gt; let t = T(E, 1, E);;&lt;br /&gt;&lt;br /&gt;val t : Tree&lt;br /&gt;&lt;br /&gt;&gt; t;;&lt;br /&gt;&lt;br /&gt;val it : Tree = T (E,1,E)&lt;br /&gt;&lt;br /&gt;&gt; let t1 = insert(0, t);;&lt;br /&gt;&lt;br /&gt;val t1 : Tree&lt;br /&gt;&lt;br /&gt;&gt; t1;;&lt;br /&gt;&lt;br /&gt;val it : Tree = T (T (E,0,E),1,E)&lt;br /&gt;&lt;br /&gt;&gt; let t2 = insert(10, t1);;&lt;br /&gt;&lt;br /&gt;val t2 : Tree&lt;br /&gt;&lt;br /&gt;&gt; t2;;&lt;br /&gt;&lt;br /&gt;val it : Tree = T (T (E,0,E),1,T (E,10,E))&lt;br /&gt;&lt;br /&gt;&gt; let t3 = insert(5, t2);;&lt;br /&gt;&lt;br /&gt;val t3 : Tree&lt;br /&gt;&lt;br /&gt;&gt; t3;;&lt;br /&gt;&lt;br /&gt;val it : Tree = T (T (E,0,E),1,T (T (E,5,E),10,E))&lt;br /&gt;&lt;br /&gt;&gt; mem(10, t1);;&lt;br /&gt;&lt;br /&gt;val it : bool = false&lt;br /&gt;&lt;br /&gt;&gt; mem(10, t2);;&lt;br /&gt;&lt;br /&gt;val it : bool = true&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-305855585402295092?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/305855585402295092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=305855585402295092' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/305855585402295092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/305855585402295092'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/10/purely-functional-data-structures-f_14.html' title='Purely Functional Data Structures: An F# Binary Tree'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-1676356192164945824</id><published>2007-10-13T23:09:00.001-04:00</published><updated>2007-10-22T13:24:32.445-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><category scheme='http://www.blogger.com/atom/ns#' term='datastructs'/><title type='text'>Stack Examples</title><content type='html'>Here is the &lt;a href="http://vernagus.blogspot.com/2007/10/purely-functional-data-structures-f.html"&gt;previous&lt;/a&gt; stack implementation in use.&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&gt; let xs = Cons(0, Cons(1, Cons(2, Nil)));;&lt;br /&gt;&lt;br /&gt;val xs : int Stack&lt;br /&gt;&lt;br /&gt;&gt; xs;;&lt;br /&gt;&lt;br /&gt;val it : int Stack = Cons (0,Cons (1,Cons (2,Nil)))&lt;br /&gt;&lt;br /&gt;&gt; let ys = Cons(3, Cons(4, Cons(5, Nil)));;&lt;br /&gt;&lt;br /&gt;val ys : int Stack&lt;br /&gt;&lt;br /&gt;&gt; ys;;&lt;br /&gt;&lt;br /&gt;val it : int Stack = Cons (3,Cons (4,Cons (5,Nil)))&lt;br /&gt;&lt;br /&gt;&gt; let zs = xs -||- ys;;&lt;br /&gt;&lt;br /&gt;val zs : int Stack&lt;br /&gt;&lt;br /&gt;&gt; zs;;&lt;br /&gt;&lt;br /&gt;val it : int Stack = Cons (0,Cons (1,Cons (2,Cons (3,Cons (4,Cons (5,Nil))))))&lt;br /&gt;&lt;br /&gt;&gt; head xs;;&lt;br /&gt;&lt;br /&gt;val it : int = 0&lt;br /&gt;&lt;br /&gt;&gt; tail xs;;&lt;br /&gt;&lt;br /&gt;val it : int Stack = Cons (1,Cons (2,Nil))&lt;br /&gt;&lt;br /&gt;&gt; update(xs, 1, 99);;&lt;br /&gt;&lt;br /&gt;val it : int Stack = Cons (0,Cons (99,Cons (2,Nil)))&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-1676356192164945824?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/1676356192164945824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=1676356192164945824' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/1676356192164945824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/1676356192164945824'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/10/stack-examples.html' title='Stack Examples'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-8043239306922096948</id><published>2007-10-13T22:31:00.000-04:00</published><updated>2007-10-14T09:04:51.879-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><category scheme='http://www.blogger.com/atom/ns#' term='datastructs'/><title type='text'>Purely Functional Data Structures: An F# Stack</title><content type='html'>One of the beauties of F# is that it doesn't force you to follow one programming technique. If you want to code with objects in an imperative style, you're free to. If you want to write strict functional code, you're free to do that as well.&lt;br /&gt;&lt;br /&gt;I'm quite familiar with imperative modes of programming so I've been bending my mind in the functional direction by reading &lt;a href="http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=0521663504"&gt;Purely Functional Data Structures&lt;/a&gt;. The book's examples are written in ML (with a Haskell appendix), so I'm re-writing them in F#. I'll post them here as I do in the hopes that it will help other .NET programmers bend their mind as well.&lt;br /&gt;&lt;br /&gt;Here is the code for a Stack implementation from Chapter 2.1:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;#light&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;exception&lt;/span&gt; Empty&lt;br /&gt;&lt;span class="kwrd"&gt;exception&lt;/span&gt; Subscript&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;type&lt;/span&gt; 'a Stack = Nil | Cons of 'a * 'a Stack&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let&lt;/span&gt; empty = Nil&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let&lt;/span&gt; isEmpty = &lt;span class="kwrd"&gt;function&lt;/span&gt;&lt;br /&gt;    | Nil -&gt; true&lt;br /&gt;    | _ -&gt; false&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let&lt;/span&gt; head = &lt;span class="kwrd"&gt;function&lt;/span&gt;&lt;br /&gt;    | Nil -&gt; raise Empty&lt;br /&gt;    | Cons(x, s) -&gt; x&lt;br /&gt;    &lt;br /&gt;&lt;span class="kwrd"&gt;let&lt;/span&gt; tail = &lt;span class="kwrd"&gt;function&lt;/span&gt;&lt;br /&gt;    | Nil -&gt; raise Empty&lt;br /&gt;    | Cons(x, s) -&gt; s&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let rec&lt;/span&gt; (-||-) xs ys =&lt;br /&gt;    if isEmpty xs then&lt;br /&gt;        ys&lt;br /&gt;    else&lt;br /&gt;        Cons(head xs, tail xs -||- ys)&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;let rec&lt;/span&gt; update = &lt;span class="kwrd"&gt;function&lt;/span&gt;&lt;br /&gt;    | Nil, i, y -&gt; raise Subscript&lt;br /&gt;    | xs, 0, y -&gt; Cons(y, tail(xs))&lt;br /&gt;    | xs, i, y -&gt; Cons(head(xs), update(tail(xs), i-1, y))&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-8043239306922096948?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/8043239306922096948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=8043239306922096948' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/8043239306922096948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/8043239306922096948'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/10/purely-functional-data-structures-f.html' title='Purely Functional Data Structures: An F# Stack'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-4026662154852419849</id><published>2007-10-02T12:36:00.000-04:00</published><updated>2007-10-02T13:01:17.997-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ironruby'/><title type='text'>Extension Methods and IronRuby</title><content type='html'>You may or may not be excited about C# getting &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx"&gt;extension methods&lt;/a&gt; but this idea is a core part of Ruby. IronRuby carries this spirit into .NET where it's a simple matter to add a method to an existing class--even a BCL class.&lt;br /&gt;&lt;br /&gt;As rich as the BCL classes are, there are times where a bit of functionality is just plain missing. In sticking with true object-oriented practices, Ruby makes it easy to add that functionality where it belongs. &lt;br /&gt;&lt;br /&gt;Suppose that you are constantly turning your strings into questions. Instead of creating a Questionizer class that takes a string and manipulates it in some way, wouldn't it be nice to just store our questionizing functionality on the strings themselves? Enter the IronRuby prompt and type the following:&lt;br /&gt;&lt;pre class="code"&gt;&gt;&gt;&gt; class &lt;span class="kwrd"&gt;String&lt;/span&gt;&lt;br /&gt;...   def questionize&lt;br /&gt;...     self + &lt;span class="str"&gt;", eh?"&lt;/span&gt;&lt;br /&gt;...   end&lt;br /&gt;... end&lt;br /&gt;=&gt; nil&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You just added a method to all String objects. Now you can use your method anywhere that you have a string object:&lt;br /&gt;&lt;pre class="code"&gt;&gt;&gt;&gt; &lt;span class="str"&gt;"Nice weather"&lt;/span&gt;.questionize&lt;br /&gt;=&gt; "Nice weather, eh?"&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now go forth and put your functionality where it clearly belongs!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-4026662154852419849?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/4026662154852419849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=4026662154852419849' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4026662154852419849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4026662154852419849'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/10/extension-methods-and-ironruby.html' title='Extension Methods and IronRuby'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-6193530856364587486</id><published>2007-09-25T13:58:00.001-04:00</published><updated>2007-09-26T07:30:19.429-04:00</updated><title type='text'>Functional Programming Patterns</title><content type='html'>If you're new to functional programming (like me), you'll quickly find a number of useful patterns that you can apply to your everyday coding tasks. Take the following task as an example: we have a FeatureCursor and we would like to repeat a certain action for every Feature in the Cursor. In C#, it would look something like this:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwd"&gt;IFeature&lt;/span&gt; feature = cursor.NextFeature();&lt;br /&gt;while (feature != null)&lt;br /&gt;{&lt;br /&gt;    // Do something with the feature&lt;br /&gt;    Console.WriteLine(feature.OID);&lt;br /&gt;    feature = cursor.NextFeature();&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is a common pattern in ArcObjects. How can we express this pattern in F# while allowing for flexibility in the action that we wish to perform?&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;let forAll (f : IFeature -&gt; unit) (cursor : IFeatureCursor) =&lt;br /&gt;    let mutable feature = cursor.NextFeature()&lt;br /&gt;    while feature &lt;&gt; null do&lt;br /&gt;        // Do something with the feature&lt;br /&gt;        f feature&lt;br /&gt;        feature &lt;- cursor.NextFeature()&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We can pass any function that we want to so long as it takes an IFeature and returns unit:&lt;br /&gt;&lt;pre class="code"&gt;forAll (fun feature -&gt; Console.WriteLine(feature.OID)) cursor&lt;/pre&gt;&lt;br /&gt;You could write a ForAll function in C# but it just wouldn't feel as natural, would it?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-6193530856364587486?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/6193530856364587486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=6193530856364587486' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6193530856364587486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/6193530856364587486'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/09/functional-programming-patterns.html' title='Functional Programming Patterns'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-3949762707291168471</id><published>2007-09-25T13:10:00.001-04:00</published><updated>2007-09-25T13:38:24.431-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><category scheme='http://www.blogger.com/atom/ns#' term='ArcObjects'/><title type='text'>F# and ArcObjects</title><content type='html'>Interested in programming with ArcObject using F#? It's easy!&lt;br /&gt;&lt;br /&gt;Start fsi referencing the appropriate ArcObjects assemblies:&lt;br /&gt;&lt;pre class="code"&gt;C:\&gt;fsi -I C:\ArcGis\DotNet -r ESRI.ArcGIS.System.dll -r ESRI.ArcGIS.DataSourcesGDB.dll -r ESRI.ArcGIS.Geodatabase.dll&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now you can open some ArcObjects namespaces:&lt;br /&gt;&lt;pre class="code"&gt;&gt; open ESRI.ArcGIS.esriSystem;;&lt;br /&gt;&lt;br /&gt;&gt; open ESRI.ArcGIS.DataSourcesGDB;;&lt;br /&gt;&lt;br /&gt;&gt; open ESRI.ArcGIS.Geodatabase;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Next, we need to initialize our license:&lt;br /&gt;&lt;pre class="code"&gt;&gt; let aoi = new AoInitializeClass();;&lt;br /&gt;&lt;br /&gt;val aoi : AoInitializeClass&lt;br /&gt;&lt;br /&gt;&gt; aoi.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);;&lt;br /&gt;&lt;br /&gt;val it : esriLicenseStatus = esriLicenseCheckedOut&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then we can connect to our geodatabase:&lt;br /&gt;&lt;pre class="code"&gt;&gt; let workspaceString = "user=MyUserName;password=MyPassword;server=MyServer;instance=MyInstance;version=SDE.DEFAULT";;&lt;br /&gt;&lt;br /&gt;val workspaceString : string&lt;br /&gt;&lt;br /&gt;&gt; let fact = new SdeWorkspaceFactoryClass();;&lt;br /&gt;&lt;br /&gt;val fact : SdeWorkspaceFactoryClass&lt;br /&gt;&lt;br /&gt;&gt; let ws = fact.OpenFromString(workspaceString, 0);;&lt;br /&gt;&lt;br /&gt;val ws : IWorkspace&lt;br /&gt;&lt;br /&gt;&gt; let featureWs = (box ws) :?&gt; IFeatureWorkspace;;&lt;br /&gt;&lt;br /&gt;val featureWs : IFeatureWorkspace&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Notice that we have to first box our Workspace object before we can cast it to the IFeatureWorkspace interface. I believe that this has to do with &lt;a href="http://blogs.msdn.com/brada/archive/2003/11/15/50721.aspx"&gt;explicit member implementation&lt;/a&gt;, but I could be wrong.&lt;br /&gt;&lt;br /&gt;Want to get a specific feature? OK:&lt;br /&gt;&lt;pre class="code"&gt;&gt; let fc = featureWs.OpenFeatureClass("MyFeatureClass");;&lt;br /&gt;&lt;br /&gt;val fc : IFeatureClass&lt;br /&gt;&lt;br /&gt;&gt; fc.GetFeature(1684597);;&lt;br /&gt;&lt;br /&gt;val it : IFeature = System.__ComObject&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And so on...&lt;br /&gt;&lt;br /&gt;As you can see, F# has no problem working with ArcObjects. Throw in the Interactive Console and you have a very attractive platform for programming with ArcObjects.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-3949762707291168471?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/3949762707291168471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=3949762707291168471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3949762707291168471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3949762707291168471'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/09/interested-in-programming-with.html' title='F# and ArcObjects'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-7953365933089883880</id><published>2007-09-20T18:20:00.000-04:00</published><updated>2007-09-20T19:00:35.404-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unit Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>Easy Testing in F#</title><content type='html'>I've found a personally acceptable answer to the &lt;a href="http://www.google.com/search?q=unit+testing+private+public&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a"&gt;debate&lt;/a&gt; about whether or not to test private members. This is a technique that you can use in F#.&lt;br /&gt;&lt;br /&gt;Here are some of the issues that you might face in testing F# code:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;I want to &lt;a href="http://xunitpatterns.com/Test%20Logic%20in%20Production.html"&gt;keep my test code out&lt;/a&gt; of my production assembly.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;I need a &lt;a href="http://msdn2.microsoft.com/en-US/library/bhc3fa7f.aspx"&gt;CLS-friendly&lt;/a&gt; API that doesn't expose F#-specific types.&lt;/li&gt;&lt;li&gt;I want to test at as &lt;a href="http://xunitpatterns.com/Philosophy%20Of%20Test%20Automation.html"&gt;fine-grained&lt;/a&gt; a level as I can.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Perhaps you see my quandary. I want my test code to be in a separate assembly from my production code, so the code-under-test needs to be exposed. The more CLS-friendly I make my assembly, the further away from the code I get. And finally, I want to test all of those little functions that I'll inevitably end up writing except I don't want to expose all of those little functions in my API.&lt;br /&gt;&lt;br /&gt;My answer? It's simple, I just compile my &lt;a href="http://xunitpatterns.com/SUT.html"&gt;SUT&lt;/a&gt; without including my interface (.fsi) file! When you do this, every value declared in your source (.fs) file is exposed to the world for testing. Then, when I compile for release, I include the interface file and all of that stuff is hidden.&lt;br /&gt;&lt;br /&gt;Thus far, I've found no issues with NUnit working in this manner and it's given me the Best of Both Worlds as far as test coverage and CLS-friendly API's go!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-7953365933089883880?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/7953365933089883880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=7953365933089883880' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7953365933089883880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/7953365933089883880'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/09/easy-testing-in-f.html' title='Easy Testing in F#'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-4223133410080569449</id><published>2007-07-23T20:44:00.000-04:00</published><updated>2007-09-12T18:54:34.329-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='ironruby'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><title type='text'>IronRuby Tests</title><content type='html'>I'm sure there's a lot to be learned from the &lt;a href="http://www.iunknown.com/2007/07/a-first-look-at.html"&gt;IronRuby&lt;/a&gt; code base but one thing in particular stuck out in my mind: the test code is actually &lt;i&gt;good&lt;/i&gt; Ruby code.&lt;br /&gt;&lt;br /&gt;This was in stark contrast to the &lt;a href="http://code.google.com/p/rubydotnetcompiler/"&gt;Ruby.NET&lt;/a&gt; test code which looks more like LISP to me than Ruby. Don't get me wrong, there's a lot to impress the Ruby enthusiast in the Ruby.NET project especially since it has been moved to an open source contribution model.&lt;br /&gt;&lt;br /&gt;My point is simply that I have confidence that IronRuby will be true to the Ruby spirit. For one, they allow for Ruby-casing when calling .NET classes, e.g., &lt;span class="kword"&gt;Environment.user_name&lt;/span&gt; instead of &lt;span class="kword"&gt;Environment.UserName&lt;/span&gt;. For another, they've obviously been studying &lt;a href="http://rspec.rubyforge.org/index.html"&gt;RSpec&lt;/a&gt; (this is a &lt;i&gt;good&lt;/i&gt; thing!). This is the kind of code that I like to see behind anything that I use:&lt;br /&gt;&lt;pre class="code"&gt;describe &lt;span class="str"&gt;"range creation"&lt;/span&gt; do&lt;br /&gt;&lt;br /&gt; it &lt;span class="str"&gt;"creates an inclusive range object from integer literals"&lt;/span&gt; do&lt;br /&gt;    a = 0..1&lt;br /&gt;    a.class.name.should == &lt;span class="str"&gt;"Range"&lt;/span&gt;&lt;br /&gt;    a.begin.should == 0&lt;br /&gt;    a.end.should == 1&lt;br /&gt;    a.exclude_end?.should == false&lt;br /&gt; end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The IronRuby test suite would be a great model for the various Ruby specification projects that are out there. It's a from-the-ground-up, behavioral specification for any Ruby language implementation.&lt;br /&gt;&lt;br /&gt;It's an exciting time for Ruby programmers who have (or want) to use .NET!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-4223133410080569449?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/4223133410080569449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=4223133410080569449' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4223133410080569449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/4223133410080569449'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/07/ironruby-tests.html' title='IronRuby Tests'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-3633499119719924270</id><published>2007-07-23T20:41:00.000-04:00</published><updated>2007-07-23T21:16:01.631-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ironruby'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><title type='text'>IronRuby &amp; C# Express</title><content type='html'>Microsoft won my heart today by releasing &lt;a href="http://www.iunknown.com/2007/07/a-first-look-at.html"&gt;IronRuby&lt;/a&gt; and by announcing that it will indeed be taking outside contributions.&lt;br /&gt;&lt;br /&gt;As if this weren't enough, I was able to build the entire IronRuby project with C# Express Edition. This isn't something that can be done with the &lt;a href="http://code.google.com/p/rubydotnetcompiler/"&gt;Ruby.NET&lt;/a&gt; project.&lt;br /&gt;&lt;br /&gt;It's because of things like this that I've been spending less and less time in Linux lately...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-3633499119719924270?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/3633499119719924270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=3633499119719924270' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3633499119719924270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3633499119719924270'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/07/ironruby-c-express.html' title='IronRuby &amp; C# Express'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-3987707273207019730</id><published>2007-07-23T20:17:00.000-04:00</published><updated>2007-09-12T18:43:52.277-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='f#'/><title type='text'>FsUnit</title><content type='html'>I've really been getting into &lt;a href="http://research.microsoft.com/fsharp/fsharp.aspx"&gt;F#&lt;/a&gt; as of late. I &lt;i&gt;love&lt;/i&gt; not having to declare types everywhere. The syntax is almost as beautiful as Ruby. I've had no problems interoperating with any other .NET library. This latter point was a particular breath of fresh air; I don't, for example, like how IronPython handles interfaces.&lt;br /&gt;&lt;br /&gt;It's a struggle to learn functional programming concepts at the same as you learn a new language but that's why I chose F# in the first place. :) It's not that bad actually since with F# you can code in the same manner as you would in Visual Basic or C#. It really lets you ease into the whole functional thing...you never feel forced into something you're not ready for which is a danger when learning a purely functional language like Haskell (which I also like very much).&lt;br /&gt;&lt;br /&gt;So the first thing I learn in a new language is a good testing framework. I love me some &lt;a href="www.nunit.org"&gt;NUnit&lt;/a&gt; just as much as the next guy, but I prefer the syntax of &lt;a href="http://rspec.rubyforge.org/index.html"&gt;RSpec&lt;/a&gt;. I'm working on a happy medium in a project that I'm calling FsUnit. You can get it &lt;a href="http://code.google.com/p/fsunit/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;With FsUnit, you still write TestFixtures and Tests but you can write assertions like the following:&lt;br /&gt;&lt;pre class="code"&gt;1 |&gt; should equal 1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;or&lt;br /&gt;&lt;pre class="code"&gt;true |&gt; should be True&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Please try it out, send me ideas or corrections, and otherwise, enjoy yourself testing in F#! :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-3987707273207019730?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/3987707273207019730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=3987707273207019730' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3987707273207019730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/3987707273207019730'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/07/fsunit.html' title='FsUnit'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4585464309698708237.post-5100701377533019461</id><published>2007-02-02T10:11:00.000-05:00</published><updated>2007-09-12T18:52:46.325-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unit Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Mocks'/><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='ArcObjects'/><title type='text'>Mocking ArcObjects</title><content type='html'>I'm an avid test-driven developer but I'm also an ArcObjects programmer. Do you think this is an oxymoron? Read on!&lt;br /&gt;&lt;br /&gt;Yes, ArcObjects are very expensive to create. Yes, they are slow and consume a lot of infrastructure. But none of this matters. ESRI did test-driven developers a humongous favor when they took an interface-oriented approach to ArcObjects. By doing this, they enabled us to easily unit test our code.&lt;br /&gt;&lt;br /&gt;Suppose you are about to write a simple C# method like the following. How do we set up a test for it?&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;public static void&lt;/span&gt; EditFeature(IFeature feature, string fieldName, object value)&lt;br /&gt;{&lt;br /&gt;     feature.set_Value(feature.Fields.FindField(fieldName), value);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Simple enough, right? Wrong! To even get a IFeature, we have to create am IFeatureWorkspace and to get one of those we'll have to create an IWorkspaceFactory. If your setup is anything like mine, that'll take tens of seconds and even minutes. Local geodatabases would ease that pain but either way our test will not be a &lt;i&gt;unit&lt;/i&gt; test.&lt;br /&gt;&lt;br /&gt;Do not despair! There's a way to test our method without relying on anything external to that one line of code. There's a wonderful testing tool called mock objects and with them we can test that our ArcObjects code does exactly what we want it to do.&lt;br /&gt;&lt;br /&gt;You can go here if you want to learn more about mock objects. Today I'm just here to introduce you to a simple example of using mock objects to test ArcObjects code.&lt;br /&gt;&lt;br /&gt;My favorite mocking framework for .NET is Rhino Mocks. When we want to create mock objects using Rhino Mocks, our first step is usually to create a MockRepository:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;MockRepository&lt;/span&gt; mocks = new MockRepository();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The next thing that we need to is create our mock objects:&lt;br /&gt;&lt;pre class="code"&gt;&lt;span class="kwrd"&gt;IFeature&lt;/span&gt; mockFeature = mocks.CreateMock();&lt;br /&gt;&lt;span class="kwrd"&gt;IFields&lt;/span&gt; mockFields = mocks.CreateMock();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I'll explain why we need to create a mock IFields object in a second. Once you have your mock objects, you can start setting up your expectations. In Rhink Mocks, this works a bit like the record button on your...well, what has a record button these days? Take another look at the method that we're testing. We set the Value of an IFeature by giving it the index of the field that we want to change. This expectation is expressed like so:&lt;br /&gt;&lt;pre class="code"&gt;Expect.Call(mockFields.FindField("field")).Return(1);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This line tells our MockRepository to expect our code under test to call the FindField() method on the mockFields object. It also demands that the value passed in to the method has to bed "field". Finally, we return the value 1 when that method is called.&lt;br /&gt;&lt;br /&gt;Our next expectation is that the value returned by FindField() is used to set the value of the field. This expectation states that we expect the field at index 1 to be set to the value, "value":&lt;br /&gt;&lt;pre class="code"&gt;mockFeature.set_Value(1, "value");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The last thing that we need to do is to tell our mockFeature to return our mockFields whenever its Fields property is called:&lt;br /&gt;&lt;pre class="code"&gt;SetupResult.For(mockFeature.Fields).Return(mockFields);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That's it! Let's tell our Mock Repository that we're done setting up our expectations:&lt;br /&gt;&lt;pre class="code"&gt;mocks.ReplayAll();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We really just have one line of test code:&lt;br /&gt;&lt;pre class="code"&gt;EditFeature(mockFeature, "field", "value");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If we did all of this correctly, our test will pass and we have just written an ArcObject method test-first.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4585464309698708237-5100701377533019461?l=vernagus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vernagus.blogspot.com/feeds/5100701377533019461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4585464309698708237&amp;postID=5100701377533019461' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/5100701377533019461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4585464309698708237/posts/default/5100701377533019461'/><link rel='alternate' type='text/html' href='http://vernagus.blogspot.com/2007/02/mocking-arcobjects.html' title='Mocking ArcObjects'/><author><name>Ray Vernagus</name><uri>http://www.blogger.com/profile/12678750838556666846</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='26' src='http://farm1.static.flickr.com/134/378442593_9a1b1cdde6_m.jpg'/></author><thr:total>0</thr:total></entry></feed>
