<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Inside F#</title>
	<atom:link href="http://lorgonblog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://lorgonblog.wordpress.com</link>
	<description>Brian&#039;s thoughts on F# and .NET</description>
	<lastBuildDate>Fri, 19 Apr 2013 18:02:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lorgonblog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Inside F#</title>
		<link>http://lorgonblog.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://lorgonblog.wordpress.com/osd.xml" title="Inside F#" />
	<atom:link rel='hub' href='http://lorgonblog.wordpress.com/?pushpress=hub'/>
		<item>
		<title>F# Depth Colorizer for VS2012 now available</title>
		<link>http://lorgonblog.wordpress.com/2012/06/24/f-depth-colorizer-for-vs2012-now-available/</link>
		<comments>http://lorgonblog.wordpress.com/2012/06/24/f-depth-colorizer-for-vs2012-now-available/#comments</comments>
		<pubDate>Sun, 24 Jun 2012 19:37:03 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/?p=351</guid>
		<description><![CDATA[The F# Depth Colorizer for VS2012 makes it easy to see the nesting-depth of your F# code and ensure that control constructs are properly indented.&#160; Compare: The left screenshot shows how code appears by default.&#160; Are the ‘try’ and ‘with’ keyword aligned?&#160; It can be hard to tell at-a-glance.&#160; The right screenshot has the F# [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=351&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The <a href="http://visualstudiogallery.msdn.microsoft.com/07636c36-52be-4dce-9f2e-3c56b8329e33">F# Depth Colorizer for VS2012</a> makes it easy to see the nesting-depth of your F# code and ensure that control constructs are properly indented.&#160; Compare:</p>
<p><a href="http://lorgonblog.files.wordpress.com/2012/06/none.png"><img style="background-image:none;border-bottom:0;border-left:0;margin:5px;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="None" border="0" alt="None" src="http://lorgonblog.files.wordpress.com/2012/06/none_thumb.png?w=374&#038;h=265" width="374" height="265" /></a><a href="http://lorgonblog.files.wordpress.com/2012/06/light.png"><img style="background-image:none;border-bottom:0;border-left:0;margin:5px;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="Light" border="0" alt="Light" src="http://lorgonblog.files.wordpress.com/2012/06/light_thumb.png?w=371&#038;h=264" width="371" height="264" /></a></p>
<p>The left screenshot shows how code appears by default.&#160; Are the ‘try’ and ‘with’ keyword aligned?&#160; It can be hard to tell at-a-glance.&#160; The right screenshot has the F# Depth Colorizer installed; small changes in background color at each level of nesting/indent highlight various code blocks and make it easy to see where the indents are.</p>
<p>This extension to Visual Studio 2012 parses F# code as you type and interactively updates the background colorization to match the actual parsed structure of the code.&#160; It understands the full F# 3.0 language syntax.</p>
<p>This extension is a free VSIX on the Visual Studio Gallery, so it is easy to <a href="http://visualstudiogallery.msdn.microsoft.com/07636c36-52be-4dce-9f2e-3c56b8329e33">download</a> and try out.&#160; Once installed, it will appear on the Visual Studio 2012 ‘Tools\Extensions and Updates…’ menu:</p>
<p><a href="http://lorgonblog.files.wordpress.com/2012/06/menu.png"><img style="background-image:none;border-bottom:0;border-left:0;margin:5px;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="Menu" border="0" alt="Menu" src="http://lorgonblog.files.wordpress.com/2012/06/menu_thumb.png?w=949&#038;h=138" width="949" height="138" /></a></p>
<p>where you can easily remove it if you decide it’s not for you.</p>
<p>Are you using the new ‘dark’ theme colors in VS2012?&#160; Not a problem, the extension can detect dark default colors, and switches to a more appropriate color set for highlighting in the dark theme:</p>
<p><a href="http://lorgonblog.files.wordpress.com/2012/06/dark.png"><img style="background-image:none;border-bottom:0;border-left:0;margin:5px;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="Dark" border="0" alt="Dark" src="http://lorgonblog.files.wordpress.com/2012/06/dark_thumb.png?w=368&#038;h=262" width="368" height="262" /></a></p>
<p>Like the extension, but don’t like the default colors?&#160; You can change them.&#160; UI is not my strong point, so unfortunately the colors are only configurable via the registry (rather than some pretty color-editor GUI).&#160; Here is the registry entry for the default light-theme colors:</p>
<blockquote><p><font face="Courier New">Windows Registry Editor Version 5.00</font></p>
<p><font face="Courier New">[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor\FSharpDepthColorizer\Light]       <br />&quot;Depth0&quot;=&quot;200,200,200,222,219,222&quot;        <br />&quot;Depth1&quot;=&quot;190,190,190,206,206,206&quot;        <br />&quot;Depth2&quot;=&quot;194,194,194,216,218,219&quot;        <br />&quot;Depth3&quot;=&quot;184,184,184,202,202,202&quot;        <br />&quot;Depth4&quot;=&quot;188,188,188,214,211,214&quot;        <br />&quot;Depth5&quot;=&quot;178,178,178,198,198,198&quot;        <br />&quot;Depth6&quot;=&quot;182,182,182,210,210,210&quot;        <br />&quot;Depth7&quot;=&quot;172,172,172,194,194,194&quot;        <br />&quot;Depth8&quot;=&quot;176,176,176,206,203,206&quot;        <br />&quot;Depth9&quot;=&quot;166,166,166,190,190,190&quot;</font></p>
</blockquote>
<p>and dark-theme colors:</p>
<blockquote><p><font face="Courier New">Windows Registry Editor Version 5.00</font></p>
<p><font face="Courier New">[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor\FSharpDepthColorizer\Dark]       <br />&quot;Depth0&quot;=&quot;47,44,47,39,34,39&quot;        <br />&quot;Depth1&quot;=&quot;29,29,29,19,19,19&quot;        <br />&quot;Depth2&quot;=&quot;49,46,49,37,34,39&quot;        <br />&quot;Depth3&quot;=&quot;31,31,31,21,21,21&quot;        <br />&quot;Depth4&quot;=&quot;51,48,51,39,34,39&quot;        <br />&quot;Depth5&quot;=&quot;33,33,33,23,23,23&quot;        <br />&quot;Depth6&quot;=&quot;53,50,53,39,35,39&quot;        <br />&quot;Depth7&quot;=&quot;35,35,35,25,25,25&quot;        <br />&quot;Depth8&quot;=&quot;55,52,55,39,37,39&quot;        <br />&quot;Depth9&quot;=&quot;37,34,37,27,27,27&quot;</font></p>
</blockquote>
<p>(You can save these registry examples to a file “foo.reg”, run the “foo.reg” file to install those keys, and then use the “regedit” tool to inspect/change the values. Be careful when modifying your registry!)</p>
<p>The DepthN values are strings of six numbers, representing two sets of RGB values, e.g.</p>
<p>DepthN = R1, G1, B1, R2, G2, B2</p>
<p>where N is the depth of the nesting of the source code structure, the RGB1 values are the color of the left edge of the highlight (intention is to provide more visual contrast at the edge), and the RGB2 values are the main color for highlighting that nesting depth. </p>
<p>Note that this is a new extension specifically designed for VS2012 (currently at the RC ‘Release Candidate’ stage); if you are using VS2010, then you’ll need to use the older version of this tool instead, linked <a href="http://lorgonblog.wordpress.com/2010/11/18/f-source-code-structural-colorizer-available/">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/351/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=351&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2012/06/24/f-depth-colorizer-for-vs2012-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2012/06/none_thumb.png" medium="image">
			<media:title type="html">None</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2012/06/light_thumb.png" medium="image">
			<media:title type="html">Light</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2012/06/menu_thumb.png" medium="image">
			<media:title type="html">Menu</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2012/06/dark_thumb.png" medium="image">
			<media:title type="html">Dark</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual F# 3.0 Beta</title>
		<link>http://lorgonblog.wordpress.com/2012/02/29/visual-f-3-0-beta/</link>
		<comments>http://lorgonblog.wordpress.com/2012/02/29/visual-f-3-0-beta/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 00:08:41 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/?p=330</guid>
		<description><![CDATA[The Beta of Visual Studio 11 was published today, which includes the Beta of F# 3.0.&#160; See today’s F# blog for the high-level details. I’ll hopefully end my blog-drought with a few posts in the coming weeks covering some details about some of the new language features in F# 3.0 and IDE features in VS11.&#160; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=330&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The Beta of Visual Studio 11 was published today, which includes the Beta of F# 3.0.&#160; See <a href="http://blogs.msdn.com/b/fsharpteam/archive/2012/02/29/introducing-visual-f-3-0-beta.aspx">today’s F# blog</a> for the high-level details.</p>
<p>I’ll hopefully end my blog-drought with a few posts in the coming weeks covering some details about some of the new language features in F# 3.0 and IDE features in VS11.&#160; In the meantime, I’d encourage you to grab the bits and try out F# in VS11 Beta!</p>
<p>Happy F# programming! </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/330/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=330&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2012/02/29/visual-f-3-0-beta/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>
	</item>
		<item>
		<title>Gotcha explained</title>
		<link>http://lorgonblog.wordpress.com/2011/01/28/gotcha-explained/</link>
		<comments>http://lorgonblog.wordpress.com/2011/01/28/gotcha-explained/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 18:54:57 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2011/01/28/gotcha-explained/</guid>
		<description><![CDATA[Last time I posted a “gotcha” snippet, asking what this F# code prints: &#160;&#160;&#160; type MyVector(x:int, y:int, z:int) = &#160;&#160;&#160;&#160;&#160;&#160;&#160; // expose the values as an array &#160;&#160;&#160;&#160;&#160;&#160;&#160; member this.Values = [&#124; x; y; z &#124;] &#160;&#160;&#160; let v =&#160;new MyVector(1,2,3) &#160;&#160;&#160; v.Values.[0] &#60;- 42 &#160;&#160;&#160; printfn "%d" v.Values.[0] It prints “1”.&#160; To see why, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=238&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://lorgonblog.wordpress.com/2011/01/26/come-work-on-f/">Last time</a> I posted a “gotcha” snippet, asking what this F# code prints:</p>
<pre style="font-family:consolas;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">type</span> MyVector(x<span style="color:purple;">:</span>int, y<span style="color:purple;">:</span>int, z<span style="color:purple;">:</span>int) <span style="color:purple;">=</span>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">// expose the values as an array</span>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>Values <span style="color:purple;">=</span> [| x; y; z |]
<br /> 
<br />&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> v <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> MyVector(1,2,3)
<br />&nbsp;&nbsp;&nbsp; v<span style="color:purple;">.</span>Values<span style="color:purple;">.</span>[0] <span style="color:purple;">&lt;-</span> 42
<br />&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"%d"</span> v<span style="color:purple;">.</span>Values<span style="color:purple;">.</span>[0]
<br /></pre>
<p>It prints “1”.&nbsp; To see why, let’s look at the corresponding C# code, in all its verbosity:</p>
<pre style="font-family:consolas;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">class</span>&nbsp;<span style="color:teal;">MyVector</span>
<br />&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">int</span> x, y, z;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> MyVector(<span style="color:blue;">int</span> x, <span style="color:blue;">int</span> y, <span style="color:blue;">int</span> z)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span><span style="color:purple;">.</span>x <span style="color:purple;">=</span> x;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span><span style="color:purple;">.</span>y <span style="color:purple;">=</span> y;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span><span style="color:purple;">.</span>z <span style="color:purple;">=</span> z;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">// expose the values as an array</span>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span>&nbsp;<span style="color:blue;">int</span>[] Values
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">get</span> { <span style="color:blue;">return</span>&nbsp;<span style="color:blue;">new</span>[] { x, y, z }; }
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp; <span style="color:blue;">class</span>&nbsp;<span style="color:teal;">Program</span>
<br />&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">static</span>&nbsp;<span style="color:blue;">void</span> Main(<span style="color:blue;">string</span>[] args)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">var</span> v <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:teal;">MyVector</span>(1, 2, 3);
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v<span style="color:purple;">.</span>Values[0] <span style="color:purple;">=</span> 42;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System<span style="color:purple;">.</span><span style="color:teal;">Console</span><span style="color:purple;">.</span>WriteLine(v<span style="color:purple;">.</span>Values[0]);
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp; }
<br /></pre>
<p>The C# code, being more explicit, makes things a little more obvious.&nbsp; “Values” is a getter property, whose body creates a new array, and so every time you refer to “.Values”, a fresh array is created that contains the 3 integers that were passed into the constructor.&nbsp; So the line that assigns the value 42 assigns it into a fresh array that is then immediately dropped on the floor.</p>
<p>This probably isn’t what is desired.&nbsp; If we want “Values” to expose a single instance of a mutable array, then we can easily do so, by creating that array instance in the class constructor and returning that same instance each time people refer to the property.&nbsp; In C#:</p>
<pre style="font-family:consolas;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">class</span>&nbsp;<span style="color:teal;">MyVector</span>
<br />&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">int</span>[] a;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> MyVector(<span style="color:blue;">int</span> x, <span style="color:blue;">int</span> y, <span style="color:blue;">int</span> z)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span><span style="color:purple;">.</span>a <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span>[] { x, y, z };
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">// expose the values as an array</span>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span>&nbsp;<span style="color:blue;">int</span>[] Values
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">get</span> { <span style="color:blue;">return</span> a; }
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp; <span style="color:blue;">class</span>&nbsp;<span style="color:teal;">Program</span>
<br />&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">static</span>&nbsp;<span style="color:blue;">void</span> Main(<span style="color:blue;">string</span>[] args)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">var</span> v <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:teal;">MyVector</span>(1, 2, 3);
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v<span style="color:purple;">.</span>Values[0] <span style="color:purple;">=</span> 42;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System<span style="color:purple;">.</span><span style="color:teal;">Console</span><span style="color:purple;">.</span>WriteLine(v<span style="color:purple;">.</span>Values[0]);
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br />&nbsp;&nbsp;&nbsp; }<br /></pre>
<p>and in F#:</p>
<pre style="font-family:consolas;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">type</span> MyVector(x<span style="color:purple;">:</span>int, y<span style="color:purple;">:</span>int, z<span style="color:purple;">:</span>int) <span style="color:purple;">=</span>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> a <span style="color:purple;">=</span> [| x; y; z |]
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">// expose the values as an array</span>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>Values <span style="color:purple;">=</span> a<br /> <br />&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> v <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> MyVector(1,2,3)
<br />&nbsp;&nbsp;&nbsp; v<span style="color:purple;">.</span>Values<span style="color:purple;">.</span>[0] <span style="color:purple;">&lt;-</span> 42
<br />&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"%d"</span> v<span style="color:purple;">.</span>Values<span style="color:purple;">.</span>[0]
<br /></pre>
<p>I see people occasionally stumble on this in a variety of ways; the fact that F# property getter syntax (and overall syntax) is so succinct makes it easier to forget that the body of the member is code that will run each time the member is referenced.&nbsp; One-time initialization should be moved to the constructor (the let/do section prior to the members; see <a href="http://lorgonblog.wordpress.com/2009/02/13/the-basic-syntax-of-f-classes-interfaces-and-members/">this blog</a> for a primer on the F# class/interface syntax). </p>
<p>Every language has its own little gotchas; at work those on the C# team still fall into the trap described <a href="http://lorgonblog.wordpress.com/2008/11/12/on-lambdas-capture-and-mutability/">here</a>, and so it is fun to josh each other about the minor warts in our respective languages.&nbsp; :)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/238/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=238&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2011/01/28/gotcha-explained/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>
	</item>
		<item>
		<title>Come work on F#!</title>
		<link>http://lorgonblog.wordpress.com/2011/01/26/come-work-on-f/</link>
		<comments>http://lorgonblog.wordpress.com/2011/01/26/come-work-on-f/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 16:51:18 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2011/01/26/come-work-on-f/</guid>
		<description><![CDATA[In case you haven’t heard, the F# team is hiring.&#160; Want to work in Redmond as an F# developer, or a program manager, or a different developer?&#160; (Or perhaps just search with keyword “F#”, for other F#-related jobs at Microsoft.)&#160; See also Don’s blogs for info on applying.&#160; There’s also a contract position in the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=234&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In case you haven’t heard, the F# team is hiring.&nbsp; Want to work in Redmond as an <a href="https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=2&amp;jid=30512&amp;jlang=EN">F# developer</a>, or a <a href="https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=1&amp;jid=33994&amp;jlang=EN">program manager</a>, or a <a href="https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=3&amp;jid=34078&amp;jlang=EN">different developer</a>?&nbsp; (Or perhaps just <a href="https://careers.microsoft.com/Search.aspx">search</a> with keyword “F#”, for other F#-related jobs at Microsoft.)&nbsp; See also <a href="http://blogs.msdn.com/b/dsyme/archive/2010/12/02/come-and-join-the-f-compiler-amp-tools-team.aspx">Don’s</a> <a href="http://blogs.msdn.com/b/dsyme/archive/2011/01/23/the-f-team-are-hiring-come-and-be-the-senior-program-manager-for-f.aspx">blogs</a> for info on applying.&nbsp; There’s also a <a href="http://blogs.msdn.com/b/dsyme/archive/2011/01/26/f-team-contract-position-in-cambridge-uk.aspx">contract position</a> in the UK for applied F#.</p>
<p>Since I dislike code-free blogs, I’ll leave you with a quick code snippet.&nbsp; Ask yourself, what does this code print?&nbsp; (Then try it.)</p>
<pre style="font-family:consolas;background:white;color:black;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">type</span> MyVector(x:int, y:int, z:int) =
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">// expose the values as an array</span>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this.Values = [| x; y; z |]
<br /> 
<br />&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> v = <span style="color:blue;">new</span> MyVector(1,2,3)
<br />&nbsp;&nbsp;&nbsp; v.Values.[0] &lt;- 42
<br />&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"%d"</span> v.Values.[0]<br /></pre>
<p>A hint: it illustrates a “gotcha” people sometimes hit when first learning the syntax for writing F# property getters.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/234/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=234&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2011/01/26/come-work-on-f/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>
	</item>
		<item>
		<title>Source code for F# XmlDoc extension</title>
		<link>http://lorgonblog.wordpress.com/2010/12/04/source-code-for-f-xmldoc-extension/</link>
		<comments>http://lorgonblog.wordpress.com/2010/12/04/source-code-for-f-xmldoc-extension/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 07:26:25 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2010/12/04/source-code-for-f-xmldoc-extension/</guid>
		<description><![CDATA[I’ve just published the code for another VSIX extension; this one auto creates xml documentation boilerplate when you type triple-slash.&#160; For example, if you have the code: type SomeType() = &#160;&#160;&#160;&#160; member this.Foo(x:int, s:string) =&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; printfn "%d: %s" x s and you type “///” anywhere on the blank line before “Foo”, then you get [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=216&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve just <a href="https://github.com/brianmcn/FSharpXmlDoc">published the code</a> for another VSIX extension; this one auto creates xml documentation boilerplate when you type triple-slash.&nbsp; For example, if you have the code:</p>
<pre style="font-family:consolas;"><span style="color:blue;">type</span> SomeType() <span style="color:purple;">=</span>
 
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>Foo(x<span style="color:purple;">:</span>int, s<span style="color:purple;">:</span>string) <span style="color:purple;">=</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"%d: %s"</span> x s</pre>
<p>and you type “///” anywhere on the blank line before “Foo”, then you get</p>
<pre style="font-family:consolas;"><span style="color:blue;">type</span> SomeType() <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">/// &lt;summary&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">/// </span>
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">/// &lt;/summary&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">/// &lt;param name="x"&gt;&lt;/param&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green;">/// &lt;param name="s"&gt;&lt;/param&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>Foo(x<span style="color:purple;">:</span>int, s<span style="color:purple;">:</span>string) <span style="color:purple;">=</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"%d: %s"</span> x s<br /></pre>
<p>with your cursor sitting conveniently between the summary tags.&nbsp; And if instead you type “///” above the type declaration, you get</p>
<pre style="font-family:consolas;"><span style="color:green;">/// &lt;summary&gt;</span>
<span style="color:green;">/// </span>
<span style="color:green;">/// &lt;/summary&gt;</span>
<span style="color:blue;">type</span> SomeType() <span style="color:purple;">=</span>
 
&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>Foo(x<span style="color:purple;">:</span>int, s<span style="color:purple;">:</span>string) <span style="color:purple;">=</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"%d: %s"</span> x s<br /></pre>
<p>Get the idea?&nbsp; Just type “///” on a blank line right before a member, type, or module-scoped let (before any attributes, if there are any), and you get a blank xmldoc template (if there wasn’t already an xmldoc there).</p>
<p>I don’t plan to put this one on the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us">gallery</a>, as I’m not too interested in maintaining it.&nbsp; You can <a href="https://github.com/brianmcn/FSharpXmlDoc">grab the the source from github</a>, set the VSIX project as the startup project, and build it yourself.&nbsp; (If someone is interested in refining/publishing it, you can contact me directly.)&nbsp; </p>
<p>The source code is simple, and structured just like <a href="http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/">my previous extension</a>.&nbsp; There are two projects. “MyFSParser” is (again) just the parser code ripped from the F# compiler, with about 130 new lines of code at the end of <a href="https://github.com/brianmcn/FSharpXmlDoc/blob/master/FSXmlDocVSIX/MyParser/MyParsing.fs">MyParsing.fs</a> that computes information about every xml-doc-able entity in a file.&nbsp; “FSXmlDocVSIX” is the editor extension that, in a mere 120 lines of code in <a href="https://github.com/brianmcn/FSharpXmlDoc/blob/master/FSXmlDocVSIX/VSIX/Program.fs">Program.fs</a>, intercepts keypresses and does some special logic when you press ‘/’ to see if you just typed “///” on a blank line above an xml-doc-able, and if so, dumps extra stuff into your editor buffer.&nbsp; It’s really simple; if you ever wanted to look at a straightforward extension to the Visual Studio editor, this is a good code sample.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=216&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2010/12/04/source-code-for-f-xmldoc-extension/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>
	</item>
		<item>
		<title>Source code for F# Depth Colorizer extension</title>
		<link>http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/</link>
		<comments>http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 21:39:20 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/</guid>
		<description><![CDATA[I’ve published the source code for the F# Depth Colorizer.&#160; You can get the code from github.&#160; The code is available under the Apache 2.0 License. Here’s a quick overview of what’s there.&#160; There is a Visual Studio 2010 solution with two projects.&#160; The “MyFSParser” project is a library that parses F# source code and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=213&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve published the source code for the <a href="http://lorgonblog.wordpress.com/2010/11/18/f-source-code-structural-colorizer-available/">F# Depth Colorizer</a>.&nbsp; You can get the code from <a href="https://github.com/brianmcn/FSharpDepthColorizer">github</a>.&nbsp; The code is available under the Apache 2.0 License.</p>
<p>Here’s a quick overview of what’s there.&nbsp; There is a Visual Studio 2010 solution with two projects.&nbsp; </p>
<ul>
<li>The “MyFSParser” project is a library that parses F# source code and yields “range” information about where source code constructs begin and end.&nbsp; It is basically a free-standing version of the front half of the F# compiler, followed by about 350 lines of my own code for munging and publishing range information from the abstract syntax tree (AST) produced by the F# compiler front end.</li>
<li>The “VSIXColorizer” project is a Visual Studio extension that plug into the editor, listens for changes in the test buffer, re-parses the source, gets the range information, tags editor ‘spans’ with the semantic depth information, and then draws adornments on the screen for the portions of the file in view.&nbsp; It’s also about 350 lines of code.</li>
</ul>
<p>Of course all the code is written in F#.&nbsp; This is a nice sample that demonstrates both the simple Visual Studio extensibility model that makes it easy to craft editor extensions, as well as the kinds of things you can do when you leverage the F# compiler source to do the “heavy lifting” to parse F# code for you.</p>
<p>In order to provide a little more guidance, I made a couple screencasts, about 10 minutes each, where I give a (rambling) walkthrough of each of the projects.&nbsp; You won’t learn all the fine details about how the compiler code or my code works, but you will get an overview of the structure and see some of the important methods/functions and how the pieces fit together.&nbsp; Here is the <a href="http://brianmcn.members.winisp.net/FSDCMyParser1.wmv">video about the parser</a> and here is the <a href="http://brianmcn.members.winisp.net/FSDCVSIX.wmv">video about the colorizer</a>.</p>
<p>I’ve already started working on another editor extension that reuses the parser library code, and so in another week or two hopefully I’ll share that too.&nbsp; I hope this is good “seed code” to help you leverage the F# compiler source and Visual Studio extensibility to do your own cool stuff!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/213/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=213&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
<enclosure url="http://brianmcn.members.winisp.net/FSDCMyParser1.wmv" length="73905817" type="video/asf" />
<enclosure url="http://brianmcn.members.winisp.net/FSDCVSIX.wmv" length="53769013" type="video/asf" />
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>
	</item>
		<item>
		<title>A quick standalone app to edit colors for the F# colorizer</title>
		<link>http://lorgonblog.wordpress.com/2010/11/20/a-quick-standalone-app-to-edit-colors-for-the-f-colorizer/</link>
		<comments>http://lorgonblog.wordpress.com/2010/11/20/a-quick-standalone-app-to-edit-colors-for-the-f-colorizer/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 20:59:21 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2010/11/20/a-quick-standalone-app-to-edit-colors-for-the-f-colorizer/</guid>
		<description><![CDATA[What kind of fool posts a cool extension for colorizing F# source code structure, but then only lets you configure the colors by editing the registry (and then having to restart Visual Studio to see if the new colors look ok)? Oh, that was me.&#160; :) Like I said in the previous blog, I don’t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=209&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>What kind of fool posts a <a href="http://lorgonblog.wordpress.com/2010/11/18/f-source-code-structural-colorizer-available/">cool extension for colorizing F# source code structure</a>, but then only lets you configure the colors by editing the registry (and then having to restart Visual Studio to see if the new colors look ok)?</p>
<p>Oh, that was me.&nbsp; :)</p>
<p>Like I said in the previous blog, I don’t have the skills to design a good GUI to edit the colors or figure out the most discoverable place in VS to edit them.&nbsp; But maybe you do!&nbsp; And so in the spirit of sharing source, here’s a crummy (but working) standalone app for experimenting with the colors.&nbsp; A screenshot is suggestive:</p>
<p><a href="http://lorgonblog.files.wordpress.com/2010/11/fscoloreditor.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="FSColorEditor" border="0" alt="FSColorEditor" src="http://lorgonblog.files.wordpress.com/2010/11/fscoloreditor_thumb.png?w=804&#038;h=488" width="804" height="488"></a></p>
<p>Basically, you can click on one of the rectangles, and then use the buttons to change the R/G/B values of the left-edge color or the main color.&nbsp; And once you have colors you like, you can click a different button which prints out a .reg file you can use to install those colors.&nbsp; (The app only reads the registry, it does not write it, so you have to copy-paste the text from the console window, save it to a .reg file, and run it if you want to install your updated colors.)</p>
<p>Anyway, the code is below.&nbsp; Just throw this in an F# Console Application, add references to the WPF assemblies (PresentationCore, PresentationFramework, System.Xaml, System.Xml, UIAutomationTypes, and WindowsBase), press Ctrl-F5 to build and run and you’re off to the races.&nbsp; Feel free to steal all this code to build your own better app/extension, or just to use to build your own attractive color schemes.&nbsp; The code is just a quick ugly hack, but hopefully you can work with it.</p>
<p>And yes, I’ll be releasing the code for the actual editor colorizer extension <a href="http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/">soon</a>, I just want to finish tidying it up a little.&nbsp; (Thanks to those who have already left feedback and pointed out minor bugs!)</p>
<p>Quickie code for app to manage editing colors:</p>
<pre style="font-family:consolas;"><span style="color:blue;">open</span> System<span style="color:purple;">.</span>Windows 
<span style="color:blue;">open</span> System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>Controls
<span style="color:blue;">open</span> System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>Data
<span style="color:blue;">open</span> System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>Media 
<span style="color:blue;">open</span> System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>Shapes 
<span style="color:blue;">open</span> Microsoft<span style="color:purple;">.</span>Win32 
 
<span style="color:blue;">type</span> IIndexable<span style="color:purple;">&lt;'</span>a<span style="color:purple;">&gt;</span>&nbsp;<span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp; <span style="color:blue;">abstract</span>&nbsp;<span style="color:blue;">member</span> Item <span style="color:purple;">:</span> int <span style="color:blue;">-&gt;</span>&nbsp;<span style="color:purple;">'</span>a
 
<span style="color:blue;">let</span> makeBinding(sourceObj<span style="color:purple;">:</span>obj, sourcePath<span style="color:purple;">:</span>string, converter<span style="color:purple;">:'</span>T<span style="color:blue;">-&gt;</span><span style="color:purple;">'</span>U, 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; targetObj<span style="color:purple;">:</span>DependencyObject, targetDependencyProperty<span style="color:purple;">:</span>DependencyProperty) <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> b <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>Data<span style="color:purple;">.</span>Binding()
&nbsp;&nbsp;&nbsp; b<span style="color:purple;">.</span>Source <span style="color:purple;">&lt;-</span> sourceObj
&nbsp;&nbsp;&nbsp; b<span style="color:purple;">.</span>Path <span style="color:purple;">&lt;-</span>&nbsp;<span style="color:blue;">new</span> System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>PropertyPath(sourcePath)
&nbsp;&nbsp;&nbsp; b<span style="color:purple;">.</span>Converter <span style="color:purple;">&lt;-</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <span style="color:blue;">new</span> System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>Data<span style="color:purple;">.</span>IValueConverter <span style="color:blue;">with</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>Convert(v, targetType, param, culInfo) <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; box(converter (unbox v))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>ConvertBack(v, targetType, param, culInfo) <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise <span style="color:purple;">&lt;|</span>&nbsp;<span style="color:blue;">new</span> System<span style="color:purple;">.</span>NotImplementedException() }
&nbsp;&nbsp;&nbsp; BindingOperations<span style="color:purple;">.</span>SetBinding(targetObj, targetDependencyProperty, b) <span style="color:purple;">|&gt;</span> ignore
 
<span style="color:blue;">type</span> MyWindow() <span style="color:blue;">as</span> this <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp; <span style="color:blue;">inherit</span> Window()
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">static</span>&nbsp;<span style="color:blue;">let</span> selectedRectangleNumber <span style="color:purple;">=</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DependencyProperty<span style="color:purple;">.</span>Register(<span style="color:maroon;">"SelectedRectangleNumber"</span>, typeof<span style="color:purple;">&lt;</span>int<span style="color:purple;">&gt;</span>, typeof<span style="color:purple;">&lt;</span>MyWindow<span style="color:purple;">&gt;</span>, 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">new</span> FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions<span style="color:purple;">.</span>AffectsRender, 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">new</span> PropertyChangedCallback(<span style="color:blue;">fun</span> depObj ea <span style="color:blue;">-&gt;</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">match</span> box depObj, box ea<span style="color:purple;">.</span>NewValue <span style="color:blue;">with</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | (<span style="color:purple;">:?</span> MyWindow <span style="color:blue;">as</span> w), (<span style="color:purple;">:?</span> int <span style="color:blue;">as</span> x) <span style="color:blue;">-&gt;</span> w<span style="color:purple;">.</span>TriggerSelectedRectangleNumberChanged(x) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | _ <span style="color:blue;">-&gt;</span> ())))
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> selectedChanged <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> Event<span style="color:purple;">&lt;</span>Handler<span style="color:purple;">&lt;</span>int<span style="color:purple;">&gt;</span>,int<span style="color:purple;">&gt;</span>()
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> getNum() <span style="color:purple;">=</span> this<span style="color:purple;">.</span>GetValue(MyWindow<span style="color:purple;">.</span>SelectedRectangleNumber) <span style="color:purple;">:?&gt;</span> int
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> setNum(n) <span style="color:purple;">=</span> this<span style="color:purple;">.</span>SetValue(MyWindow<span style="color:purple;">.</span>SelectedRectangleNumber, n)
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> colors <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">try</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> key <span style="color:purple;">=</span> Registry<span style="color:purple;">.</span>CurrentUser<span style="color:purple;">.</span>OpenSubKey(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:maroon;">@"Software\Microsoft\VisualStudio\10.0\Text Editor\FSharpDepthColorizer"</span>)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Array<span style="color:purple;">.</span>init 10 (<span style="color:blue;">fun</span> i <span style="color:blue;">-&gt;</span> key<span style="color:purple;">.</span>GetValue(sprintf <span style="color:maroon;">"Depth%d"</span> i) <span style="color:purple;">:?&gt;</span> string)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:purple;">|&gt;</span> Array<span style="color:purple;">.</span>map (<span style="color:blue;">fun</span> s <span style="color:blue;">-&gt;</span>&nbsp;<span style="color:blue;">let</span> [|r1;g1;b1;r2;g2;b2|] <span style="color:purple;">=</span> s<span style="color:purple;">.</span>Split[|<span style="color:maroon;">','</span>|] <span style="color:purple;">|&gt;</span> Array<span style="color:purple;">.</span>map byte
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r1,g1,b1,r2,g2,b2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">with</span> e <span style="color:blue;">-&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [|&nbsp; <span style="color:green;">// greyscale colors</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 190uy,190uy,190uy,230uy,230uy,230uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 170uy,170uy,170uy,210uy,210uy,210uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 184uy,184uy,184uy,224uy,224uy,224uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 164uy,164uy,164uy,204uy,204uy,204uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 178uy,178uy,178uy,218uy,218uy,218uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 158uy,158uy,158uy,198uy,198uy,198uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 172uy,172uy,172uy,212uy,212uy,212uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 152uy,152uy,152uy,192uy,192uy,192uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 166uy,166uy,166uy,206uy,206uy,206uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 146uy,146uy,146uy,186uy,186uy,186uy
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |]
&nbsp;&nbsp;&nbsp; <span style="color:green;">// why the SolidColorBrush below? </span>
&nbsp;&nbsp;&nbsp; <span style="color:green;">// to have a DependencyObject to data-bind... there is probably a cleaner way, but oh well</span>
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> edgeColors <span style="color:purple;">=</span> colors <span style="color:purple;">|&gt;</span> Array<span style="color:purple;">.</span>map (<span style="color:blue;">fun</span> (r,g,b,_,_,_) <span style="color:blue;">-&gt;</span> SolidColorBrush(Color<span style="color:purple;">.</span>FromRgb(r,g,b)))
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> mainColors <span style="color:purple;">=</span> colors <span style="color:purple;">|&gt;</span> Array<span style="color:purple;">.</span>map (<span style="color:blue;">fun</span> (_,_,_,r,g,b) <span style="color:blue;">-&gt;</span> SolidColorBrush(Color<span style="color:purple;">.</span>FromRgb(r,g,b)))
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> brushes <span style="color:purple;">=</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> makeGradientStop(b<span style="color:purple;">:</span>SolidColorBrush, pct) <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> gs <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> GradientStop(b<span style="color:purple;">.</span>Color, pct)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; makeBinding(b, <span style="color:maroon;">"Color"</span>, (<span style="color:blue;">fun</span> (c<span style="color:purple;">:</span>Color) <span style="color:blue;">-&gt;</span> c), gs, GradientStop<span style="color:purple;">.</span>ColorProperty)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gs
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <span style="color:blue;">new</span> IIndexable<span style="color:purple;">&lt;</span>Brush<span style="color:purple;">&gt;</span>&nbsp;<span style="color:blue;">with</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span> this<span style="color:purple;">.</span>Item depth <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">upcast</span>&nbsp;<span style="color:blue;">new</span> LinearGradientBrush(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">new</span> GradientStopCollection( 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [|
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; makeGradientStop(edgeColors<span style="color:purple;">.</span>[depth], 0.0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; makeGradientStop(mainColors<span style="color:purple;">.</span>[depth], 0.01)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; makeGradientStop(mainColors<span style="color:purple;">.</span>[depth], 1.0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |] ), <span style="color:blue;">new</span> Point(0.0, 0.5), <span style="color:blue;">new</span> Point(1.0, 0.5)) }
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> printCurrentSettings() <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"Windows Registry Editor Version 5.00"</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">""</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor\FSharpDepthColorizer]"</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">for</span> i <span style="color:blue;">in</span> 0..9 <span style="color:blue;">do</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> ec <span style="color:purple;">=</span> edgeColors<span style="color:purple;">.</span>[i]<span style="color:purple;">.</span>Color
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> mc <span style="color:purple;">=</span> mainColors<span style="color:purple;">.</span>[i]<span style="color:purple;">.</span>Color
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printfn <span style="color:maroon;">"\"Depth%d\"=\"%d,%d,%d,%d,%d,%d\""</span> i ec<span style="color:purple;">.</span>R ec<span style="color:purple;">.</span>G ec<span style="color:purple;">.</span>B mc<span style="color:purple;">.</span>R mc<span style="color:purple;">.</span>G mc<span style="color:purple;">.</span>B 
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> mkButton(colors<span style="color:purple;">:</span>SolidColorBrush[], text, dr, dg, db) <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> b <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> Button()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b<span style="color:purple;">.</span>Content <span style="color:purple;">&lt;-</span> text
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b<span style="color:purple;">.</span>Click<span style="color:purple;">.</span>Add(<span style="color:blue;">fun</span> _ <span style="color:blue;">-&gt;</span> colors<span style="color:purple;">.</span>[getNum()]<span style="color:purple;">.</span>Color <span style="color:purple;">&lt;-</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Color<span style="color:purple;">.</span>FromRgb(colors<span style="color:purple;">.</span>[getNum()]<span style="color:purple;">.</span>Color<span style="color:purple;">.</span>R <span style="color:purple;">+</span> byte dr, 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; colors<span style="color:purple;">.</span>[getNum()]<span style="color:purple;">.</span>Color<span style="color:purple;">.</span>G <span style="color:purple;">+</span> byte dg, 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; colors<span style="color:purple;">.</span>[getNum()]<span style="color:purple;">.</span>Color<span style="color:purple;">.</span>B <span style="color:purple;">+</span> byte db))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> mkButtonPanel(colors<span style="color:purple;">:</span>SolidColorBrush[],text,dr,dg,db,f) <span style="color:purple;">=</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> panel <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> StackPanel(Orientation <span style="color:purple;">=</span> Orientation<span style="color:purple;">.</span>Horizontal)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> tb <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> TextBlock()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selectedChanged<span style="color:purple;">.</span>Publish<span style="color:purple;">.</span>Add(<span style="color:blue;">fun</span> _ <span style="color:blue;">-&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; makeBinding(colors<span style="color:purple;">.</span>[getNum()], <span style="color:maroon;">"Color"</span>, (<span style="color:blue;">fun</span> (c<span style="color:purple;">:</span>Color) <span style="color:blue;">-&gt;</span> f(c)<span style="color:purple;">.</span>ToString()), 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tb, System<span style="color:purple;">.</span>Windows<span style="color:purple;">.</span>Controls<span style="color:purple;">.</span>TextBlock<span style="color:purple;">.</span>TextProperty))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; panel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButton(colors, text<span style="color:purple;">+</span><span style="color:maroon;">" down"</span>,<span style="color:purple;">-</span>dr,<span style="color:purple;">-</span>dg,<span style="color:purple;">-</span>db)) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; panel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(tb) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; panel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButton(colors, text<span style="color:purple;">+</span><span style="color:maroon;">" up"</span>,dr,dg,db)) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; panel
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">do</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> leftPanel <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> StackPanel(Orientation <span style="color:purple;">=</span> Orientation<span style="color:purple;">.</span>Vertical)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leftPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButtonPanel(edgeColors,<span style="color:maroon;">"edge R"</span>,2,0,0,(<span style="color:blue;">fun</span> c<span style="color:blue;">-&gt;</span>c<span style="color:purple;">.</span>R))) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leftPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButtonPanel(edgeColors,<span style="color:maroon;">"edge G"</span>,0,2,0,(<span style="color:blue;">fun</span> c<span style="color:blue;">-&gt;</span>c<span style="color:purple;">.</span>G))) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leftPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButtonPanel(edgeColors,<span style="color:maroon;">"edge B"</span>,0,0,2,(<span style="color:blue;">fun</span> c<span style="color:blue;">-&gt;</span>c<span style="color:purple;">.</span>B))) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leftPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButtonPanel(mainColors,<span style="color:maroon;">"main R"</span>,2,0,0,(<span style="color:blue;">fun</span> c<span style="color:blue;">-&gt;</span>c<span style="color:purple;">.</span>R))) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leftPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButtonPanel(mainColors,<span style="color:maroon;">"main G"</span>,0,2,0,(<span style="color:blue;">fun</span> c<span style="color:blue;">-&gt;</span>c<span style="color:purple;">.</span>G))) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leftPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(mkButtonPanel(mainColors,<span style="color:maroon;">"main B"</span>,0,0,2,(<span style="color:blue;">fun</span> c<span style="color:blue;">-&gt;</span>c<span style="color:purple;">.</span>B))) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> printButton <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> Button(Content<span style="color:purple;">=</span><span style="color:maroon;">"Print current settings to console"</span>)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printButton<span style="color:purple;">.</span>Click<span style="color:purple;">.</span>Add(<span style="color:blue;">fun</span> _ <span style="color:blue;">-&gt;</span> printCurrentSettings())
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leftPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(printButton) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> mainPanel <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> StackPanel(Orientation <span style="color:purple;">=</span> Orientation<span style="color:purple;">.</span>Horizontal)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mainPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(leftPanel) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> canvas <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> Canvas()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">for</span> i <span style="color:blue;">in</span> 0..mainColors<span style="color:purple;">.</span>Length<span style="color:purple;">-</span>1 <span style="color:blue;">do</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> rect <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> Rectangle(Width<span style="color:purple;">=</span>600., Height<span style="color:purple;">=</span>500., Fill <span style="color:purple;">=</span> brushes<span style="color:purple;">.</span>[i])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rect<span style="color:purple;">.</span>MouseDown<span style="color:purple;">.</span>Add(<span style="color:blue;">fun</span> _ <span style="color:blue;">-&gt;</span> setNum(i))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Canvas<span style="color:purple;">.</span>SetLeft(rect, (float i)<span style="color:purple;">*</span>30.)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Canvas<span style="color:purple;">.</span>SetTop(rect, (float i)<span style="color:purple;">*</span>30.)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Canvas<span style="color:purple;">.</span>SetZIndex(rect, i)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; canvas<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(rect) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">let</span> rect <span style="color:purple;">=</span>&nbsp;<span style="color:blue;">new</span> Rectangle(Width<span style="color:purple;">=</span>600., Height<span style="color:purple;">=</span>40.)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selectedChanged<span style="color:purple;">.</span>Publish<span style="color:purple;">.</span>Add(<span style="color:blue;">fun</span> _ <span style="color:blue;">-&gt;</span> rect<span style="color:purple;">.</span>Fill <span style="color:purple;">&lt;-</span> brushes<span style="color:purple;">.</span>[getNum()])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Canvas<span style="color:purple;">.</span>SetLeft(rect, 0.)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Canvas<span style="color:purple;">.</span>SetTop(rect, (float mainColors<span style="color:purple;">.</span>Length)<span style="color:purple;">*</span>30. <span style="color:purple;">+</span> 20.)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Canvas<span style="color:purple;">.</span>SetZIndex(rect, mainColors<span style="color:purple;">.</span>Length)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; canvas<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(rect) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mainPanel<span style="color:purple;">.</span>Children<span style="color:purple;">.</span>Add(canvas) <span style="color:purple;">|&gt;</span> ignore
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this<span style="color:purple;">.</span>Content <span style="color:purple;">&lt;-</span> mainPanel
 
&nbsp;&nbsp;&nbsp; <span style="color:blue;">member</span>&nbsp;<span style="color:blue;">private</span> this<span style="color:purple;">.</span>TriggerSelectedRectangleNumberChanged(x<span style="color:purple;">:</span>int) <span style="color:purple;">=</span> selectedChanged<span style="color:purple;">.</span>Trigger(this, x)
&nbsp;&nbsp;&nbsp; <span style="color:blue;">static</span>&nbsp;<span style="color:blue;">member</span> SelectedRectangleNumber <span style="color:purple;">=</span> selectedRectangleNumber 
 
[&lt;System<span style="color:purple;">.</span>STAThread&gt;]
<span style="color:blue;">do</span>
&nbsp;&nbsp;&nbsp; (<span style="color:blue;">new</span> Application())<span style="color:purple;">.</span>Run(MyWindow()) <span style="color:purple;">|&gt;</span> ignore
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/209/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=209&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2010/11/20/a-quick-standalone-app-to-edit-colors-for-the-f-colorizer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/11/fscoloreditor_thumb.png" medium="image">
			<media:title type="html">FSColorEditor</media:title>
		</media:content>
	</item>
		<item>
		<title>F# source code structural colorizer available</title>
		<link>http://lorgonblog.wordpress.com/2010/11/18/f-source-code-structural-colorizer-available/</link>
		<comments>http://lorgonblog.wordpress.com/2010/11/18/f-source-code-structural-colorizer-available/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 14:05:34 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2010/11/18/f-source-code-structural-colorizer-available/</guid>
		<description><![CDATA[Last week I mentioned the editor extension I am working on, and now it’s available for you to try out!&#160; You can obtain the F# Depth Colorizer from the Visual Studio Gallery.&#160; It’s a one-click install; once installed you’ll see it listed when you bring up the “Tools\Extension Manager” menu in Visual Studio: Once installed, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=204&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://lorgonblog.wordpress.com/2010/11/12/the-f-compiler-source-release-making-it-easy-to-write-cool-visual-studio-extensions/">Last week</a> I mentioned the editor extension I am working on, and now it’s available for you to try out!&nbsp; You can obtain the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/0713522e-27e6-463f-830a-cb8f08e467c4">F# Depth Colorizer</a> from the <a href="http://visualstudiogallery.msdn.microsoft.com/">Visual Studio Gallery</a>.&nbsp; It’s a one-click install; once installed you’ll see it listed when you bring up the “Tools\Extension Manager” menu in Visual Studio:</p>
<p><a href="http://lorgonblog.files.wordpress.com/2010/11/fsdcem.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="FSDCEM" border="0" alt="FSDCEM" src="http://lorgonblog.files.wordpress.com/2010/11/fsdcem_thumb.png?w=858&#038;h=137" width="858" height="137"></a></p>
<p>Once installed, the structure of your code will be highlighted in the editor, like this</p>
<p><a href="http://lorgonblog.files.wordpress.com/2010/11/fsdcgreyscalescreenshot.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="FSDCGreyScaleScreenshot" border="0" alt="FSDCGreyScaleScreenshot" src="http://lorgonblog.files.wordpress.com/2010/11/fsdcgreyscalescreenshot_thumb.png?w=829&#038;h=473" width="829" height="473"></a></p>
<p>or like this</p>
<p><a href="http://lorgonblog.files.wordpress.com/2010/11/fsdcredbluescreenshot.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="FSDCRedBlueScreenshot" border="0" alt="FSDCRedBlueScreenshot" src="http://lorgonblog.files.wordpress.com/2010/11/fsdcredbluescreenshot_thumb.png?w=831&#038;h=472" width="831" height="472"></a></p>
<p>rather than plain old code like this</p>
<p><a href="http://lorgonblog.files.wordpress.com/2010/11/fsdcdisabledscreenshot.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="FSDCDisabledScreenshot" border="0" alt="FSDCDisabledScreenshot" src="http://lorgonblog.files.wordpress.com/2010/11/fsdcdisabledscreenshot_thumb.png?w=830&#038;h=473" width="830" height="473"></a></p>
<p>Get the idea?&nbsp; As suggested by the first two screenshots, the colors are configurable.&nbsp; A good UI for configuring the colors was beyond me, so the colors are configurable via a registry setting.&nbsp; (EDIT: see also <a href="http://lorgonblog.wordpress.com/2010/11/20/a-quick-standalone-app-to-edit-colors-for-the-f-colorizer/">here</a>) If you don’t have the registry entry, you get the “greyscale” colors from the first screenshot by default.&nbsp; Those greyscale colors could be represented via the following registry entry:</p>
<pre style="font-family:consolas;"><font size="2">Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor\FSharpDepthColorizer]
"Depth0"="190,190,190,230,230,230"
"Depth1"="170,170,170,210,210,210"
"Depth2"="184,184,184,224,224,224"
"Depth3"="164,164,164,204,204,204"
"Depth4"="178,178,178,218,218,218"
"Depth5"="158,158,158,198,198,198"
"Depth6"="172,172,172,212,212,212"
"Depth7"="152,152,152,192,192,192"
"Depth8"="166,166,166,206,206,206"
"Depth9"="146,146,146,186,186,186"<br /></font></pre>
<p>Alternatively, the red-blue colors from the second screenshot are:</p>
<pre style="font-family:consolas;"><font size="2">Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor\FSharpDepthColorizer]
"Depth0"="240,180,180,240,220,220"
"Depth1"="180,180,240,220,220,240"
"Depth2"="240,172,172,240,216,212"
"Depth3"="172,172,240,212,216,240"
"Depth4"="240,164,164,240,212,204"
"Depth5"="164,164,240,204,212,240"
"Depth6"="240,156,156,240,208,196"
"Depth7"="156,156,240,196,208,240"
"Depth8"="240,148,148,240,204,188"
"Depth9"="148,148,240,188,204,240"<br /></font></pre>
<p>and more generally, the extension will look for the those registry keys.&nbsp; (You can save these registry examples to a file “foo.reg” and then run the “foo.reg” file to install those keys, or use the “regedit” tool to inspect/change the values.&nbsp; Be careful when modifying your registry!)</p>
<p>The DepthN values are strings of six numbers, representing two sets of RGB values, e.g.</p>
<p>DepthN = R1, G1, B1, R2, G2, B2</p>
<p>where N is the depth of the nesting of the source code structure, the RGB1 values are the color of the left edge of the highlight (intention is to provide more visual contrast at the edge), and the RGB2 values are the main color for highlighting that nesting depth.&nbsp; There must be 10 depths, if you go deeper, the tool cycles around:</p>
<p><a href="http://lorgonblog.files.wordpress.com/2010/11/fsdcdeepnestingscreenshot.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="FSDCDeepNestingScreenshot" border="0" alt="FSDCDeepNestingScreenshot" src="http://lorgonblog.files.wordpress.com/2010/11/fsdcdeepnestingscreenshot_thumb.png?w=268&#038;h=226" width="268" height="226"></a></p>
<p>where the colors are getting darker until it’s gone 10 deep and cycles back around to using the lightest pink color from that color set.</p>
<p>I’ll publish the source code for this VSIX extension soon. (EDIT: It&#8217;s posted, see <a href="http://lorgonblog.wordpress.com/2010/11/21/source-code-for-f-depth-colorizer-extension/">here</a>.) &nbsp; For now, I’d encourage you to try it out; you can leave feedback on my blog or on the gallery.&nbsp; Enjoy!</p>
<p>(Much thanks to <a href="http://blogs.msdn.com/b/noahric/">Noah</a> who helped me write the editor portion of the extension.&nbsp; Thanks to many people who did beta testing and offered useful feedback.)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/204/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=204&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2010/11/18/f-source-code-structural-colorizer-available/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/11/fsdcem_thumb.png" medium="image">
			<media:title type="html">FSDCEM</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/11/fsdcgreyscalescreenshot_thumb.png" medium="image">
			<media:title type="html">FSDCGreyScaleScreenshot</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/11/fsdcredbluescreenshot_thumb.png" medium="image">
			<media:title type="html">FSDCRedBlueScreenshot</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/11/fsdcdisabledscreenshot_thumb.png" medium="image">
			<media:title type="html">FSDCDisabledScreenshot</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/11/fsdcdeepnestingscreenshot_thumb.png" medium="image">
			<media:title type="html">FSDCDeepNestingScreenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>The F# compiler source release: making it easy to write cool Visual Studio extensions</title>
		<link>http://lorgonblog.wordpress.com/2010/11/12/the-f-compiler-source-release-making-it-easy-to-write-cool-visual-studio-extensions/</link>
		<comments>http://lorgonblog.wordpress.com/2010/11/12/the-f-compiler-source-release-making-it-easy-to-write-cool-visual-studio-extensions/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 09:34:55 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2010/11/12/the-f-compiler-source-release-making-it-easy-to-write-cool-visual-studio-extensions/</guid>
		<description><![CDATA[In case you’ve been hiding under a rock and haven’t heard, the F# compiler was recently released under the Apache 2.0 license; see Don’s blog for the details.&#160; This source code release gives you the freedom to use the F# compiler code how you like, and so of course as a developer who likes using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=193&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In case you’ve been hiding under a rock and haven’t heard, the F# compiler was recently released under the Apache 2.0 license; see <a href="http://blogs.msdn.com/b/dsyme/archive/2010/11/04/announcing-the-f-compiler-library-source-code-drop.aspx">Don’s blog</a> for the details.&nbsp; This source code release gives you the freedom to use the F# compiler code how you like, and so of course as a developer who likes using Visual Studio, I decided to take a crack at a Visual Studio extension that I’ve always wanted to write.</p>
<p>The basic idea is an editor extension that uses background colorization to show the “control flow depth” of F# code.&nbsp; A screenshot is a little suggestive:</p>
<p><a href="http://lorgonblog.files.wordpress.com/2010/11/fsparsedepthscreenshot.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="FSParseDepthScreenshot" border="0" alt="FSParseDepthScreenshot" src="http://lorgonblog.files.wordpress.com/2010/11/fsparsedepthscreenshot_thumb.png?w=282&#038;h=194" width="282" height="194"></a></p>
<p>but in order to really describe it, I made a video (about 6 minutes long), linked below.</p>
<p>The idea is simple; the F# compiler code already knows how to do all the heavy lifting of parsing source code and creating a parse tree (an abstract syntax tree, or “AST”), and the AST knows all the info about code structure and e.g. that this expression starts in this line/column and ends in this other line/column.&nbsp; So I just take the tree and turn it into some useful “depth and span” information, which I then use from a Visual Studio editor extension to add color adornments in the editor.</p>
<p>This is still under development, but I plan to publish the extension on the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/">Visual Studio Gallery</a>, and publish the source code when I’m done.</p>
<p>Anyway, check out the video <a href="http://brianmcn.members.winisp.net/FSharpParseDepthPreview.wmv">here</a>.&nbsp; I’m interested to hear what people think, and hope this inspires others to try their hand at leveraging the F# compiler code to write cool tools and extensions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/193/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=193&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2010/11/12/the-f-compiler-source-release-making-it-easy-to-write-cool-visual-studio-extensions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://brianmcn.members.winisp.net/FSharpParseDepthPreview.wmv" length="33343795" type="video/asf" />
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/11/fsparsedepthscreenshot_thumb.png" medium="image">
			<media:title type="html">FSParseDepthScreenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>PDC is just around the corner&#8230;</title>
		<link>http://lorgonblog.wordpress.com/2010/10/26/pdc-is-just-around-the-corner/</link>
		<comments>http://lorgonblog.wordpress.com/2010/10/26/pdc-is-just-around-the-corner/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 04:52:12 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://lorgonblog.wordpress.com/2010/10/26/pdc-is-just-around-the-corner/</guid>
		<description><![CDATA[For those of you attending Microsoft’s Professional Developers Conference, I hope you’ll stop by the F# “Ask the Experts” table at lunchtime on Thursday or Friday to say hello and ask some interesting questions about F#!&#160; For those of you who won’t be in Redmond this week, all of the PDC content can be watched [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=186&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>For those of you attending Microsoft’s <a href="http://www.microsoftpdc.com/">Professional Developers Conference</a>, I hope you’ll stop by the F# “Ask the Experts” table at lunchtime on Thursday or Friday to say hello and ask some interesting questions about F#!&nbsp; For those of you who won’t be in Redmond this week, all of the PDC content can be watched live online (or recorded afterwards), so there’s no reason for you to miss out on all the great talks.</p>
<p>Don’s F# talk entitled “The Future of F#: Data and Services at your Finger Tips” is scheduled during the final timeslot on Friday afternoon, so of course readers of this blog will want to check that out.&nbsp; <a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/10/26/make-sure-you-don-t-miss-windows-phone-sessions-during-pdc10.aspx">Windows Phone 7</a> will be another hot topic at PDC; I have been trying really hard to get my hands on a phone, so that I can show off some F# apps running on the phone at the Experts table, but so far I’ve only met dead ends.&nbsp; I’ve still got another 36 hours or so, and I haven’t given up on that yet.&nbsp; <img style="border-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lorgonblog.files.wordpress.com/2010/10/wlemoticon-smile.png"></p>
<p>Regarding general F# news… I recently saw F# get some love on <a href="http://news.ycombinator.com/item?id=1826564">HackerNews</a>, and PDC will be sure to generate some more F# buzz this week.&nbsp; And I think perhaps there’s some more F# news in store soon after PDC as well.&nbsp; So now is a good time to have your finger on the pulse of the F# community; <a href="http://feeds.feedburner.com/planet_fsharp">Planet F#</a> or <a href="http://www.atalasoft.com/cs/blogs/rickm/default.aspx">Rick Minerich’s blog</a> are good ways to keep up with the F# highlights.&nbsp; On the other hand, if you’re relatively new to the world of F#, you might prefer reading <a href="http://stackoverflow.com/questions/734525/getting-started-with-f">Getting started with F#</a>.</p>
<p>In completely unrelated news, I recently posted an answer to <a href="http://stackoverflow.com/questions/3989264/best-explanation-for-languages-without-null">Best explanation for Languages without Null</a> on <a href="http://stackoverflow.com/">StackOverflow</a> that has easily become my highest-upvoted-answer ever.&nbsp; Undoubtedly the large <a href="http://stackoverflow.com/faq#bounty">bounty</a> on the question helped attract eyeballs… regardless of why, I’m pleased that my thoughts on this topic garnered so much attention.&nbsp; (It makes up at least a tiny bit for my lack of substantive blogging of late; this is my fifth post in a row that’s light on code or novel ideas.&nbsp; I hope to have some meatier/code-ful topics to blog about soon.)</p>
<p>Enough rambling for now – enjoy PDC this week!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lorgonblog.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lorgonblog.wordpress.com/186/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lorgonblog.wordpress.com&#038;blog=16474804&#038;post=186&#038;subd=lorgonblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lorgonblog.wordpress.com/2010/10/26/pdc-is-just-around-the-corner/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ad588a46e9e78dced5c6dbcf1355bd09?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brianmcn</media:title>
		</media:content>

		<media:content url="http://lorgonblog.files.wordpress.com/2010/10/wlemoticon-smile.png" medium="image">
			<media:title type="html">Smile</media:title>
		</media:content>
	</item>
	</channel>
</rss>
