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

<channel>
	<title>Mélange &#187; Technical</title>
	<atom:link href="http://pradeepc.net/blog/category/technical/feed/" rel="self" type="application/rss+xml" />
	<link>http://pradeepc.net/blog</link>
	<description>the colors of my life</description>
	<lastBuildDate>Wed, 11 Jan 2012 02:43:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ClickOnce Installation for Multiple Users</title>
		<link>http://pradeepc.net/blog/2010/04/02/clickonce-installation-for-multiple-users/</link>
		<comments>http://pradeepc.net/blog/2010/04/02/clickonce-installation-for-multiple-users/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 21:22:24 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Click Once]]></category>
		<category><![CDATA[ClickOnce]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=384</guid>
		<description><![CDATA[An interesting question came up in one of the internal mailing lists at work about ClickOnce. The person who asked the question had the following scenario for his ClickOnce application. The application runs in a call center. Assume there are &#8230; <a href="http://pradeepc.net/blog/2010/04/02/clickonce-installation-for-multiple-users/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>An interesting question came up in one of the internal mailing lists at work about ClickOnce. The person who asked the question had the following scenario for his ClickOnce application.</p>
<p>The application runs in a call center. Assume there are 100 users and 100 computers. Any user can use any machine on a given day. Assuming everyone uses a different machine each day for 100 days then each day they will have to install the application on the machine they are using and by the 100th day each machine will have 100 installations of the app. Clearly not a desirable situation.</p>
<p>How do we go about solving this ?</p>
<p>The quick answer is that you cannot solve it using ClickOnce in a straightforward manner. The reason ? ClickOnce installations are always per user. It is by design and not a side effect or even a configurable option. When you install a ClickOnce application it goes into C:\Users\&lt;User&gt;\AppData\Local\Apps\2.0\&lt;Blah&gt;. Here &lt;Blah&gt; is a set of folders with names that doesn&#8217;t make much sense. For example, here is an actual example of the full path to a ClickOnce installation &#8211; C:\Users\&lt;User&gt;\AppData\Local\Apps\2.0\8Y7PD2RC.9VE\L1OL139M.4W2. These names would be different on different machines. This makes it very hard to find the location of the installation, so we cannot share the installation between users (assuming that other users have access to this folder). Other users would not get desktop shortcuts and Start-&gt;Programs shortcuts. Also AppData is a hidden folder which makes it even harder to find for non-technical users.</p>
<p>So what do we do ?</p>
<p>For the specific scenario here, ClickOnce does not fit the bill as the deployment strategy. MSI is a better choice. XCopy might also work depending on the application requirements.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2010/04/02/clickonce-installation-for-multiple-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ladies and Gentlemen, this is *the* F# book !</title>
		<link>http://pradeepc.net/blog/2010/03/27/ladies-and-gentlemen-this-is-the-f-book/</link>
		<comments>http://pradeepc.net/blog/2010/03/27/ladies-and-gentlemen-this-is-the-f-book/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 04:22:17 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/?p=333</guid>
		<description><![CDATA[It has been a long time since I got excited about a programming book as much as I did with Programming F#. I have all the books on F# available in the market today. But I should say that this &#8230; <a href="http://pradeepc.net/blog/2010/03/27/ladies-and-gentlemen-this-is-the-f-book/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://pradeepc.net/blog/wp-content/uploads/2010/03/lrg.jpg"><img class="alignnone size-medium wp-image-355" title="Programming F# Front Cover" src="http://pradeepc.net/blog/wp-content/uploads/2010/03/lrg-228x300.jpg" alt="Programming F# Front Cover" width="228" height="300" /></a></p>
<p>It has been a long time since I got excited about a programming book as  much as I did with <a href="http://www.amazon.com/Programming-comprehensive-writing-complex-problems/dp/0596153643/" target="_blank">Programming F#</a>. I have all the books on F# available  in the market today. But I  should say that this is the best book for learning F# if you have no  experience with functional programming. I am not sure how this book  would be for a person who is totally new to programming (chances are  they would find this ahead of their curve). But for a person who has  good experience with imperative programming this book would get you up  and running with F# in specific and functional programming in general.</p>
<p>The book by Don Syme <a href="http://www.amazon.com/gp/product/1590598504/ref=cm_cr_asin_lnk">Expert  F# (Expert&#8217;s Voice in .Net)</a> (who invented F#) is also good but not  as good as Programming F# for new functional programmers. But once you  have read this book, Don Syme&#8217;s book might be a good follow up.</p>
<p>The strongest point of this book is the clarity with which concepts  are explained and the choice of good examples to explain a concept. They  are concise and to the point. It also made the book surprisingly small  (at a little less than 400 pages). But no worries, everything that you  need to get a firm footing in F# is in here.</p>
<p>This is truly a 5 star book. Highly recommended.</p>
<p>The table of contents:<br />
Part I. Multiparadigm Programming</p>
<p>Chapter 1. Introduction to F#<br />
Chapter 2. Fundamentals<br />
Chapter 3. Functional Programming<br />
Chapter 4. Imperative Programming<br />
Chapter 5. Object-Oriented Programming<br />
Chapter 6. .NET Programming<br />
Chapter 7. Applied Functional Programming<br />
Chapter 8. Applied Object-Oriented Programming</p>
<p>Part II. Programming F#</p>
<p>Chapter 9. Scripting<br />
Chapter 10. Computation Expressions<br />
Chapter 11. Asynchronous and Parallel Programming<br />
Chapter 12. Reflection<br />
Chapter 13. Quotations<br />
Appendix A. Overview of .NET Libraries<br />
Appendix B. F# Interop</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2010/03/27/ladies-and-gentlemen-this-is-the-f-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Functions in F# Part 2</title>
		<link>http://pradeepc.net/blog/2009/12/24/functions-in-f-part-2/</link>
		<comments>http://pradeepc.net/blog/2009/12/24/functions-in-f-part-2/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 22:28:18 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/24/functions-in-f-part-2/</guid>
		<description><![CDATA[I had written a post on Functions in F# a couple of days ago and Binil posted a comment which prompted me to post a follow up to add some information that I left out in the original post. F# &#8230; <a href="http://pradeepc.net/blog/2009/12/24/functions-in-f-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had written <a href="http://pradeepc.net/blog/2009/12/21/functions-in-f/">a post on Functions in F#</a> a couple of days ago and <a href="http://binil.wordpress.com/">Binil</a> posted a comment which prompted me to post a follow up to add some information that I left out in the original post.</p>
<p><strong><font color="#3c3cff" size="2">F# Syntax</font></strong></p>
<p>F# has two syntax forms available – a lightweight syntax and a verbose syntax. The lightweight syntax uses indentation to mark the beginning and end of code blocks. This naturally results in more concise code. The verbose syntax uses additional keywords to demarcate code blocks making the code lengthier than it needs to be but it makes the code less sensitive to indentation (imagine copy-pasting and sending code in email etc).</p>
<p>The lightweight syntax is on by default. You can explicitly set it to on by using</p>
<p>#light </p>
<p>The verbose syntax is always on which means you can still use the verbose keywords even if the lightweight syntax is on.&#160; We can enforce the verbose syntax by switching off the lightweight syntax as follows</p>
<p>#light “off”</p>
<p>The lightweight syntax is in more prominent use than the verbose syntax and it seems that going forward the verbose syntax might be obsolete.</p>
<p>Only spaces can be used for indentation in F#, TABs are not accepted. Visual Studio by default converts TABs to spaces. This can be set in Tools –&gt; Options dialog under Text Editor –&gt; F# –&gt; Tabs.</p>
<p><a href="http://pradeepc.net/blog/wp-content/uploads/2009/12/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://pradeepc.net/blog/wp-content/uploads/2009/12/image_thumb2.png" width="753" height="444" /></a> </p>
<p>&#160;</p>
<p><strong><font color="#3c3cff" size="2">Tail Recursion</font></strong></p>
<p>I had mentioned about recursive functions in my <a href="http://pradeepc.net/blog/2009/12/21/functions-in-f/">previous post on Functions in F#</a> but I did not mention anything about tail recursion. Given the importance of recursion in F#, this is a very important topic and I want to thank <a href="http://binil.wordpress.com/">Binil</a> for bringing it to my notice.</p>
<p>First, let me provide some background info on what is bad about recursive functions and why tail recursion is the preferred way to write recursive functions.</p>
<p>When is function needs to be executed, a block of memory is allocated on the system stack for the function and is called a stack frame. When the function completes execution, this memory is reclaimed and is called unwinding the stack. </p>
<p>Recursive functions call themselves repeatedly until an exit condition is met. This means that a new stack frame has to be created each time the recursive call is made. Given enough nested function calls there wouldn’t be any more space on the system stack and would cause an undesirable condition called stack overflow. The program execution is terminated forcefully by the runtime.</p>
<p>If the function calls are not recursive, for example calling a function 1000 times in a for loop, the memory block for a function can be reclaimed when the function execution is over. So what we need to try to achieve is to write the function in such a way that the stack frame of the calling function need not be maintained while execution proceeds to the next function call. The way to do this is to make the recursive call as the last statement in the function. When we do that the compiler produces different code which allows the stack frame of the calling function to be unwound and the memory reclaimed, in effect making it similar to calling the function in a loop. This technique is called tail recursion.</p>
<p>Let us look at some code to make this more clear. Here is the recursive implementation of factorial that I wrote in my <a href="http://pradeepc.net/blog/2009/12/21/functions-in-f/">previous blog post</a>.</p>
<pre class="code"><span style="color: blue">let rec </span>factorial x=
    <span style="color: blue">if </span>x &lt;= <span style="color: brown">1 </span><span style="color: blue">then
        </span><span style="color: brown">1
    </span><span style="color: blue">else
        </span>x * factorial (x-<span style="color: brown">1</span>)</pre>
<p>Here it might look as if the recursive call is the last statement in the function, but it is not. It would become clear if we wrote it this way:</p>
<pre class="code"><span style="color: blue">let rec </span>factorial x=
    <span style="color: blue">if </span>x &lt;= <span style="color: brown">1 </span><span style="color: blue">then
        </span><span style="color: brown">1
    </span><span style="color: blue">else
        let </span>product = x * factorial (x-<span style="color: brown">1</span>)
        product</pre>
<p>Now it becomes clear that the last statement in the function is returning the value of product. We also see that the function has to maintain the value of x in its stack frame and multiply it with the value returned by the recursive call. So if the function is written as shown above, there is no way to reclaim the stack memory until the chain of recursive calls return. So let us re-write the function in using tail recursion.</p>
<pre class="code"><span style="color: blue">let </span>factorial x =
    <span style="color: blue">let rec </span>tailRecFactorial x prod =
        <span style="color: blue">if </span>x &lt;= <span style="color: brown">1 </span><span style="color: blue">then
            </span>prod
        <span style="color: blue">else
            </span>tailRecFactorial (x-<span style="color: brown">1</span>) (prod * x)
    tailRecFactorial x <span style="color: brown">1
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>Here we have a nested function which takes the product up to the current stage as a parameter which means nothing needs to be stored on the stack of the calling function. The stack frame can be safely reclaimed. The compiler is able to spot the tail recursive calls and generates code as if the function was called in a loop. Execution returns the original calling point when the exit condition is met.</p>
<p>The method I showed above to achieve tail recursion is called accumulator pattern. Another way is to use <a href="http://fsharpcode.blogspot.com/2009/12/f-continuation-monad.html">Continuations</a>. </p>
<p><strong><font color="#3c3cff" size="2">Trivia</font></strong></p>
<p>When I was writing the non tail recursive factorial function, by mistake I wrote it this way:</p>
<pre class="code"><span style="color: blue">let rec </span>factorial x =
    <span style="color: blue">if </span>x &lt;= <span style="color: brown">1 </span><span style="color: blue">then
        </span><span style="color: brown">1
    </span><span style="color: blue">else
    </span>x * (factorial x-<span style="color: brown">1</span>)</pre>
<p>&#160;</p>
<p>Can you spot the problem ? </p>
<p>Hint: It causes a <a href="http://msdn.microsoft.com/en-us/library/system.stackoverflowexception.aspx">StackOverflowException</a> when executed.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/12/24/functions-in-f-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Plans for 2010 Part 2</title>
		<link>http://pradeepc.net/blog/2009/12/21/plans-for-2010-part-2/</link>
		<comments>http://pradeepc.net/blog/2009/12/21/plans-for-2010-part-2/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 20:59:29 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[Diet]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Atkins]]></category>
		<category><![CDATA[Chris Smith]]></category>
		<category><![CDATA[Don Syme]]></category>
		<category><![CDATA[New year resolution]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/plans-for-2010-part-2/</guid>
		<description><![CDATA[As I have posted here, I have made some resolutions for the new year. If nothing, just for the fun. I have to add two more things to the list. Learning F# and Reducing my weight. I have been trying &#8230; <a href="http://pradeepc.net/blog/2009/12/21/plans-for-2010-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As I have posted <a href="http://pradeepc.net/blog/2009/12/16/plans-for-2010/">here</a>, I have made some <a href="http://en.wikipedia.org/wiki/New_Year%27s_resolution">resolutions for the new year</a>. If nothing, just for the fun. I have to add two more things to the list.</p>
<ul>
<li>Learning F# and</li>
<li>Reducing my weight.</li>
</ul>
<p>I have been trying to learn F# for over a year now (maybe even a little more). I have all the F# books in print now as well as the PDF for the upcoming Manning MEAP – <a href="http://www.amazon.com/Functional-Programming-Real-World-Examples/dp/1933988924/">Functional Programming for the Real World</a>. But they been collecting dust on my shelf. Functional programming requires a new mindset and hence requires a little more effort for me than studying a new imperative language. The first book that I bought is <a href="http://www.amazon.com/Expert-F-Experts-Voice-Net/dp/1590598504/">Expert F#</a> which is definitely the wrong book for a beginner. It is written by <a href="http://blogs.msdn.com/dsyme/">Don Syme</a> et.al. who is the primary designer of the language and is a little dense. It is a good book with a lot of information but it is just not good for somebody new to functional programming. Once you have grasped the main ideas behind functional programming, it is a good book to have. The <a href="http://www.amazon.com/Programming-Definitive-Guide-Don-Syme/dp/1430224312/">second edition of this book</a> is coming up soon.</p>
<p>The game changer for me was <a href="http://www.amazon.com/Programming-Animal-Guide-Chris-Smith/dp/0596153643/">Programming F#</a> by <a href="http://blogs.msdn.com/chrsmith/">Chris Smith</a> which, IMHO, is the best book out there today to learn F#. It is a surprisingly small book and is written with such clarity that even somebody with absolutely no exposure to functional programming languages would be able to learn from it. It makes the ideas accessible and has some brilliant examples to showcase some of the features of F#. It kind of feels like an easy-going friend, which is exactly what you need when exploring unfamiliar grounds. I was so impressed with the book that I wrote a <a href="http://www.amazon.com/review/R1DCW9XUQ9HUUQ/">review of the book</a> on Amazon giving it 5 stars.</p>
<p>I am not entirely comfortable with F# yet. But I have my feet wet and I plan to make the plunge in 2010.</p>
<p>Another thing that I want to tackle in 2010 is my weight (and fat). I am 190 lbs now. I used to be something like 175 lbs 3 years ago when I came to USA. 15 lbs in 3 years ! I am definitely worried about this. So is my wife. I had taken diets <a href="http://pradeepc.net/blog/2008/10/04/lean-mean/">a couple</a> of times <a href="http://pradeepc.net/blog/2004/12/13/losing/">previously</a> and had always managed to reduce weight. But it always came back with a vengeance. So I am not sure whether another diet is the solution. Being on a diet is one of the most worst experiences that I have been through. Food is always on your mind and you can’t eat it. You are constantly fighting the sugar craving (I was on a <a href="http://atkins.com/">low-carb diet</a>). It is hell. </p>
<p>Although I haven’t made any specific plans, I think I would concentrate more on exercise and less on diet this time. Let us see how it goes.</p>
<p>Happy Holidays !</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/12/21/plans-for-2010-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Functions in F#</title>
		<link>http://pradeepc.net/blog/2009/12/21/functions-in-f/</link>
		<comments>http://pradeepc.net/blog/2009/12/21/functions-in-f/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 11:06:28 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/12/21/functions-in-f/</guid>
		<description><![CDATA[Wikipedia says that …functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions… The point I wish to make here is that functions &#8230; <a href="http://pradeepc.net/blog/2009/12/21/functions-in-f/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wikipedia says that</p>
<blockquote><p>…functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions…</p>
</blockquote>
<p>The point I wish to make here is that functions are the&#160; most important “things” in a functional programming language. You can say that functions are “first class citizens” in a functional programming language. This means that functions can be passed around as parameters and return values of other functions, just like any other data. Functions which can take other functions as parameters and/or return values are called Higher-Order Functions.</p>
<p><strong><font color="#3737ff" size="2">Functions and Type Inference</font></strong></p>
<p>Here is an example of a simple function in F#.</p>
<blockquote><p>let triple x = 3 * x</p>
</blockquote>
<p>Here triple is the name of the function and x is the name of the parameter passed to the function. Contrary to C# naming convention for function, F# uses camel casing. Even though we have not specified any type information, the compiler is able to infer that this function takes an integer as parameter and returns an integer. This is called Type Inference and makes your F# program more concise. </p>
<p>How did I know that the compiler inferred the parameter and return value as int? I typed in the above functional declaration in F# interactive and terminated it with ;; and hit Enter. F# showed me:</p>
<blockquote><p>val triple : int –&gt; int</p>
</blockquote>
<p>This means that triple is a function which takes an integer as parameter and returns an integer. If we try to call the function with a float as parameter</p>
<blockquote><p>triple 3.0</p>
</blockquote>
<p>it will spit out an error message as follows.</p>
<blockquote><p>stdin(4,8): error FS0001: This expression was expected to have type      <br />&#160;&#160;&#160; int&#160;&#160;&#160; <br />but here has type       <br />&#160;&#160;&#160; float&#160;&#160;&#160; </p>
</blockquote>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>We know that * (multiplication operator) works with floats as well, so why this error ? The reason for this is that in the absence of any additional type information the compiler simply defaulted the type to integer. So triple is a function which can take an integer as parameter and return an integer which is equal to three times its input. It is equivalent to the following C# function.</p>
<pre class="code"><span style="color: blue">static int </span>Triple(<span style="color: blue">int </span>x)
{
      <span style="color: blue">return </span><span style="color: brown">3 </span>* x;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Since the function expects integer, a parameter of type float will produce an error.</p>
<p>So what do we do when we need a datatype other than the default type that the compiler is able to infer? We give a hint to the compiler via type annotation.</p>
<blockquote>
<p>let triple (x: float) = 3.0f * x</p>
</blockquote>
<blockquote>
<p>Note: In the above example type annotation is not strictly required because the compiler would infer x as float because 3.0f is float. But it does show you how to annotate a function parameter with its type.</p>
</blockquote>
<p>&#160;</p>
<p><strong><font color="#4a4aff" size="2">Higher Order Functions</font></strong></p>
<p>The functions mentioned above are not a higher-order functions because they do not take a function as parameter, neither do they return one. List.map and List.filter are examples of higher order functions. List.map takes a function and applies it to each item in the list (also passed as parameter to it) and returns a new list with the output values. List.filter takes a function and list as parameters and returns a new list. The output list contains those values from the input list for which the input function returned true. An example is shown below which makes use of both these higher order functions.</p>
<pre class="code"><span style="color: blue">let </span>triple x =
    <span style="color: brown">3 </span>* x

<span style="color: blue">let </span>isEven x =
    x % <span style="color: brown">2 </span>= <span style="color: brown">0

</span><span style="color: blue">let </span>actOnEven action numbers=
    List.map action (List.filter isEven numbers)

[&lt;EntryPoint&gt;]
<span style="color: blue">let </span>main(args:string[]) =
    <span style="color: blue">let </span>results = (actOnEven triple [<span style="color: brown">1 </span>.. <span style="color: brown">10</span>])
    Console.WriteLine (results)
    <span style="color: brown">0</span></pre>
<p>Here actOnEven is itself a higher order function.</p>
<p><strong><font color="#5555ff" size="2">Recursive Functions</font></strong></p>
<p>Recursive functions are functions that call themselves. An important tenet of functional programming is the use of recursion instead of looping. We can create recursive functions using the following syntax.</p>
<pre class="code"><span style="color: blue">let rec </span>factorial num =
    <span style="color: blue">if</span>( num &lt;= <span style="color: brown">1</span>) <span style="color: blue">then
        </span><span style="color: brown">1
    </span><span style="color: blue">else
        </span>num * factorial (num - <span style="color: brown">1</span>)</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The <strong>rec</strong> keyword is a helping hand to the compiler for type inference. Personally, I don’t like it but I think they couldn’t find a way around it.</p>
<p><strong><font color="#3c3cff" size="2">Function Currying</font></strong></p>
<p>Currying (named after <a href="http://en.wikipedia.org/wiki/Haskell_Curry" target="_blank">Haskell Brooks Curry</a>) is an interesting technique in which you pass one of the arguments to a function and it returns another function which takes the rest of the arguments. For eg., consider the function</p>
<p>let add x y = x + y</p>
<p>If you run this in F# interactive, you will see the following message:</p>
<p>val add : int -&gt; int –&gt; int</p>
<p>This means that add is a function which takes an integer and returns a function which takes another integer as parameter and returns an integer. So if we call add with just one parameter, it will return another function which takes the second parameter.</p>
<p>let addToTwo = (add 2)</p>
<p>To be clear, addToTwo is a function that takes one integer parameter and returns an integer.</p>
<p>For eg, </p>
<p>addToTwo 8</p>
<p>will return 10.</p>
<p>Here addToTwo is the curried function and this technique is called function currying. Although this may look like a strange and useless language feature, it has interesting and powerful applications in functional programming (like the pipe forward operator). I will write more about this in future blog posts.</p>
<p><strong><font color="#3333ff" size="2">Nested Functions</font></strong></p>
<p>In F#, a function can contain another function. Here is a simple example.</p>
<pre class="code"><span style="color: blue">let </span>printList numbers=
    <span style="color: blue">let </span>print num=
        printfn <span style="color: maroon">&quot;%i&quot; </span>num
    List.map print numbers</pre>
<p>Here print is a function nested in printList.</p>
<p>Some of the feature that I have mentioned here would be new to C# programmers and might feel a little strange. But have hope, for all will become more clear with time. We need to see some solid examples to appreciate the power of some of them. I have mostly presented useless examples but I hope a reader would have gleaned atleast a little information about functions and its usage in F# from this post. There is more to write but it is getting late (3 am) and tomorrow is a working day, so I gotta go. Will be back with more on F#.</p>
<p>References:</p>
<p><a href="http://www.amazon.com/Programming-Animal-Guide-Chris-Smith/dp/0596153643/">Programming F#</a></p>
<p><a href="http://www.amazon.com/Expert-F-Experts-Voice-Net/dp/1590598504/">Expert F#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/12/21/functions-in-f/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to post source code on your blog</title>
		<link>http://pradeepc.net/blog/2009/11/06/how-to-post-source-code-in-your-blog/</link>
		<comments>http://pradeepc.net/blog/2009/11/06/how-to-post-source-code-in-your-blog/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 21:59:14 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/11/06/how-to-post-source-code-in-your-blog/</guid>
		<description><![CDATA[For a long time I have been looking for a tool to help me post source code on my blog. Obviously many people had solved this because we have all seen well formatted source code on many blogs. I did &#8230; <a href="http://pradeepc.net/blog/2009/11/06/how-to-post-source-code-in-your-blog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For a long time I have been looking for a tool to help me post source code on my blog. Obviously many people had solved this because we have all seen well formatted source code on many blogs. I did try several solutions including <a href="http://pleasemakeanote.blogspot.com/2008/06/posting-source-code-in-blogger.html" target="_blank">Syntax Highlighter</a>, <a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2007/03/02/Formatting-source-code-in-a-blog-post-.aspx" target="_blank">Copy Source as Html</a>, <a href="http://manoli.net/csharpformat/" target="_blank">C# code format from Manoli</a> and even tried posting screen shots of the code (got this idea from <a href="http://joshsmithonwpf.wordpress.com/" target="_blank">Josh Smith’s blog</a>). They didn’t work well for me (as you can see from several postings it did work for others, it is just a matter of personal taste). The screen shot idea is a good one except for the fact that the readers cannot copy the source from your blog and search engines cannot index the code. I had a workaround for this by linking to a text file which contained the source code. This made the process all mucky and cumbersome.</p>
<p>Some time in the recent past I stumbled on <a href="http://download.live.com/writer" target="_blank">Live Writer</a>. It was quite nifty and did a pretty good job with identifying your blog engine and templates and previewing your post. But when you copy pasted code from Visual Studio, it was not so pretty. Thankfully Douglas Stockwell had written <a href="http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9&amp;bt=9&amp;pl=8" target="_blank">a plugin for Live Writer</a> to paste your code from Visual Studio. Together they did an amazing job in formatting source code as you can see below:</p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Windows.Forms;
<span style="color: blue">using </span>System.Security.Principal;
<span style="color: blue">using </span>System.ServiceModel;

<span style="color: blue">namespace </span>WindowsFormsApplication1
{
    <span style="color: blue">static class </span><span style="color: #2b91af">Program
    </span>{
        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">The main entry point for the application.
        </span><span style="color: gray">/// &lt;/summary&gt;
        </span>[<span style="color: #2b91af">STAThread</span>]
        <span style="color: blue">static void </span>Main()
        {
            <span style="color: #2b91af">Application</span>.EnableVisualStyles();
            <span style="color: #2b91af">Application</span>.SetCompatibleTextRenderingDefault(<span style="color: blue">false</span>);
            <span style="color: #2b91af">Application</span>.Run(<span style="color: blue">new </span><span style="color: #2b91af">Form1</span>());
        }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Happy blogging.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/11/06/how-to-post-source-code-in-your-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why we should be testing the release build and not the debug build</title>
		<link>http://pradeepc.net/blog/2009/11/06/why-we-should-be-testing-the-release-build-and-not-the-debug-build/</link>
		<comments>http://pradeepc.net/blog/2009/11/06/why-we-should-be-testing-the-release-build-and-not-the-debug-build/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 21:20:05 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/11/06/why-we-should-be-testing-the-release-build-and-not-the-debug-build/</guid>
		<description><![CDATA[If we are deploying the release build of an application, you should be testing the release build of the application. While it doesn’t sound like a big deal, subtle errors arising from the compiler optimizations can bite you in production. &#8230; <a href="http://pradeepc.net/blog/2009/11/06/why-we-should-be-testing-the-release-build-and-not-the-debug-build/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If we are deploying the release build of an application, you should be testing the release build of the application. While it doesn’t sound like a big deal, subtle errors arising from the compiler optimizations can bite you in production. Here is an example of it.</p>
<p>As I mentioned in <a href="http://pradeepc.net/blog/2009/11/04/getting-access-denied-errors-in-your-wcf-service-or-asp-net-application/" target="_blank">a previous post</a>, one of solutions for the access denied issue was to pre-load the assemblies in the Global.asax Application_Start event handler. For preloading a specific assembly (lets call it foo.dll) I did something like this:</p>
<p>MyNamespace.MyClass.Equals(null, null);</p>
<p>Things worked fine in the debug build, but in the release build we were getting Access denied for the foo.dll assembly. It was a little weird because all the other assemblies were getting loaded as network service and they all succeeded. Foo.dll was getting loaded under the identity of the user and was failing. I decompiled the foo.dll using <a href="http://www.red-gate.com/products/reflector/" target="_blank">Reflector</a> (can’t say how many times this nifty little tool saved the day) and found that the code was optimized by the compiler to this:</p>
<p>object.Equals(null, null);</p>
<p>It does make sense. In hindsight.</p>
<p>We tested the solution in debug build where there was no optimization and everything worked as expected.</p>
<p>So my advice is – if you are deploying the release build of an application, you should be testing the release build of the application.</p>
<p>P.S. – There was an interesting discussion in the MSDN forums a couple of years ago which displayed a similar problem. I will blog about it later, for a little while it got me real frightened about my understanding of the .net platform.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/11/06/why-we-should-be-testing-the-release-build-and-not-the-debug-build/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Access Denied Errors in your WCF service or ASP.NET application ?</title>
		<link>http://pradeepc.net/blog/2009/11/04/getting-access-denied-errors-in-your-wcf-service-or-asp-net-application/</link>
		<comments>http://pradeepc.net/blog/2009/11/04/getting-access-denied-errors-in-your-wcf-service-or-asp-net-application/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 03:04:39 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/11/04/getting-access-denied-errors-in-your-wcf-service-or-asp-net-application/</guid>
		<description><![CDATA[We are using impersonation in our WCF Service so that credentials of the user can flow to the backend layer (where authorization is done). Strangely we were getting Access Denied errors when the client tries to connect to the service. &#8230; <a href="http://pradeepc.net/blog/2009/11/04/getting-access-denied-errors-in-your-wcf-service-or-asp-net-application/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We are using impersonation in our WCF Service so that credentials of the user can flow to the backend layer (where authorization is done). Strangely we were getting Access Denied errors when the client tries to connect to the service. The error message was like:</p>
<p><font color="#ff0000">Could not load file or assembly &#8216;MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&#8217; or one of its dependencies. Access is denied.</font></p>
<p><font color="#000000">This was very frustrating to say the least. The first thing to do was search the internet with the error message and sure enough, several other people had faced the same issue but nobody had a good solution for the problem. The problem was that the code was running under the identity of the user (because we were using impersonation) and when the assemblies were shadow copied to the “Temporary ASP.NET Files” directory (C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files), the user did not have write permissions to that directory and hence the Access denied error.</font></p>
<p><em><font color="#000000">Note: I should say that the Fusion Log Viewer was extremely helpful in identifying the problem and helping to make sure that the problem was resolved.</font></em></p>
<p>The obvious solution is to give users write permission to that folder. The testing team decided that this could a potential security issue (even though this was an internal application and permissions were given only to authenticated users). So we began hunting for other solutions and came up with more solutions.</p>
<ul>
<li>Run aspnet_regiis –ga “authenticated users”. </li>
</ul>
<p>This seemed to fix the problem, but it turned out that it was just a variation of granting authenticated users permission to the Temporary ASP.NET Files folder. What this command does is add the user/user-group to the IIS_USRS groups which is already set to have modify permissions on the Temporary ASP.NET Files folder. It works, but we are back to square one.</p>
<ul>
<li>Disable Shadow copying of assemblies </li>
</ul>
<p>As I mentioned earlier, the problem was occurring while shadow copying the assemblies to the temp location. The primary purpose of shadow copying is to do dynamic compilation and hot-swapping files. Dynamic compilation does not apply to WCF as much as for ASP.NET. Also we were not very concerned about the hot-swapping of files, so this was a credible option for us. But what concerned us was that we couldn’t find any info about any other side effects of disabling shadow copying. To disable shadow copy, add the following in your web.config inside the configuration section.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;
    </span><span style="color: blue">&lt;</span><span style="color: #a31515">hostingEnvironment </span><span style="color: red">shadowCopyBinAssemblies</span><span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue">/&gt;
&lt;/</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;</span></pre>
<p>The good thing about this option is that it does not require a code change and is easy to revert and also there doesn’t appear to be any security issues.</p>
<ul>
<li>Move impersonation to the end of the call stack </li>
</ul>
<p>Since the problem occurs because the assembly loading happens in the identity of the user, we could do away with declarative impersonation and do an imperative style impersonation where impersonation is done only when making calls to the backend system. To make it more clear, we were doing impersonation like:</p>
<pre class="code">[<span style="color: #2b91af">OperationBehavior</span>(Impersonation = <span style="color: #2b91af">ImpersonationOption</span>.Required)]
<span style="color: blue">public </span><span style="color: #2b91af">Response </span>DoSomething(<span style="color: #2b91af">Request </span>request)
{
<span style="color: blue">        return </span>request.Execute();
}</pre>
<pre class="code">Instead we could do impersonation only while calling the backend code:</pre>
<pre class="code"><span style="color: #2b91af">WindowsIdentity </span>callerWindowsIdentity = <span style="color: #2b91af">ServiceSecurityContext</span>.Current.WindowsIdentity;
<span style="color: blue">if </span>(callerWindowsIdentity == <span style="color: blue">null</span>)
{
    <span style="color: blue">throw new </span><span style="color: #2b91af">InvalidOperationException</span>(<span style="color: #a31515">&quot;The caller cannot be mapped to a WindowsIdentity&quot;</span>);
}

<span style="color: blue">using </span>(callerWindowsIdentity.Impersonate())
{
    <span style="color: green">// Make backend calls
</span>} </pre>
<ul><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></ul>
<p>This is definitely a good solution, but has atleast two drawbacks. The first problem (not a big one) is that it requires a code change. The second problem is a performance one and happens only if the backend calls are webservice calls. The reason for this is that the webservice calls usually require a XmlSerializers dll which is generated by Visual Studio and usually deployed along with the application. If this assembly is not present, the runtime will create one dynamically. This can cause a perf hit. Since we do impersonation before making the backend call, the XmlSerializer assembly is loaded in the identity of the user and will fail. But the CLR, failing to bind the assembly, will synthesize one for you thus causing a perf hit.</p>
<p>If your backend calls are not webservice calls, then this is a reasonable workaround for you.</p>
<ul>
<li>Pre-load the assemblies </li>
</ul>
<p>What we understood from the Fusion Logs was that the assembly loading was happening under the identity of the end user who does not have adequate permissions. So one thing we can do is to pre-load the assemblies when the service is running as the network service account. To do this, we created a Global.asax file and in the Application_Start event handler, we refer to types in all the assemblies of the service, thus forcing them to be loaded even before the first request is processed. The code looks something like this:</p>
<pre class="code"><span style="color: blue">namespace </span>MyService
{
    <span style="color: blue">public class </span><span style="color: #2b91af">Global </span>: System.Web.<span style="color: #2b91af">HttpApplication
    </span>{

        <span style="color: blue">protected void </span>Application_Start(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
        {
            <span style="color: green">//Make sure all the dlls are loaded
            </span><span style="color: #2b91af">Action </span>action = <span style="color: blue">new </span><span style="color: #2b91af">Action</span>(<span style="color: blue">null</span>);</pre>
<pre class="code">            EntityOperations.<span style="color: #2b91af">EntityOperationsFactory</span>.CreateOperation();</pre>
<pre class="code">            DataAccess.<span style="color: #2b91af">DaoFactory</span>.CreateDao(); </pre>
<pre class="code">            WebServiceLibrary.<span style="color: #2b91af">WebServiceGateway</span>.Initialize(<span style="color: blue">null</span>);
        }</pre>
<pre class="code">     }</pre>
<pre class="code">}</pre>
<p>Using the Fusion Logs we were able to see that the assemblies were getting loaded under the identity of the network service account. We could also see that the XmlSerializers were also getting loaded correctly. </p>
<p>This solution might feel a little icky because of its unconventional nature but I think it is a brilliant solution and it seems to work correctly. We have decided to adopt this solution for our project. </p>
<ul>
<li>Change the shadow copy directory to a directory inside the website directory</li>
</ul>
<p>Frankly I never tried this one out and don’t know if it works, but it is worth some investigation if none of the solutions outlined above works for you.</p>
<p>I will make a follow up post or edit this one, if I find problems with the solutions mentioned here or if I find better solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/11/04/getting-access-denied-errors-in-your-wcf-service-or-asp-net-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Adding a desktop shortcut using Wix</title>
		<link>http://pradeepc.net/blog/2009/11/04/adding-a-desktop-shortcut-using-wix/</link>
		<comments>http://pradeepc.net/blog/2009/11/04/adding-a-desktop-shortcut-using-wix/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 00:01:32 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/11/04/adding-a-desktop-shortcut-using-wix/</guid>
		<description><![CDATA[Creating installers is a pain in the ass. We had to move from ClickOnce to MSI (for reasons bizarre) and we chose Wix (it was easy considering the fact that there was only one option to chose from). While Wix &#8230; <a href="http://pradeepc.net/blog/2009/11/04/adding-a-desktop-shortcut-using-wix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Creating installers is a pain in the ass. </p>
<p>We had to move from ClickOnce to MSI (for reasons bizarre) and we chose Wix (it was easy considering the fact that there was only one option to chose from). </p>
<p>While Wix doesn&#8217;t help much in easing the pain (and in some ways it makes things worse), it sure does help in automating the creation of your MSI. While I would like to see a much simpler, automate-able solution for creating MSIs, if you need to do something <strong><em>today</em></strong> Wix is the way to go. Wix is a little complex and unintuitive to use (maybe because of the nature of the underlying technology &#8211; MSI). Whatever the reason, I found that creating shortcuts is not as straight forward as one would expect it to be. I would expect to set some attribute to true (like in ClickOnce) and be done with it, but it was not so. Hence this blog post.</p>
<p>The following steps are for creating desktop shortcuts, it differs for creating shortcuts in the Start-&gt;Programs list. </p>
<p>First, you need to add the following line</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">DesktopFolder</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">Desktop</span>&quot;<span style="color: blue">/&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Then add a shortcut node under the File node corresponding to the file for which you want the shortcut.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">File </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">StartupExecutable</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.<span style="color: blue">StartupExecutable</span>.TargetFileName)</span>&quot; <span style="color: red">Source</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.<span style="color: blue">StartupExecutable</span>.TargetPath)</span>&quot; <span style="color: red">DiskId</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot; <span style="color: red">KeyPath</span><span style="color: blue">=</span>&quot;<span style="color: blue">yes</span>&quot;<span style="color: blue">&gt;
               &lt;</span><span style="color: #a31515">Shortcut </span><span style="color: red">Advertise</span><span style="color: blue">=</span>&quot;<span style="color: blue">yes</span>&quot;
                         <span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">MyProductDesktopShortcut</span>&quot;
                         <span style="color: red">Directory</span><span style="color: blue">=</span>&quot;<span style="color: blue">DesktopFolder</span>&quot;
                         <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">Name of desktop shortcut</span>&quot;
                         <span style="color: red">WorkingDirectory</span><span style="color: blue">=</span>&quot;<span style="color: blue">INSTALLLOCATION</span>&quot;
                         <span style="color: red">Description</span><span style="color: blue">=</span>&quot;<span style="color: blue">Some description</span>&quot;
                         <span style="color: red">Icon</span><span style="color: blue">=</span>&quot;<span style="color: blue">Icon.exe</span>&quot;<span style="color: blue">&gt;
                 &lt;</span><span style="color: #a31515">Icon </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">Icon.exe</span>&quot; <span style="color: red">SourceFile</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.<span style="color: blue">StartupExecutable</span>.TargetPath)</span>&quot; <span style="color: blue">/&gt;
               &lt;/</span><span style="color: #a31515">Shortcut</span><span style="color: blue">&gt;
             &lt;/</span><span style="color: #a31515">File</span><span style="color: blue">&gt;</span></pre>
<p>To give a perspective, the whole thing should look like this:</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">TARGETDIR</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">SourceDir</span>&quot;<span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">DesktopFolder</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">Desktop</span>&quot;<span style="color: blue">/&gt;
      &lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">ProgramMenuFolder</span>&quot;<span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">ApplicationProgramsFolder</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">My Company Name</span>&quot;<span style="color: blue">/&gt;
      &lt;/</span><span style="color: #a31515">Directory</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">ProgramFilesFolder</span>&quot;<span style="color: blue">&gt;
        &lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">MyCompanyFolder</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">My Company Name</span>&quot;<span style="color: blue">&gt;
          &lt;</span><span style="color: #a31515">Directory </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">INSTALLLOCATION</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">My Product Name</span>&quot;<span style="color: blue">&gt;
</span><span style="color: blue">            &lt;</span><span style="color: #a31515">Component </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">MyComponent</span>&quot; <span style="color: red">Guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">1c4ba634-0428-4bcd-ad46-c7cf232e007b</span>&quot;<span style="color: blue">&gt;
              &lt;!-- </span><span style="color: green">Add our project output dll's </span><span style="color: blue">--&gt;
              &lt;</span><span style="color: #a31515">File </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">StartupExecutable</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.<span style="color: blue">StartupExecutable</span>.TargetFileName)</span>&quot; <span style="color: red">Source</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.<span style="color: blue">StartupExecutable</span>.TargetPath)</span>&quot; <span style="color: red">DiskId</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot; <span style="color: red">KeyPath</span><span style="color: blue">=</span>&quot;<span style="color: blue">yes</span>&quot;<span style="color: blue">&gt;
                &lt;</span><span style="color: #a31515">Shortcut </span><span style="color: red">Advertise</span><span style="color: blue">=</span>&quot;<span style="color: blue">yes</span>&quot;
                          <span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">MyProductDesktopShortcut</span>&quot;
                          <span style="color: red">Directory</span><span style="color: blue">=</span>&quot;<span style="color: blue">DesktopFolder</span>&quot;
                          <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">Name of desktop shortcut</span>&quot;
                          <span style="color: red">WorkingDirectory</span><span style="color: blue">=</span>&quot;<span style="color: blue">INSTALLLOCATION</span>&quot;
                          <span style="color: red">Description</span><span style="color: blue">=</span>&quot;<span style="color: blue">Some description</span>&quot;
                          <span style="color: red">Icon</span><span style="color: blue">=</span>&quot;<span style="color: blue">Icon.exe</span>&quot;<span style="color: blue">&gt;
                  &lt;</span><span style="color: #a31515">Icon </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">Icon.exe</span>&quot; <span style="color: red">SourceFile</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.<span style="color: blue">StartupExecutable</span>.TargetPath)</span>&quot; <span style="color: blue">/&gt;
                &lt;/</span><span style="color: #a31515">Shortcut</span><span style="color: blue">&gt;
              &lt;/</span><span style="color: #a31515">File</span><span style="color: blue">&gt; </span>
<span style="color: blue"><span style="color: blue">              &lt;!—</span><span style="color: green">Rest of your project assemblies –</span><span style="color: blue">&gt;</span></span><span style="color: blue">
              &lt;</span><span style="color: #a31515">File </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">MiddleTier</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.MiddleTier.TargetFileName)</span>&quot; <span style="color: red">Source</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.MiddleTier.TargetPath)</span>&quot; <span style="color: red">DiskId</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot; <span style="color: blue">/&gt;
              &lt;</span><span style="color: #a31515">File </span><span style="color: red">Id</span><span style="color: blue">=</span>&quot;<span style="color: blue">Backend</span>&quot; <span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.Backend.TargetFileName)</span>&quot; <span style="color: red">Source</span><span style="color: blue">=</span>&quot;<span style="color: blue">$(var.Backend.TargetPath)</span>&quot; <span style="color: red">DiskId</span><span style="color: blue">=</span>&quot;<span style="color: blue">1</span>&quot; <span style="color: blue">/&gt;</span></pre>
<pre class="code"><span style="color: blue">        </span><span style="color: blue">&lt;/</span><span style="color: #a31515">Component</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">Directory</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p>I hope this was helpful for you fellow journeyman.</p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/11/04/adding-a-desktop-shortcut-using-wix/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Second F# Program &#8211; Curried Functions</title>
		<link>http://pradeepc.net/blog/2009/10/28/second-f-program-curried-functions/</link>
		<comments>http://pradeepc.net/blog/2009/10/28/second-f-program-curried-functions/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 09:07:52 +0000</pubDate>
		<dc:creator>pc</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://pradeepc.net/blog/2009/10/28/second-f-program-curried-functions/</guid>
		<description><![CDATA[let display message = printfn "%s" (message.ToString()) let powerOf x y = x ** y let powerOf2RaisedBy = powerOf 2.0 [&#60;EntryPoint&#62;] let main(args) = display (powerOf2RaisedBy 3.0) 0]]></description>
			<content:encoded><![CDATA[<pre class="code"><span style="color: blue">let </span>display message =
    printfn <span style="color: maroon">"%s" </span>(message.ToString())

<span style="color: blue">let </span>powerOf x y = x ** y

<span style="color: blue">let </span>powerOf2RaisedBy = powerOf <span style="color: brown">2.0

</span>[&lt;EntryPoint&gt;]
<span style="color: blue">let </span>main(args) =
    display (powerOf2RaisedBy <span style="color: brown">3.0</span>)
    <span style="color: brown">0
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://pradeepc.net/blog/2009/10/28/second-f-program-curried-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

