<?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>Orbifold</title>
	<atom:link href="http://visualizationtools.net/default/feed/" rel="self" type="application/rss+xml" />
	<link>http://visualizationtools.net/default</link>
	<description>Think. Visualize. Understand.</description>
	<lastBuildDate>Wed, 18 Jan 2012 09:08:00 +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>A Nuget package for Processing.js</title>
		<link>http://visualizationtools.net/default/nuget-processing/</link>
		<comments>http://visualizationtools.net/default/nuget-processing/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 08:12:23 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web client]]></category>
		<category><![CDATA[data-visualization]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=5679</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Nuget packages make it easy to add functionality to your applications. Much like adding a WCF service reference, you can add (or update) with a few clicks all sorts of libraries and tools to a Visual Studio project. If you have a website (MVC or standard webforms) you can add various JavaScript libraries; jQuery, RazorJS, fastJSON&#8230;and it&#8217;s so much easier than figuring out the download page, getting it into the correct folder and so on. Since I&#8217;m a big fan of data visualization libraries it&#8217;s a pleasure to have easy access to D3.js in this way, but I was missing for a long time access to Processing.js through the Nuget library. Not anymore. After a bit looking around and agreeing with the good people at <a title="Processing.js" href="http://processingjs.org/" target="_blank">Processing </a>I created/uploaded <a title="Processing.js" href="http://nuget.org/packages/Processing.js" target="_blank">a Nuget package for processing.js</a>.</p>
<p><a href="http://nuget.org/packages/Processing.js"><img class="alignnone size-medium wp-image-5681" title="Nuget Processing.js " src="http://visualizationtools.net/default/wp-content/uploads/2011/12/NugetProcessingScreenshot-300x274.png" alt="" width="300" height="274" /></a></p>
<p>&nbsp;</p>
<h1>1-2-3 example</h1>
<p>Create a website in Visual Studio (I&#8217;ve taken a MVC one here) and right-click on your project, go to the Nuget package manager and search for &#8216;Processing.js&#8217; in the online section</p>
<p><a href="http://nuget.org/packages/Processing.js"><img class="alignnone size-medium wp-image-5682" title="Nuget Package Manager" src="http://visualizationtools.net/default/wp-content/uploads/2011/12/NugetPackageManager-259x300.png" alt="" width="259" height="300" /></a></p>
<p><a href="http://nuget.org/packages/Processing.js"><img class="alignnone size-medium wp-image-5683" title="Nuget Package Manager" src="http://visualizationtools.net/default/wp-content/uploads/2011/12/NugetPackageManager2-300x129.png" alt="" width="300" height="129" /></a></p>
<p>Click on &#8216;Install&#8217; and a couple of JS libraries will be added to your Scripts folder.</p>
<p>Either in your aspx/html or in the &#8216;_layout.cshtml&#8217; file add a reference to the &#8216;Processing.js&#8217; library. You can simply drag-drop the file from the Solution Browser into the text editor and Visual Studio will automatically create the correct reference. From this point on the possibilities are endless, have a look at the <a title="Processing exhibition" href="http://processingjs.org/exhibition" target="_blank">Processing ehibition</a> for instance.</p>
<p>For example, if you wish to add a clock to your page change the &#8216;Index.cshtml&#8217; to the following:</p>
<div class="wp_codebox">
<table>
<tr id="p56791">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre>
</td>
<td class="code" id="p5679code1">
<pre class="xml" style="font-family:monospace;">@{
    ViewBag.Title = &quot;Home Page&quot;;
}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    A simple processing.js clock
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;canvas</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;canvas1&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/canvas<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;script1&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    // Simple way to attach js code to the canvas is by using a function
    function sketchProc(processing) {
        // Override draw function, by default it will be called 60 times per second
        processing.draw = function () {
            // determine center and max clock arm length
            var centerX = processing.width / 2, centerY = processing.height / 2;
            var maxArmLength = Math.min(centerX, centerY);
&nbsp;
            function drawArm(position, lengthScale, weight) {
                processing.strokeWeight(weight);
                processing.line(centerX, centerY,
        centerX + Math.sin(position * 2 * Math.PI) * lengthScale * maxArmLength,
        centerY - Math.cos(position * 2 * Math.PI) * lengthScale * maxArmLength);
            }
&nbsp;
            // erase background
            processing.background(224);
&nbsp;
            var now = new Date();
&nbsp;
            // Moving hours arm by small increments
            var hoursPosition = (now.getHours() % 12 + now.getMinutes() / 60) / 12;
            drawArm(hoursPosition, 0.5, 5);
&nbsp;
            // Moving minutes arm by small increments
            var minutesPosition = (now.getMinutes() + now.getSeconds() / 60) / 60;
            drawArm(minutesPosition, 0.80, 3);
&nbsp;
            // Moving hour arm by second increments
            var secondsPosition = now.getSeconds() / 60;
            drawArm(secondsPosition, 0.90, 1);
        };
&nbsp;
    }
&nbsp;
    var canvas = document.getElementById(&quot;canvas1&quot;);
    // attaching the sketchProc function to the canvas
    var p = new Processing(canvas, sketchProc);
    // p.exit(); to detach it
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;height: 0px; width: 0px; overflow: hidden;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</td>
</tr>
</table>
</div>
<p>Run/display this page and you&#8217;ll get something like the following:</p>
<p><a href="http://nuget.org/packages/Processing.js"><img src="http://visualizationtools.net/default/wp-content/uploads/2011/12/NugetSimpleProcessingApp-300x143.png" alt="" title="Nuget Simple Processing App" width="300" height="143" class="alignnone size-medium wp-image-5687" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/nuget-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The job of the future</title>
		<link>http://visualizationtools.net/default/job-of-the-future/</link>
		<comments>http://visualizationtools.net/default/job-of-the-future/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 16:54:09 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[data-visualization]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=5672</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/29684853?title=0&amp;byline=0&amp;portrait=0" width="400" height="225" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/29684853">The Value of Data Visualization</a> from <a href="http://vimeo.com/columnfive">Column Five</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Finding the needle in the haystack is now more pressing than before. The more data we produce and have access to, the more the need for something intelligent to get the information out of the data becomes important. Obviously the ever-increasing amount of data and the shift to global data stores like the cloud have increased the need for better visualizations techniques and innovative thinking.But the amount of noise has also increased and the need to choose through it. How to filter out of the billions of tweets the stuff that matters to you? The only way to do that is by choosing; what matters to you is related to the things that you choose for and which have a direct relevance in your life (personal or professional). Before the filtering comes the criteria and the criteria are dictated by the business or personal context combined with a more-or-less precise definition of what the solution or answer should be like. Usually a question has many answers or complementary answers, much like a mathematical problem has a one or more solutions depending on the target space within which the solution should be found. </p>
<p>Although I find it refreshing to see that data visualization and presentation techniques are now more important than ever before, it&#8217;s not for myself the reason why this field is interesting or fertile. Data visualization is useful as a product for the end-user or consumer but is equally well interesting for the producer or creative inventor because it combines various fields. Like nothing else you need to be partly an artist, partly a scientist to come up with something beautiful yet meaningful and interesting. You need to understand sometimes deep technical details and exotic programming concepts while having a good understanding of the business context and what a customer needs. You need to fathom the (business) question and at the same time have a vision, which usually means a mixture of intuition and expertise. You need to understand the language of different people and sub-cultures, read through minor details, yet see through the details and go beyond to deliver a broad concept. Having a bird&#8217;s-eye view while knowing the murky details on a low-level demands a mind which can stretch across all levels of thinking. Can you make the simple complex and the complex simple? Can you see color where others see mathematical formula&#8217;s? Can you see sound where others see data and shapes? Can you see code where someone sees motion? Can you see patterns where others see noise? Can you see information where others see data?</p>
<ul>
<li><a href="http://www.visualizing.org/" title="Visualizing" target="_blank">Visualizing.org</a></li>
<li><a href="http://www.informationisbeautiful.net/" title="Information is beautiful" target="_blank">Information is beautiful</a></li>
<li><a href="http://datavisualization.ch/showcases/" title="Data Viz Showcase" target="_blank">Data Visualization Showcase</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/job-of-the-future/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A functional graph library in F#</title>
		<link>http://visualizationtools.net/default/functional-graph-library/</link>
		<comments>http://visualizationtools.net/default/functional-graph-library/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 10:46:56 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[FSharp]]></category>
		<category><![CDATA[Diagramming]]></category>
		<category><![CDATA[F#]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=5636</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s well-know that adjacency lists are the way to go if you wish to model a graph data structure, so we&#8217;ll represent a graph as (node*adjacency list) and include some generic data buckets in the tuple. More precisely</p>
<div class="wp_codebox">
<table>
<tr id="p56362">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre>
</td>
<td class="code" id="p5636code2">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">type</span> Node <span style="color: #a52a2a;">=</span>
    <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #5d478b; font-style: italic;">(* node identifier *)</span> <span style="color: #a52a2a;">*</span>
    <span style="color: #3cb371;">'TDaton (* node data *)
&nbsp;
type Connection&lt;'</span>TDaton<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">=</span>
    <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #5d478b; font-style: italic;">(* source Id *)</span> <span style="color: #a52a2a;">*</span>
    <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #5d478b; font-style: italic;">(* sink Id *)</span> <span style="color: #a52a2a;">*</span>
    <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #5d478b; font-style: italic;">(* weight *)</span> <span style="color: #a52a2a;">*</span>
    <span style="color: #3cb371;">'TDaton (* connection data *)
&nbsp;
type Adjacency&lt;'</span>TDaton<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">=</span>
    Connection<span style="color: #a52a2a;">&lt;</span><span style="color: #3cb371;">'TDaton&gt; list (* a list of connections to other nodes*)
&nbsp;
type Atom&lt;'</span>TNodeDaton, <span style="color: #3cb371;">'TConnectionDaton&gt; =
    Node&lt;'</span>TNodeDaton<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">*</span> Adjacency<span style="color: #a52a2a;">&lt;</span><span style="color: #3cb371;">'TConnectionDaton&gt;
&nbsp;
type Graph&lt;'</span>TNodeDaton, <span style="color: #3cb371;">'TConnectionDaton&gt; =
    Atom&lt;'</span>TNodeDaton, <span style="color: #3cb371;">'TConnectionDaton&gt; list</span></pre>
</td>
</tr>
</table>
</div>
<p>The connections are directed links between nodes and the weight tuple factor is taken out of the generic data bucket in order to make weighted graph analysis possible. One could replace the generic data attached to the connection by an interface which would require a weight property, but here again this would complicate things in code. In any case, in the documentation of the library I have added an example of how to attach polymorphic data buckets to nodes and connections.</p>
<p>The adjacency type is just an alias for a connection list and, finally, the graph is as advertised above just a list of nodes with their adjacency list. The Atom type is a type alias for one single graph (list) element and comes handy in the algorithms.</p>
<p>From these few type definitions you can spend the rest of your life doing graph analysis and implementing all the known (or unknown) graph algorithms; shortest path, Hamiltionian cycles, connected components and so on. At this point the current implementation contains the most used ones and the emphasis was also on having a quick (and easy) way to display the graph (and their properties).</p>
<div class="image-wrap portfolio"><a href="/default/wp-content/uploads/2011/07/FGraphInteractive.png" rel="prettyPhoto" title="FGraph in F# Interactive"><span class="zoom"></span>
<img src="http://visualizationtools.net/default/wp-content/uploads/2011/07/FGraphInteractive-300x173.png" alt="FGraph Interactive" title="FGraph Interactive" width="300" height="173" class="alignnone size-medium wp-image-5643" />
</a></div><p style="clear:both;">&nbsp;</p><p style="clear:both">&nbsp;</p>
<p>Obviously, if you want to implement some graph algorithms you need all the basics like; adding nodes, removing connections, setting node data, fetching upstream and downstream nodes, testing whether a link exists and so on. In addition, you also need a way to easily create graphs or generate random graphs (with a fixed node degree for example). Since most of the graph analysis focuses on paths and structure it&#8217;s often not necessary to adorn the graph with data or weights, hence the possibility to define graphs through a more simple structure:</p>
<div class="wp_codebox">
<table>
<tr id="p56363">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
</pre>
</td>
<td class="code" id="p5636code3">
<pre class="fsharp" style="font-family:monospace;">&nbsp;
<span style="color: #06c; font-weight: bold;">let</span> pregraph <span style="color: #a52a2a;">=</span>
        <span style="color: #6c6;">&#91;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">1</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">2</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">2</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">3</span><span style="color: #a52a2a;">;</span><span style="color: #c6c;">5</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">3</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">4</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">5</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">4</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#93;</span>
<span style="color: #06c; font-weight: bold;">let</span> graph <span style="color: #a52a2a;">=</span> Orbifold.<span style="color: #060;">FGraph</span>.<span style="color: #060;">ParseList</span> pregraph
graph <span style="color: #a52a2a;">|&gt;</span> GraphVisualizer.<span style="color: #060;">Show</span></pre>
</td>
</tr>
</table>
</div>
<p>This will launch the visualizer and produce the following simple graph:</p>
<p><img class="alignnone size-full wp-image-5638" title="a simple graph" src="http://visualizationtools.net/default/wp-content/uploads/2011/07/simplegraph.png" alt="a simple graph" width="547" height="509" /></p>
<p>The power of F# resides in the handling of lists and avoiding loops as one would in C# tremendously helps in situations like this. One should compare the ParseList method implementation with what it would take in C#:</p>
<div class="wp_codebox">
<table>
<tr id="p56364">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre>
</td>
<td class="code" id="p5636code4">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">///&lt;summary&gt;Parses a simple list made out of tuples of (int, int list). The first integer is the index and the list is the list of nodes indices to which the current node is connected.&lt;/summary&gt;</span>
<span style="color: #06c; font-weight: bold;">let</span> ParseList <span style="color: #6c6;">&#40;</span>list : <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">int</span><span style="color: #a52a2a;">*</span> <span style="color: #06c; font-weight: bold;">int</span> list<span style="color: #6c6;">&#41;</span> list<span style="color: #6c6;">&#41;</span> : Graph<span style="color: #a52a2a;">&lt;</span>Object,Object<span style="color: #a52a2a;">&gt;=</span>
        <span style="color: #06c; font-weight: bold;">let</span> g <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">ref</span> Graph.<span style="color: #060;">Empty</span>
        <span style="color: #06c; font-weight: bold;">let</span> linkedIds: <span style="color: #06c; font-weight: bold;">int</span> list <span style="color: #06c; font-weight: bold;">ref</span> <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">ref</span> <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#93;</span>
        <span style="color: #06c; font-weight: bold;">let</span> containsNumber number list <span style="color: #a52a2a;">=</span> <a href="http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/namespaces.html"><span style="color: #06c; font-weight: bold;">List</span></a>.<span style="color: #060;">exists</span> <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> elem <span style="color: #a52a2a;">-&gt;</span> elem <span style="color: #a52a2a;">=</span> number<span style="color: #6c6;">&#41;</span> list
        g.<span style="color: #060;">Value</span> <span style="color: #a52a2a;">&lt;-</span> <span style="color: #6c6;">&#40;</span>list <span style="color: #a52a2a;">|&gt;</span> <a href="http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/namespaces.html"><span style="color: #06c; font-weight: bold;">List</span></a>.<span style="color: #060;">map</span> <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> <span style="color: #6c6;">&#40;</span>idx,adjs<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">-&gt;</span>
                                <span style="color: #06c; font-weight: bold;">let</span> newNode : Node<span style="color: #a52a2a;">&lt;</span>Object<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#40;</span>idx, <span style="color: #06c; font-weight: bold;">null</span><span style="color: #6c6;">&#41;</span>
                                <span style="color: #06c; font-weight: bold;">let</span> ad <span style="color: #a52a2a;">=</span> <a href="http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/namespaces.html"><span style="color: #06c; font-weight: bold;">List</span></a>.<span style="color: #060;">map</span> <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> t<span style="color: #a52a2a;">-&gt;</span>
                                                        <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #06c; font-weight: bold;">not</span> <span style="color: #6c6;">&#40;</span>containsNumber t <span style="color: #a52a2a;">!</span>linkedIds<span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">then</span> linkedIds.<span style="color: #060;">Value</span><span style="color: #a52a2a;">&lt;-</span> t::<span style="color: #a52a2a;">!</span>linkedIds
                                                        <span style="color: #06c; font-weight: bold;">let</span> con : Connection<span style="color: #a52a2a;">&lt;</span>Object<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#40;</span>idx,t,<span style="color: #c6c;">0</span>,<span style="color: #06c; font-weight: bold;">null</span><span style="color: #6c6;">&#41;</span>
                                                        con
                                                   <span style="color: #6c6;">&#41;</span> adjs
                                <span style="color: #06c; font-weight: bold;">let</span> atom : Atom<span style="color: #a52a2a;">&lt;</span>Object,Object<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#40;</span>newNode,ad<span style="color: #6c6;">&#41;</span>
                                atom
                          <span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span>
        <span style="color: #5d478b; font-style: italic;">(*we auto-add the node if it appears in the connections*)</span>
        linkedIds.<span style="color: #060;">Value</span> <span style="color: #a52a2a;">|&gt;</span> <a href="http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/namespaces.html"><span style="color: #06c; font-weight: bold;">List</span></a>.<span style="color: #060;">iter</span> <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> t <span style="color: #a52a2a;">-&gt;</span>
                                             <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #06c; font-weight: bold;">not</span> <span style="color: #6c6;">&#40;</span>NodeExists t <span style="color: #a52a2a;">!</span>g<span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">then</span>
                                                            <span style="color: #06c; font-weight: bold;">let</span> n : Node<span style="color: #a52a2a;">&lt;</span>Object<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#40;</span>t,<span style="color: #06c; font-weight: bold;">null</span><span style="color: #6c6;">&#41;</span>
                                                            <span style="color: #06c; font-weight: bold;">let</span> c : Adjacency<span style="color: #a52a2a;">&lt;</span>Object<span style="color: #a52a2a;">&gt;</span> <span style="color: #a52a2a;">=</span> <span style="color: #6c6;">&#91;</span><span style="color: #6c6;">&#93;</span>
                                                            g.<span style="color: #060;">Value</span><span style="color: #a52a2a;">&lt;-</span><span style="color: #6c6;">&#40;</span>n,c<span style="color: #6c6;">&#41;</span>::<span style="color: #a52a2a;">!</span>g
                                      <span style="color: #6c6;">&#41;</span>
        g.<span style="color: #060;">Value</span></pre>
</td>
</tr>
</table>
</div>
<p>The interesting part of the library sits in the analysis module where one encounters the unavoidable traversals and where I tried to also implement useful variants like the depth-first traversal of edges:</p>
<div class="wp_codebox">
<table>
<tr id="p56365">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre>
</td>
<td class="code" id="p5636code5">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> DFTEdgeVisit <span style="color: #6c6;">&#40;</span>g:Graph<span style="color: #a52a2a;">&lt;</span>_,_<span style="color: #a52a2a;">&gt;</span><span style="color: #6c6;">&#41;</span> <span style="color: #6c6;">&#40;</span>start:<span style="color: #06c; font-weight: bold;">int</span><span style="color: #6c6;">&#41;</span> <span style="color: #6c6;">&#40;</span>processEdge: <span style="color: #06c; font-weight: bold;">int</span><span style="color: #a52a2a;">*</span>int<span style="color: #a52a2a;">-&gt;</span><span style="color: #06c; font-weight: bold;">unit</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span>
        <span style="color: #06c; font-weight: bold;">let</span> nextToVisit <span style="color: #a52a2a;">=</span> Stack<span style="color: #a52a2a;">&lt;</span><span style="color: #06c; font-weight: bold;">int</span><span style="color: #a52a2a;">&gt;</span><span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span>
        <span style="color: #06c; font-weight: bold;">let</span> discovered <span style="color: #a52a2a;">=</span> HashSet<span style="color: #a52a2a;">&lt;</span><span style="color: #06c; font-weight: bold;">int</span><span style="color: #a52a2a;">&gt;</span><span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span>
        <span style="color: #06c; font-weight: bold;">let</span> v <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">ref</span> <span style="color: #c6c;">0</span> <span style="color: #5d478b; font-style: italic;">(* current vertex *)</span>
        <span style="color: #06c; font-weight: bold;">ignore</span><span style="color: #6c6;">&#40;</span>nextToVisit.<span style="color: #060;">Push</span><span style="color: #6c6;">&#40;</span>start<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span>
        <span style="color: #06c; font-weight: bold;">ignore</span><span style="color: #6c6;">&#40;</span>discovered.<span style="color: #060;">Add</span><span style="color: #6c6;">&#40;</span>start<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span>
        <span style="color: #06c; font-weight: bold;">let</span> parents <span style="color: #a52a2a;">=</span> Dictionary<span style="color: #a52a2a;">&lt;</span><span style="color: #06c; font-weight: bold;">int</span>,<span style="color: #06c; font-weight: bold;">int</span><span style="color: #a52a2a;">&gt;</span><span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span>
        <span style="color: #06c; font-weight: bold;">while</span> nextToVisit.<span style="color: #060;">Count</span> <span style="color: #a52a2a;">&gt;</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">do</span>
            v.<span style="color: #060;">Value</span> <span style="color: #a52a2a;">&lt;-</span> nextToVisit.<span style="color: #060;">Pop</span><span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span>
            <span style="color: #06c; font-weight: bold;">if</span> parents.<span style="color: #060;">ContainsKey</span><span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">!</span>v<span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">then</span> processEdge <span style="color: #6c6;">&#40;</span>parents.<span style="color: #6c6;">&#91;</span><span style="color: #a52a2a;">!</span>v<span style="color: #6c6;">&#93;</span>,<span style="color: #a52a2a;">!</span>v<span style="color: #6c6;">&#41;</span>
            <span style="color: #06c; font-weight: bold;">let</span> someDescendants <span style="color: #a52a2a;">=</span> GetDescendants <span style="color: #a52a2a;">!</span>v g
            <span style="color: #06c; font-weight: bold;">match</span> someDescendants <span style="color: #06c; font-weight: bold;">with</span>
            |None <span style="color: #a52a2a;">-&gt;</span> <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span>
            |Some<span style="color: #6c6;">&#40;</span>desc<span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">-&gt;</span> <a href="http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/namespaces.html"><span style="color: #06c; font-weight: bold;">List</span></a>.<span style="color: #060;">iter</span> <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> d <span style="color: #a52a2a;">-&gt;</span> <span style="color: #06c; font-weight: bold;">if</span> <span style="color: #06c; font-weight: bold;">not</span> <span style="color: #6c6;">&#40;</span>discovered.<span style="color: #060;">Contains</span><span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fst</span> d<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span> <span style="color: #06c; font-weight: bold;">then</span>
                                                                                    <span style="color: #06c; font-weight: bold;">ignore</span><span style="color: #6c6;">&#40;</span>parents.<span style="color: #060;">Add</span><span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fst</span> d,<span style="color: #a52a2a;">!</span>v<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span>
                                                                                    <span style="color: #06c; font-weight: bold;">ignore</span><span style="color: #6c6;">&#40;</span>discovered.<span style="color: #060;">Add</span><span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fst</span> d<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span>
                                                                                    <span style="color: #06c; font-weight: bold;">ignore</span><span style="color: #6c6;">&#40;</span>nextToVisit.<span style="color: #060;">Push</span><span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">fst</span> d<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span> <span style="color: #6c6;">&#40;</span><a href="http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/namespaces.html"><span style="color: #06c; font-weight: bold;">List</span></a>.<span style="color: #060;">rev</span> desc<span style="color: #6c6;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>Here again, one would use in C# Action<> parameters for the visitors but in F# things are made easy since functions and variables are on the same footing.</p>
<p>Some of the algorithms, like the shortest path between two nodes, are quite straightforward in C# but are really an headache when trying to convert to purely functional analogs. At this points the library does its best to honour the functional paradigm (also because often it represents immense performance gains w.r.t. the more linear non-functional versions) but sometimes the traditional algorithms are more readable and hence more accessible for developers who wish to alter the code. </p>
<p>Finally, I&#8217;d like to highlight the graph visualization part which resides in a separate library. When experimenting with F# and graphs in the F# interactive mode you can easily display the graph by feeding it to the <strong>GraphVisualizer.Show</strong> method:</p>
<div class="wp_codebox">
<table>
<tr id="p56366">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
</pre>
</td>
<td class="code" id="p5636code6">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> g <span style="color: #a52a2a;">=</span>
        <span style="color: #6c6;">&#91;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">1</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">2</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">2</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">3</span><span style="color: #a52a2a;">;</span><span style="color: #c6c;">5</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">3</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">4</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#40;</span><span style="color: #c6c;">5</span>, <span style="color: #6c6;">&#91;</span><span style="color: #c6c;">4</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span><span style="color: #a52a2a;">;</span>
        <span style="color: #6c6;">&#93;</span>
g <span style="color: #a52a2a;">|&gt;</span> GraphVisualizer.<span style="color: #060;">Show</span><span style="color: #a52a2a;">;;</span>
GraphVisualizer.<span style="color: #060;">ShowShortestPath</span><span style="color: #6c6;">&#40;</span><span style="color: #c6c;">1</span>,<span style="color: #c6c;">4</span>,g<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;;</span></pre>
</td>
</tr>
</table>
</div>
<p>You can also use the graph visualizer as a WPF component in your application. The control is a classic MVVM control with an ItemsSource accepting a Graph structure. Typically you&#8217;d use it as follows:</p>
<div class="wp_codebox">
<table>
<tr id="p56367">
<td class="line_numbers">
<pre>1
</pre>
</td>
<td class="code" id="p5636code7">
<pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Visualizer:GraphControl</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;Diagram&quot;</span> <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Tension</span>=<span style="color: #ff0000;">&quot;{Binding Value, ElementName=TensionSlider}&quot;</span> <span style="color: #000066;">ItemsSource</span>=<span style="color: #ff0000;">&quot;{Binding Graph}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
</td>
</tr>
</table>
</div>
<p>where the tension determines the tension between the node in the spring-embedder layout algorithm. I&#8217;ll add some more layout algorithms in the next pass (tree layout variations in particular).</p>
<p>The WPF component also has easy access to the analysis like for example the shortes path:</p>
<div class="wp_codebox">
<table>
<tr id="p56368">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre>
</td>
<td class="code" id="p5636code8">
<pre class="fshapr" style="font-family:monospace;">let g2 = Graph.ParseList [
                            (1, [3;6;9]);
                            (2, [4]);
                            (3, [2;5]);
                            (5, [20]);
                            (6, [7;8]);
                            (7, [12]);
                            (9, [10;11]);
                            (12, [13]);
                            (20, [12]);
&nbsp;
                        ]
this.Graph &lt;- Graph.Analysis.ColorizeShortestPath( 1,13, g2)</pre>
</td>
</tr>
</table>
</div>
<p>where &#8220;this.Graph&#8221; is here the MVVM property of the model bound to the GraphControl. The result would be the picture below.<br />
<img src="http://visualizationtools.net/default/wp-content/uploads/2011/07/shortestpath.png" alt="shortest path visualization" title="shortest path visualization" width="572" height="571" class="alignnone size-full wp-image-5639" /></p>
<p>Some final remarks and questions regarding this project:</p>
<ul>
<li>all&#8217;s F#; the custom diagramming control, the library and the MVVM stuff. It would make sense to use this library in a C# context (to benefit from the F# performance) but I haven&#8217;t put any energy in this. Not sure it&#8217;s a priority since our other libraries (<a href="/G2" title="G2 library" target="_blank">G2</a>, <a href="/Lynx" title="Lynx library" target="_blank">Lynx</a>) contain all this as well. </li>
<li>this is work in progress and I spend a lot of time documenting things as well as creating sample code, I reckon things will settle by September this year.</li>
<li>making this open source would be a good thing for the community but I&#8217;ll have to sleep over it. You can try to convince me.</li>
<li>the WPF control is a templated control and can be customized. On the other hand, the arrow and node visual are hard coded. It could be useful to template them as well and in this fashion enable databinding of the databuckets defined above to the visuals. However, this library is not a full-fledged Visio replacement, rather it focuses on graph analysis. Does is make sense to invent a mechanism to enable more line-of-business scenario&#8217;s? I think our existing graph libraries are filling the need there. The only reason I would put energy in this is that at this moment there is no graph visualization library for F# on the market. </li>
<li>What about Silverlight? Well, I don&#8217;t see a technical issue there but I am less sure about the audience doing Silverlight development in F#. Is there an audience for this?</li>
</ul>
<p>Thanks to <a href="http://tomasp.net/" title="Tomas Petricek" target="_blank">Tomas Petricek</a> for some useful suggestions and the <a href="http://www.ffconsultancy.com/" title="Flying Frog Consulting" target="_blank">Flying Frog</a> for insightful directions.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/functional-graph-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Categories, monads and F# for dummies</title>
		<link>http://visualizationtools.net/default/categories-for-dummies/</link>
		<comments>http://visualizationtools.net/default/categories-for-dummies/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 12:19:58 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[FSharp]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Mathematics]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=5554</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>This is an article to stir your curiosity about monads, categories and functional programming. I didn&#8217;t try to make it mathematically correct and it&#8217;s not a precise treatment of monads from the functional programming point of view. It&#8217;s only to help you understand and appreciate the unifying power of monads as they appear in the context of F# and Haskell. I also think there is a widely spread confusion around monads and the fact that diverse concepts are mixed up:</p>
<ul>
<li>is a computational expression the same as a workflow, is it a monad?</li>
<li>how do math articles about monads map to articles about functional programming?</li>
<li>are the methods defined by F# as part of a computation expression dictated by the idea of a monad? How to translate the concepts from categories to functional programming and back?</li>
<li>why should I care about monads, they never appear in C# or JavaScript&#8230;!?</li>
<li>how can the Haskell or OCaml stuff be translated to F#? Though Haskell has a whole lot of info regarding monads, it&#8217;s not always easy to see how it maps to the F# syntax or way of thinking.</li>
</ul>
<p>Let me say straight away that understanding monads will not directly solve your marketing challenges, nor will it make writing software easier, not is it a magical recipe to simplify the data access layer of your website. However, it does</p>
<ul>
<li><strong>make you a better programmer</strong> in the same way that learning design patterns (anti-pattern etc.) teaches you to recognize structures and solutions on a higher level of abstraction</li>
<li><strong>shed light on the relationship between domains which seem unrelated</strong> (exception handling, state management, graphs and networks, asynchronous calls, domain specific languages and so on)</li>
<li>suggest you to <strong>rethink software structures</strong> and how typical programming challenges are solved</li>
<li>open up a large field of ideas in the overlap of software development and maths which are fun to explore.</li>
</ul>
<p>I don&#8217;t expect to see monadic stuff appear in Silverlight animations or in CSS style sheets but for sure you&#8217;ll see it appear in</p>
<ul>
<li>the NoSQL movement and graph analysis algorithms</li>
<li>the financial and insurance business where F# is at this moment a big hit</li>
<li>DSL developments and meta-programming</li>
</ul>
<p>and who knows what the future brings?</p>
<h2>A simple idea</h2>
<p>We are surrounded by data collections and structures, sets of interrelated data and hierarchies:</p>
<ul>
<li>a family and its members where relationships are defined by concepts like father, mother, sister, uncle and so on</li>
<li>company hierarchies with employees and relationships defined by team structures, divisions and so on</li>
<li>modules of code and calling/instantiation relations where exceptions are bubbling from down the stack to the upper (UI level if not properly handled) parts</li>
<li>algorithmic financial transactions (flows) based on some intricate logic</li>
</ul>
<p>and on a more scientific level even more where one notices certain similarities and intriguing analogies:</p>
<ul>
<li>genes and memes: the formation of genetic structures vs. the formation of thoughts and ideas</li>
<li>the spreading of viral diseases vs. the spreading of computer viruses</li>
<li>the six-degrees of freedom appearing on the internet vs. the plex of actors in the IMDB database</li>
</ul>
<p>In a lot of cases similarities are just accidental (it&#8217;s because a banana and a lemon are yellow that there is deep connection, except the shared pigment) but there are equally well amazing symmetries which can be made precise. Category theory is a theory which makes this idea of &#8216;being similar&#8217; exact and at the heart of it is really a very simple notion:</p>
<ul>
<li>you have <strong>collection </strong>of objects</li>
<li>a collection has a certain <strong>structure</strong></li>
<li>you can <strong>map </strong>objects from one collection to another and the relationship can also be mapped.</li>
</ul>
<p><a href="http://visualizationtools.net/default/wp-content/uploads/2011/06/CategoryIdea.png"><img class="alignnone size-full wp-image-5557" title="Category Idea" src="http://visualizationtools.net/default/wp-content/uploads/2011/06/CategoryIdea.png" alt="Category Idea" width="469" height="287" /></a></p>
<table style="border: 1px solid #6B8B99; float: none; width: 90%;">
<tbody>
<tr style="background-color: #6b8b99;">
<th style="color: #fff;"> <strong>Example </strong></th>
</tr>
<tr>
<td>Take the members of a family (with their relationships; mother, father etc.) and take the employees in a company with its hierarchy. Can you create a mapping from one collection to the other? If your thinking is more in terms of pictures and visuals you&#8217;ll probably starts drawing a graph and map the nodes and edges from one graph to the other. This is no accident, graphs and mappings from one graph onto another is a good playground to study categories.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<table style="border: 1px solid #6B8B99; float: none; width: 90%;">
<tbody>
<tr style="background-color: #6b8b99;">
<th style="color: #fff;"> <strong>Example </strong></th>
</tr>
<tr>
<td>Take some business logic and imagine that at some point an exception is thrown; it propagates through the logic to end up being caught (or not). Take, on the other hand, the stateful (call it state-machine if you prefer) flow of an online ordering system where you are guided through a wizard to check out and buy some goods (like you&#8217;d do on Amazon). Is there some underlying structure governing these two systems? Probably this would take you somewhat longer than the previous example and it also requires a bit more abstraction, but the answer is &#8216;yes&#8217; there is a mapping (i.e. a mathematically exact symmetry) between the two.State machines (<a title="Automata" href="http://en.wikipedia.org/wiki/Automata_theory" target="_blank">automata</a>) and the way exceptions or infinities can be handled in code have a common mathematical underpinning.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>From this we take a bold step a define a (pedestrian) category as follows (more precise definition below):</p>
<table style="border: 1px solid #D94D23; float: none; width: 90%;">
<tbody>
<tr style="background-color: #d94d23;">
<th style="color: #fff;"> <strong>Definition</strong></th>
</tr>
<tr>
<td><em>A <strong>category </strong>is a collection of objects with some relationships. The objects in the collection are called (duh!) <strong>objects </strong>and the relationships are called <strong>morphisms</strong>. A mapping between two categories is called a <strong>functor</strong>.</em></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Maybe it should be called at this point a pedestrian category or something because this is of course not very precise; this definition would turn pretty much everything into categories and functors! At this point I only want to help you understand where the real maths and the hard F# stuff is coming from and make it more acceptable.</p>
<p>A <strong>morphism </strong>is something which morphs one thing into another, something which transfers one thing into another. You will also encounter in the literature similar concepts like</p>
<ul>
<li><strong>homomorphism</strong>: it emphasizes even more the idea of morphing. The prefix &#8216;homo&#8217; meaning &#8216;the same&#8217; and &#8216;morph&#8217; means &#8216;changing&#8217;. Technically speaking the term homomorphism comes from group theory and morphism refers to the more general idea which can be applied outside group theory and Lie groups.</li>
<li><strong>endomorphism</strong>: &#8216;endo&#8217; means &#8216;in itself&#8217; and this emphasizes that a morphism is not going somewhere else but stays in the same package. So, an endomorphism of a family would map one person onto another inside the same family. A morphism would in general morph one family onto another.</li>
<li><strong>epimorphism</strong>: here the emphasis is on the fact that the morphism reaches the whole target collection.</li>
<li><strong>isomorphism</strong>: in this case the morphism is mapping elements one-to-one and onto the target. The notion is a very important one and appears pretty much everywhere in maths and science. In essence it says that if two things are isomorphic they are indistinguishable from one another and anything.everything you say about one is valid for the other.</li>
</ul>
<h2>Some more simple examples</h2>
<p>In order to move away from the heuristics above towards some more serious definitions I need to highlight more (simple) examples.</p>
<table style="border: 1px solid #6B8B99; float: none; width: 90%;">
<tbody>
<tr style="background-color: #6b8b99;">
<th style="color: #fff;"> <strong>Example </strong></th>
</tr>
<tr>
<td>Take the collection of sets and the mappings between sets. This is a category where the mappings are the morphisms (morphings) and it&#8217;s often denoted with <strong>Set</strong> (in bold). An endofunctor F here is, for example, a mapping into itself which maps a set, say S, to the set of subsets:</p>
<p><img src='http://s0.wp.com/latex.php?latex=F%3A+S+%5Crightarrow+2%5ES+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='F: S &#92;rightarrow 2^S ' title='F: S &#92;rightarrow 2^S ' class='latex' /></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<table style="border: 1px solid #6B8B99; float: none; width: 90%;">
<tbody>
<tr style="background-color: #6b8b99;">
<th style="color: #fff;"> <strong>Example </strong></th>
</tr>
<tr>
<td>Take the real number (floats, if you prefer) with an operation called &#8216;addition&#8217;. Take the same real number with an operation called &#8216;multiplication&#8217;. We call them objects in the category of &#8216;real numbers with an operation&#8217;. A morphism f between the two objects is<br />
<img src='http://s0.wp.com/latex.php?latex=f%3A+%5Cmathbb%7BR%7D%2C%2B+%5Crightarrow+%5Cmathbb%7BR%7D%2C+x+%5Cmapsto+e%5Ex.&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='f: &#92;mathbb{R},+ &#92;rightarrow &#92;mathbb{R}, x &#92;mapsto e^x.' title='f: &#92;mathbb{R},+ &#92;rightarrow &#92;mathbb{R}, x &#92;mapsto e^x.' class='latex' /><br />
This morphism has the amazing property that:<br />
<img src='http://s0.wp.com/latex.php?latex=f%28x%2By%29+%3D+f%28x%29.f%28y%29.&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='f(x+y) = f(x).f(y).' title='f(x+y) = f(x).f(y).' class='latex' /><br />
and this property is shared with many other types of collections. In addition, you should also notice that zero is mapped to one and that zero is the identity (null element) for the addition while the number one is the identity for the multiplication.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<table style="border: 1px solid #6B8B99; float: none; width: 90%;">
<tbody>
<tr style="background-color: #6b8b99;">
<th style="color: #fff;"> <strong>Example </strong></th>
</tr>
<tr>
<td>Take the collection of lists of strings (List in C# and &#8216;string List&#8217; in F#) and consider the morphism called &#8216;concatenation&#8217; between lists. Take the collection of lists of integers on the other hand and with the same concatenation of of lists as with the string collection. A functor here is the <strong>List.map</strong> operation of F# and you should note that it doesn&#8217;t matter whether you concatenate things first and then apply the map or first apply the map and then concatenate things. In a mathematical fashion you can write that if F is the List.map action and f, g are morphisms then<br />
<img src='http://s0.wp.com/latex.php?latex=F%28f.g%29+%3D+F%28f%29.F%28g%29+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='F(f.g) = F(f).F(g) ' title='F(f.g) = F(f).F(g) ' class='latex' /></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<table style="border: 1px solid #6B8B99; float: none; width: 90%;">
<tbody>
<tr style="background-color: #6b8b99;">
<th style="color: #fff;"> <strong>Example </strong></th>
</tr>
<tr>
<td>The collection of data types in .Net is a category so is the collection of data types in Haskell (usually denoted by <strong>Hask</strong>). Let&#8217;s call this category <strong>Net</strong>. There is a useful lifting procedure or amplifier inside the collection; take any type and map it to a collection of this same type:</p>
<p><img src='http://s0.wp.com/latex.php?latex=Amp%3A+T+%5Cmapsto+List%3C+T%3E&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='Amp: T &#92;mapsto List&lt; T&gt;' title='Amp: T &#92;mapsto List&lt; T&gt;' class='latex' /></p>
<p>Note that you can iterate this, even though in practice you won&#8217;t often see a List&lt;List&lt;List&lt;T&gt;&gt;&gt; type defined in an application. The things is, this is an endofunctor of <strong>the category Net </strong>into <strong>Net</strong>.</td>
</tr>
</tbody>
</table>
<h2>Some simple list manipulations</h2>
<p>There are some well-know examples of categories and monads like the so-called maybe monad, the identity monad and the state monad but I think the easiest way to explore or check the ideas is by means of the <strong>concat monad</strong> over the category of lists of integers, called from here on <strong>List</strong> (in bold). It consists of the following:</p>
<ul>
<li><strong>sets and subsets of integers</strong>: [], [1], [1;2;3], [[1], [5;6]]&#8230;are examples of objects in this category</li>
<li>the <strong>return operation</strong> which returns a singleton set from any given element<br />
<img src='http://s0.wp.com/latex.php?latex=return%3A+x+%5Cmapsto+%5Bx%5D&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='return: x &#92;mapsto [x]' title='return: x &#92;mapsto [x]' class='latex' /></li>
<li>the <strong>identity operator</strong> which returns whatever is given:<br />
<img src='http://s0.wp.com/latex.php?latex=id%3A+x+%5Cmapsto+x+%5Cnewline++id%3A+%5Bx%5D%5Cmapsto+%5Bx%5D++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='id: x &#92;mapsto x &#92;newline  id: [x]&#92;mapsto [x]  ' title='id: x &#92;mapsto x &#92;newline  id: [x]&#92;mapsto [x]  ' class='latex' /></li>
<li>the<strong> concatenation operator</strong> which concatenates list:<br />
<img src='http://s0.wp.com/latex.php?latex=concat%3A+%5B%5Ba%5D%2C%5Bb%5D%5D+%5Cmapsto+%5Ba%2Cb%5D&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='concat: [[a],[b]] &#92;mapsto [a,b]' title='concat: [[a],[b]] &#92;mapsto [a,b]' class='latex' /></li>
</ul>
<p>Now, you can play with these operations and discover some interesting properties like the fact that:</p>
<table style="border: 1px solid #A7BD5B; float: none; width: 90%;">
<tbody>
<tr style="background-color: #a7bd5b; color: #fff;">
<th> Property</th>
</tr>
<tr>
<td><img src='http://s0.wp.com/latex.php?latex=concat+.+concat+%3D+concat+.+%28List.map%29%28concat%29&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='concat . concat = concat . (List.map)(concat)' title='concat . concat = concat . (List.map)(concat)' class='latex' /></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Indeed if you take an arbitrary set, say [[[a];[b]];[[c;d];[[f]]], an apply the left hand side you get:</p>
<p><img src='http://s0.wp.com/latex.php?latex=concat%28concat%28%5B%5B%5Ba%5D%3B%5Bb%5D%5D%3B%5B%5Bc%3Bd%5D%3B%5B%5Bf%5D%5D%5D%29%29%5Cnewline++%3D+concat%28+%5B%5Ba%5D%3B%5Bb%5D%3B%5Bc%3Bd%5D%3B%5Bf%5D%5D%29%5Cnewline++%3D+%5Ba%3Bb%3Bc%3Bd%3Bf%5D++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='concat(concat([[[a];[b]];[[c;d];[[f]]]))&#92;newline  = concat( [[a];[b];[c;d];[f]])&#92;newline  = [a;b;c;d;f]  ' title='concat(concat([[[a];[b]];[[c;d];[[f]]]))&#92;newline  = concat( [[a];[b];[c;d];[f]])&#92;newline  = [a;b;c;d;f]  ' class='latex' /><br />
The other side of the equation tells you that:</p>
<p><img src='http://s0.wp.com/latex.php?latex=concat+.+%28List.map%29%28concat%29%28%5B%5B%5Ba%5D%3B%5Bb%5D%5D%3B%5B%5Bc%3Bd%5D%3B%5B%5Bf%5D%5D%5D%29%5Cnewline++%3D+concat%28+%5B%5Ba%3Bb%5D%3B%5Bc%3Bd%3Bf%5D%5D%29%5Cnewline++%3D+%5Ba%3Bb%3Bc%3Bd%3Bf%5D++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='concat . (List.map)(concat)([[[a];[b]];[[c;d];[[f]]])&#92;newline  = concat( [[a;b];[c;d;f]])&#92;newline  = [a;b;c;d;f]  ' title='concat . (List.map)(concat)([[[a];[b]];[[c;d];[[f]]])&#92;newline  = concat( [[a;b];[c;d;f]])&#92;newline  = [a;b;c;d;f]  ' class='latex' /></p>
<p>In a similar fashion you can show that</p>
<table style="border: 1px solid #A7BD5B; float: none; width: 90%;">
<tbody>
<tr style="background-color: #a7bd5b; color: #fff;">
<th> Property</th>
</tr>
<tr>
<td><img src='http://s0.wp.com/latex.php?latex=concat.+return+%3D+id%3D+concat.%28List.map%29%28return%29++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='concat. return = id= concat.(List.map)(return)  ' title='concat. return = id= concat.(List.map)(return)  ' class='latex' /></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Now, let&#8217;s introduce a *-operator which acts on morphisms f in the List category:<br />
<img src='http://s0.wp.com/latex.php?latex=f%5E%2A+%3D+concat.%28List.map%29%28f%29+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='f^* = concat.(List.map)(f) ' title='f^* = concat.(List.map)(f) ' class='latex' /></p>
<p>This star-operator has also some interesting features which immediately generalize to arbitrary monads later on, namely:</p>
<table style="border: 1px solid #A7BD5B; float: none; width: 90%;">
<tbody>
<tr style="background-color: #a7bd5b; color: #fff;">
<th> Property</th>
</tr>
<tr>
<td><img src='http://s0.wp.com/latex.php?latex=return%5E%2A%3D+id%5Cnewline++f%5E%2A+.+return+%3D+f%5Cnewline++g%5E%2A.f%5E%2A%3D%28g%5E%2A.f%29%5E%2A+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='return^*= id&#92;newline  f^* . return = f&#92;newline  g^*.f^*=(g^*.f)^* ' title='return^*= id&#92;newline  f^* . return = f&#92;newline  g^*.f^*=(g^*.f)^* ' class='latex' /></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>All these things are really easy to show inside this List category but have a deeper meaning on a general level.</p>
<h2>Some simple maths</h2>
<p>At this point you are ready to receive the general definition of a category and a monad.</p>
<table style="border: 1px solid #D94D23; float: none; width: 90%;">
<tbody>
<tr style="background-color: #d94d23;">
<th style="color: #fff;"> <strong>Definition</strong></th>
</tr>
<tr>
<td>A <strong>category </strong>consists of three things (aka triplet):</p>
<ul>
<li>a collection of <strong>objects</strong></li>
<li>a collection of <strong>morphisms </strong>f between the objects</li>
<li>a <strong>binary operation</strong> (which tunrs the structure in a so-called monoid) inside the collection such that<br />
<img src='http://s0.wp.com/latex.php?latex=f.%28g.h%29+%3D+%28f.g%29.h+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='f.(g.h) = (f.g).h ' title='f.(g.h) = (f.g).h ' class='latex' /><br />
and an identity which keeps things identitical<br />
<img src='http://s0.wp.com/latex.php?latex=id.f+%3D+f.id+%3D+f+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='id.f = f.id = f ' title='id.f = f.id = f ' class='latex' /></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>The only difference here with the pedestrian definition above is that morphism need to satisfy the associative constraint and the existence of an identity.</p>
<table style="border: 1px solid #D94D23; float: none; width: 90%;">
<tbody>
<tr style="background-color: #d94d23;">
<th style="color: #fff;"> <strong>Definition</strong></th>
</tr>
<tr>
<td>A <strong>functor </strong>is a map F from one category to another which maps both objects and morphisms in such a way that<br />
<img src='http://s0.wp.com/latex.php?latex=F+.+id+%3D+id.F%5Cnewline++F%28f%29.F%28g%29+%3D+F%28f.g%29++++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='F . id = id.F&#92;newline  F(f).F(g) = F(f.g)    ' title='F . id = id.F&#92;newline  F(f).F(g) = F(f.g)    ' class='latex' /></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>At this point you should see how this abstract definition corresponds to the various examples above, in particular the <strong>List </strong>category in the previous section. In the literature you will also see that the collection of morphisms between two objects A and B is denoted by <strong>Hom(A,B)</strong>, which is an abbreviation for &#8216;Hom-omorphisms&#8217;.</p>
<p>In the previous section you was that the List category of integers has some interesting features when you combine the (List.map), the return, the id and the concat operations. The general definition of a monad is simply expressing the fact that many structures have the same set of properties. Let me first rephrase it in this specific category;</p>
<p>The <strong>List </strong>category has</p>
<ul>
<li>an operation (actually an endofunctor) (List.map) which maps lists onto lists</li>
<li>the return operation creates a singleton from an element</li>
<li>the concat operation together with the return operation has the following properties:<br />
<img src='http://s0.wp.com/latex.php?latex=concat.+return+%3D+id%3D+concat.%28List.map%29%28return%29+%5Cnewline++concat+.+concat+%3D+concat+.+%28List.map%29%28concat%29++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='concat. return = id= concat.(List.map)(return) &#92;newline  concat . concat = concat . (List.map)(concat)  ' title='concat. return = id= concat.(List.map)(return) &#92;newline  concat . concat = concat . (List.map)(concat)  ' class='latex' /></li>
</ul>
<p>and this turns the triple (List.map, return, concat) into a monad.</p>
<p>In general, <strong>a monad is a triple which satisfies the same set of properties and you&#8217;ll see instead of concat and return the following</strong>:</p>
<table style="border: 1px solid #D94D23; float: none; width: 90%;">
<tbody>
<tr style="background-color: #d94d23;">
<th style="color: #fff;"> <strong>Definition</strong></th>
</tr>
<tr>
<td>A monad is a category C together with&nbsp;</p>
<ul>
<li> an <strong>endofunctor </strong>T from C to C</li>
<li>a transformation <img src='http://s0.wp.com/latex.php?latex=%5Ceta%3A+C%5Crightarrow+T&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='&#92;eta: C&#92;rightarrow T' title='&#92;eta: C&#92;rightarrow T' class='latex' /></li>
<li>a transformation <img src='http://s0.wp.com/latex.php?latex=%5Cmu%3A+T%5E2%5Cmapsto+T&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='&#92;mu: T^2&#92;mapsto T' title='&#92;mu: T^2&#92;mapsto T' class='latex' /></li>
</ul>
<p>satisfying</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cmu+.+%5Cmu+%3D+%5Cmu+.+T+%28%5Cmu%29%5Cnewline++%5Cmu+.+%5Ceta+%3D+id+%3D+%5Cmu+.+T%28%5Ceta%29++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='&#92;mu . &#92;mu = &#92;mu . T (&#92;mu)&#92;newline  &#92;mu . &#92;eta = id = &#92;mu . T(&#92;eta)  ' title='&#92;mu . &#92;mu = &#92;mu . T (&#92;mu)&#92;newline  &#92;mu . &#92;eta = id = &#92;mu . T(&#92;eta)  ' class='latex' /></td>
</tr>
</tbody>
</table>
<p>Don&#8217;t be scared away by all this, it&#8217;s just an abstract reformulation of the simple concatenation and mappings of lists above! I do need however to push things a bit further because the way a monad is defined in maths is in general not the way you&#8217;ll recognize it in F# or Haskell. Usually you&#8217;ll see the equivalent formulation by Heinrich Kleisli who invented the Kleisli triple and which turned out to be an equivalent definition for monads. That is, it can be shown that there is a one-to-one correspondence between a Kleisli structure and a monad.</p>
<table style="border: 1px solid #D94D23; float: none; width: 90%;">
<tbody>
<tr style="background-color: #d94d23;">
<th style="color: #fff;"> <strong>Definition</strong></th>
</tr>
<tr>
<td>In this equivalent formulation a monad (or Kleisli triple if you prefer) is defined as a triple over a category consisting of&nbsp;</p>
<ul>
<li>an endofunctor T</li>
<li>a return operation <img src='http://s0.wp.com/latex.php?latex=%5Ceta%3A+C%5Crightarrow+T+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='&#92;eta: C&#92;rightarrow T ' title='&#92;eta: C&#92;rightarrow T ' class='latex' /></li>
<li>a *-operator on morphisms which lifts a morphism</li>
</ul>
<p>satisfying:<br />
<img src='http://s0.wp.com/latex.php?latex=%5Ceta%5E%2A+%3D+id%5Cnewline++f%5E%2A+.%5Ceta+%3D+f%5Cnewline++g%5E%2A+.f%5E%2A+%3D+%28g%5E%2A+.+f%29%5E%2A++&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='&#92;eta^* = id&#92;newline  f^* .&#92;eta = f&#92;newline  g^* .f^* = (g^* . f)^*  ' title='&#92;eta^* = id&#92;newline  f^* .&#92;eta = f&#92;newline  g^* .f^* = (g^* . f)^*  ' class='latex' /></td>
</tr>
</tbody>
</table>
<p>and you should immediately recognize the properties we mentioned above in the context of the List category. The proof that the two definitions are leading to the same structure is not difficult but it wouldn&#8217;t be useful at this point (unless you are math oriented and you need to see it to understand it).</p>
<h2>Some simple F#</h2>
<p>The prototypical example in the context of F# workflows is the &#8216;dividing by zero&#8217; problem; one cannot divide by zero. If you have a computation where at some point an exception is raised (either explicitly or by the runtime) it doesn&#8217;t make sense to continue a computation but maybe you want to handle the exception.<br />
The way to handle this in F# is by using a label attached to a number; if the label says &#8216;failure&#8217; it doesn&#8217;t matter what the value is, if the label says &#8216;success&#8217; it makes sense to read the value. It&#8217;s a way to include infinity in the constraint range of values the runtime can handle:</p>
<div class="wp_codebox">
<table>
<tr id="p55549">
<td class="line_numbers">
<pre>1
</pre>
</td>
<td class="code" id="p5554code9">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">type</span> Result <span style="color: #a52a2a;">=</span> Success <span style="color: #06c; font-weight: bold;">of</span> <span style="color: #06c; font-weight: bold;">float</span> | Infinite</pre>
</td>
</tr>
</table>
</div>
<p>Next, instead of the usual division you define a divide function like so</p>
<div class="wp_codebox">
<table>
<tr id="p555410">
<td class="line_numbers">
<pre>1
2
3
4
</pre>
</td>
<td class="code" id="p5554code10">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> divide x y <span style="color: #a52a2a;">=</span>
  <span style="color: #06c; font-weight: bold;">match</span> y <span style="color: #06c; font-weight: bold;">with</span>
  | <span style="color: #c6c;">0.0</span> <span style="color: #a52a2a;">-&gt;</span> Infinite
  | _ <span style="color: #a52a2a;">-&gt;</span> Success<span style="color: #6c6;">&#40;</span>x<span style="color: #a52a2a;">/</span>y<span style="color: #6c6;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>and plug it into a class with two members:</p>
<div class="wp_codebox">
<table>
<tr id="p555411">
<td class="line_numbers">
<pre>1
2
3
4
5
6
</pre>
</td>
<td class="code" id="p5554code11">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">type</span> SaveDivision<span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">=</span>
 <span style="color: #06c; font-weight: bold;">member</span> this Bind <span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#40;</span>x:Results<span style="color: #6c6;">&#41;</span>, <span style="color: #6c6;">&#40;</span>res: float<span style="color: #a52a2a;">-</span>&amp;gt<span style="color: #a52a2a;">;</span>Result<span style="color: #6c6;">&#41;</span><span style="color: #6c6;">&#41;</span>
  <span style="color: #06c; font-weight: bold;">match</span> x <span style="color: #06c; font-weight: bold;">with</span>
  |Success<span style="color: #6c6;">&#40;</span>x<span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">-&gt;</span> rest x
  | Infinite <span style="color: #a52a2a;">-&gt;</span> Infinite
 <span style="color: #06c; font-weight: bold;">member</span> this.<span style="color: #060;">Return</span> x <span style="color: #a52a2a;">=</span> x</pre>
</td>
</tr>
</table>
</div>
<p>At this point you can look at this as a class with two methods but what you really should see is that</p>
<ul>
<li>the map from a float number to the Result type is an amplifier or lift map as we described in the example above; it&#8217;s the endofunctor on the Net category of data types</li>
<li>the Bind operation corresponds to the *-operation of a Kleisli triple</li>
<li>the return corresponds to the eta-mapping of the Kleisli triple</li>
</ul>
<p>and it turns this triple into a monad! You should also reflect on the fact that the Bind member correspond to the concat operation on the List category (and similarly the return corresponds to the return member).</p>
<p>The way you use the SaveDivision monad in a concrete computation is by instantiating it and do something inside as follows:</p>
<div class="wp_codebox">
<table>
<tr id="p555412">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
</pre>
</td>
<td class="code" id="p5554code12">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">let</span> safe <span style="color: #a52a2a;">=</span> SaveDivision<span style="color: #6c6;">&#40;</span><span style="color: #6c6;">&#41;</span>
<span style="color: #06c; font-weight: bold;">let</span> SomeCalculation x1 x2 <span style="color: #a52a2a;">=</span>
 safe <span style="color: #6c6;">&#123;</span>
    <span style="color: #06c; font-weight: bold;">let!</span> x <span style="color: #a52a2a;">=</span> divide <span style="color: #c6c;">1</span> x1
    <span style="color: #06c; font-weight: bold;">let!</span> y <span style="color: #a52a2a;">=</span> divide <span style="color: #c6c;">1</span> x2
    <span style="color: #06c; font-weight: bold;">return</span> divide x y
 <span style="color: #6c6;">&#125;</span></pre>
</td>
</tr>
</table>
</div>
<p>and as soon as you try this on zero you get the Infinite as an answer. Without this construction you would get an exception, obviously.The &#8216;bang&#8217; or exclamation mark after the let keywords is actually a way to tell F# that the Bind operation should be used instead of the normal assignment (or type inference).</p>
<p>So, this very simple example highlights the following:</p>
<ul>
<li><strong>monads in F# allows you to do &#8216;stuff&#8217; </strong>under the hood and redefine how things are being assigned or returned</li>
<li><strong>a monad in F# is really a Kleisli triple</strong> but because it&#8217;s mathematically equivalent to a monad there is no need to differentiate. I does confuse however when you try to compare the mathematical textbooks with the functional programming textbooks</li>
<li><strong>monads are often called workflows</strong> because it allows you do embed a whole logic or workflow inside the instantiated class (monad) and redefine how things like the assignment (let!) should function. You will also see that F# in fact has extended the notion of monad to include other monad members and in this fashion allowing you to redefine how for-next, try, yield and other statements are acting inside the monad.</li>
<li>monads are <strong>sometimes called computation expression</strong> since it redefines how assignments and expressions should act on (category) objects</li>
</ul>
<p>In Haskell you will not encounter the alternative names and the term monad is used uniformly.</p>
<p>The suspicious mind should by now worry about a lack of consistency and feel the need for more formal proofs that for example the constraints (or defining rules) of a Kleisli triple (aka monad) are satisfied. Indeed, is the SafeDivision monad with the specified operations satisfying the constraints? Well, yes, it does. But I will refrain to reproduce the proofs and am happy to forward you to someone you tediously wrote it all down; see <a title="Paul Abraham" href="http://paul-abraham.blogspot.com/">Paul Abraham&#8217;s blog </a>and <a title="Monads in F#" href="http://www.paul-abraham.com/MonadsInFSharp.doc">this document in particular wherein you&#8217;ll find the F# proofs</a>.</p>
<h2>A simple dictionary</h2>
<p>In Haskell the following type class is used to implement monads:</p>
<div class="wp_codebox">
<table>
<tr id="p555413">
<td class="line_numbers">
<pre>1
2
3
</pre>
</td>
<td class="code" id="p5554code13">
<pre class="fsharp" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">class</span> Monad m where
   <span style="color: #06c; font-weight: bold;">return</span> :: a →m a
   <span style="color: #6c6;">&#40;</span><span style="color: #a52a2a;">&gt;&gt;=</span><span style="color: #6c6;">&#41;</span> :: m a →<span style="color: #6c6;">&#40;</span>a →m b<span style="color: #6c6;">&#41;</span> →m b</pre>
</td>
</tr>
</table>
</div>
<p>You can immediately recognize the return and the bind methods but the symbol &#8216;&gt;&gt;=&#8217; is usually used instead of &#8216;bind&#8217;. Purists will tell you that the discussion around monads in Haskell is not complete without the topic of &#8216;comonads&#8217; and &#8216;cofunctors&#8217; but it will take a while before these discussions appear in the F# community. See <a href="http://blog.ezyang.com/2010/07/flipping-arrows-in-coburger-king/" target="_blank">this article</a> in case you want to know more about this.</p>
<p>In order to use monads in F# you only need to implement an (implicit) class which implements the Bind and Return member. The language extends the purely mathematical definition with eight extra methods:</p>
<table style="border: 1px solid #D94D23; float: none; width: 90%;">
<tbody>
<tr style="background-color: #d94d23;">
<th style="color: #fff;">Member</th>
<th width="50%">Description</th>
</tr>
<tr>
<td valign="top"><code>member <strong>Bind </strong>: M&lt;'a&gt; * ('a -&gt; M&lt;'b&gt;) -&gt; M&lt;'b&gt;</code></td>
<td valign="top"><span style="color: #ff6600;">Required member</span>. Converts <code>let!</code> and <code>do!</code> within the monad.</td>
</tr>
<tr>
<td valign="top"><code>member <strong>Return </strong>: 'a -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #ff6600;">Required member.</span> Converts the <code>return</code> within the monad.</td>
</tr>
<tr>
<td valign="top"><code>member <strong>Delay </strong>: (unit -&gt; M&lt;'a&gt;) -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Ensures that side effects within the monad are performed when expected.</td>
</tr>
<tr>
<td valign="top"><code>member <strong>Yield </strong>: 'a -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Converts the <code>yield</code> within the monad.</td>
</tr>
<tr>
<td valign="top"><code>member <strong>For </strong>: seq&lt;'a&gt; * ('a -&gt; M&lt;'b&gt;) -&gt; M&lt;'b&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Converts the <code>for ... do ...</code> within the monad.&nbsp; <code>M&lt;'b&gt;</code> can optionally be <code>M&lt;unit&gt;</code></td>
</tr>
<tr>
<td valign="top"><code>member <strong>While </strong>: (unit -&gt; bool) * M&lt;'a&gt; -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Converts the <code>while ... do ...</code> within the monad. <code>M&lt;'b&gt;</code> can optionally be <code>M&lt;unit&gt;</code></td>
</tr>
<tr>
<td valign="top"><code>member <strong>Using </strong>: 'a * ('a -&gt; M&lt;'b&gt;) -&gt; M&lt;'b&gt; when 'a&nbsp;:&gt; IDisposable</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Converts the <code>use</code> bindings within the monad.</td>
</tr>
<tr>
<td valign="top"><code>member <strong>Combine </strong>: M&lt;'a&gt; -&gt; M&lt;'a&gt; -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Used to convert sequencing within the monad. The first <code>M&lt;'a&gt;</code> can optionally be <code>M&lt;unit&gt;</code></td>
</tr>
<tr>
<td valign="top"><code>member <strong>Zero </strong>: unit -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Converts the empty <code>else</code> branches of <code>if/then</code> in the monad.</td>
</tr>
<tr>
<td valign="top"><code>member <strong>TryWith </strong>: M&lt;'a&gt; -&gt; M&lt;'a&gt; -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Converts the <code>try/with</code> bindings of the monad.</td>
</tr>
<tr>
<td valign="top"><code>member <strong>TryFinally </strong>: M&lt;'a&gt; -&gt; M&lt;'a&gt; -&gt; M&lt;'a&gt;</code></td>
<td valign="top"><span style="color: #99cc00;">Optional</span>. Converts the <code>try/finally</code> bindings of the monad.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Finally, the following table should be helpful in case you wish to move back and forth between F#, Haskell and the math literature.</p>
<table style="border: 1px solid #A7BD5B; float: none; width: 90%;">
<tbody>
<tr style="background-color: #a7bd5b; color: #fff;">
<th> Haskell</th>
<th> F#</th>
<th> Math</th>
</tr>
<tr>
<td>return</td>
<td>return</td>
<td><img src='http://s0.wp.com/latex.php?latex=%5Ceta+&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='&#92;eta ' title='&#92;eta ' class='latex' /></td>
</tr>
<tr>
<td>&gt;&gt;==</td>
<td>bind</td>
<td>* operator</td>
</tr>
<tr>
<td>instantiate the Monad type class</td>
<td>implement at least the Return and Bind members</td>
<td>NA</td>
</tr>
<tr>
<td>Monad</td>
<td>Monad, Monad Expression, Workflow, Computation Expression</td>
<td>Monad with an equivalent definition through Kleisli triple.<br />
The defining structure in F# and Haskell is really a Kleisli triple but no distinction is made there between the two types.</td>
</tr>
<tr>
<td>NA</td>
<td>NA</td>
<td><img src='http://s0.wp.com/latex.php?latex=%5Cmu&#038;bg=ffffff&#038;fg=000&#038;s=1' alt='&#92;mu' title='&#92;mu' class='latex' /></td>
</tr>
<tr>
<td>functor through a type class definition</td>
<td>usually not mentioned</td>
<td>functor</td>
</tr>
<tr>
<td>function</td>
<td>function (&#8216;fun&#8217;)</td>
<td>morphism</td>
</tr>
<tr>
<td><strong>Hask </strong>category of Haskell data types</td>
<td><strong>Net </strong>category of data types</td>
<td>a wild zoo of categories; groups, topologies, graphs, differential geometries, quantum field theories and so on</td>
</tr>
<tr>
<td>composable functions</td>
<td>composable functions</td>
<td>binary operation and monoids</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2>References</h2>
<ul>
<li><a title="Monad library for F# on GitHub" href="https://github.com/panesofglass/FSharp.Monad" target="_blank">F# monad library</a></li>
<li><a title="Haskell wiki" href="http://www.haskell.org/haskellwiki/Haskell" target="_blank">Haskell wiki</a></li>
<li><a title="Haskell categories" href="http://en.wikibooks.org/wiki/Haskell/Category_theory#Monads" target="_blank">Haskell category theory on Wikibooks</a></li>
<li><a title="Awesome Princess wiki book on F#" href="http://en.wikibooks.org/wiki/F_Sharp_Programming" target="_blank">F# programming on Wikibooks</a></li>
<li><a title="Try F#" href="http://www.tryfsharp.org/" target="_blank">Try F#; awesome online F# learning site</a></li>
<li><a title="nLab" href="http://ncatlab.org/nlab/show/HomePage" target="_blank">nLab on everything categories in mathematical physics</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/categories-for-dummies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SharePoint Workspace (sync) unable to connect</title>
		<link>http://visualizationtools.net/default/sharepoint-workspace-sync-unable-to-connect/</link>
		<comments>http://visualizationtools.net/default/sharepoint-workspace-sync-unable-to-connect/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 14:32:47 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/sharepoint-workspace-sync-unable-to-connect/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Typically when you install a fresh SharePoint 2010 Enterprise and a user starts to connect to it through SharePoint WorkSpace/Groove he will receive the error:</p>
<p><em><font color="#ff0000">SharePoint Workspace was unable to interpret the SharePoint location. Please check and ensure the location contains no typing errors. </font></em></p>
<p>The solution to this consists in adding <strong>a public facing URL</strong> and making sure the server has <strong>remote differential compression installed</strong>/enabled.</p>
<p>Go to <strong>Server Manager &gt; Features </strong>and take a look at whether the remote differential compression is enabled. If not, check and install.</p>
<p><a href="http://visualizationtools.net/default/wp-content/uploads/2011/06/image6.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://visualizationtools.net/default/wp-content/uploads/2011/06/image_thumb6.png" width="451" height="337" /></a></p>
<p>Next go to <strong>SharePoint Central Administration &gt; Alternate Access Mappings</strong> and click the ‘<strong>Edit public URL&#8217;</strong> . Once there, make sure that besides the default internal URL there is also a public facing URL through which users can sync via the Workspace application.</p>
<p><a href="http://visualizationtools.net/default/wp-content/uploads/2011/06/image7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://visualizationtools.net/default/wp-content/uploads/2011/06/image_thumb7.png" width="462" height="178" /></a></p>
<p>&#160;</p>
<p>Like most issues in SharePoint, fairly simple to fix but often a whole research before figuring out what is going on.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/sharepoint-workspace-sync-unable-to-connect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Particle systems and Silverlight</title>
		<link>http://visualizationtools.net/default/silverlight-particle-systems/</link>
		<comments>http://visualizationtools.net/default/silverlight-particle-systems/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 17:17:55 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[data-visualization]]></category>
		<category><![CDATA[Layout algorithms]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=5515</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="image-wrap portfolio"><a href="/default/wp-content/uploads/2011/06/image5.png" rel="prettyPhoto" title="Sample particle system"><span class="zoom"></span>
<img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="/default/wp-content/uploads/2011/06/image_thumb5.png" border="0" alt="image" width="530" height="368" />
</a></div><p style="clear:both;">&nbsp;</p><p style="clear:left;">&nbsp;</p>
<p>Recently a customer requested a particle simulation with the intention to investigate correlations and the effect of multiple ‘attractors’. The real, underlying issue in this demand is the fact that certain situations and systems are governed by laws (differential equations) which cannot be solved exactly and require a dynamic system to search for critical coefficients. These coefficients result in (semi) stable configurations or highlight boundary conditions inside which things make sense.</p>
<p>The problem with these kind of systems is the scalability which has two aspects; <strong>the visualization</strong> which doesn’t scale well with the retained graphics pipeline of WPF/SL/WP7 on the one hand&nbsp; and the O(N*N) <strong>calculation of interactions between particles</strong>.</p>
<p>Regarding the visuals there is really a lot to consider:</p>
<ul>
<li>if you inherit from a baseclass like FrameworkElement or Control or even UserControl you carry around with each and every particle a whole lot of stuff; data binding, styling, event and other infrastructure. While all these things are really great in an LOB, one doesn’t usually need all this when dealing with (lots of) particles</li>
<li>typically the underlying surface needs to be a Canvas but this element also brings along many gears; the retained rendering system, the measure/layout mechanics, styling and more. Maybe the bonus you miss when bypassing the Canvas is the ability to easily integrate zoom and pan in an application.</li>
<li>how much user-interaction is required, are mouse-events necessary or is it a ‘let it run’ system? Here as well, you need to consider carefully the implications (especially related to the scalability of the app).</li>
</ul>
<p>With respect to the simulation or calculation part things are more straightforward but you also need to think about</p>
<ul>
<li>the possibility to use F# for the more mathematically oriented parts. The disadvantage is however the need to constraint your model to make sure things talk to C#, or you have to go the full nine yards in F# (talking to XAML is still a disaster in this case).</li>
<li>how to optimize the calculations and to make sure that inside loops you break early and branch as much as possible</li>
<li>dropping unnecessary properties of the particles and make the particle system as lightweight as possible</li>
</ul>
<p>Within the Silverlight/WP context my experience is that if you use the Canvas/UIElement combination you easily hit a wall around <strong>500 particles</strong> due to the way the rendering engine is functioning and the fact that the UIElement (or FrameworkElement) are too ‘heavy’. The inter-particle calculation will still run OK with 500 particles but the end-result is that it’s not a good solution altogether.</p>
<p>One can keep the Canvas as underlying surface and render particles as inherited Shape items but this doesn’t push the boundary much.</p>
<p>A step further is to replace the Canvas with a bitmap and use direct pixel printing. This is easily done with the <a href="http://writeablebitmapex.codeplex.com/" target="_blank">WriteableBitmapEx</a> project you can find on CodePlex. This boosts your rendering to <strong>5000 particles</strong> if you drop interactions. However, if you switch on inter-particle forces you hit a calculational wall around <strong>1500 particles</strong> which is still way better than the retained rendering solution but still somewhat underwhelming.</p>
<p>So, as a next step it would be great to use parallel processing for the algorithmic part but unfortunately there is no task parallel processing library (TPL) for Silverlight (though somewhat made an unofficial port). Another possibility would be to use MailboxProcessor of F# but it would entail threading issues and an altogether more difficult system.</p>
<p>Various samples and libraries are available for XNA and Windows Phone which allow one to create particle effects but</p>
<ul>
<li>the often use sprites or similar techniques to minimize the particle count. The results are usually very good but the aim in the context of games is usually to create a certain effect rather than to give a physically correct simulation.</li>
<li>they often do not exhibit inter-particle forces. If they do the particle count is low.</li>
<li>they focus on effects and not physics</li>
</ul>
<p>See also the Flint-sharp library which is a port of the Flash/Flex library.</p>
<p>The conclusion is that one can perform simulations and develop particle system in Silverlight if the need is not above, say, a thousand particles. Above this threshold things become more difficult and Silverlight as a medium becomes less suitable for this type of task. Obviously there are high-tech solutions on the basis of C++ and GPU instructions but this was outside my client’s scope (and my technical know-how as well).</p>
<div class="bluebox">
<a href="/downloads/stuff/SilverlightParticles.zip">Attached is simple and fun particle system on the basis of WriteableBitmapEx and lightweight particles.</a>
</div>
<p><strong>Note</strong>: on different level you need to note in the attached simulation sample that</p>
<ul>
<li>the average speed varies a lot while the amount of interacting particles stays the same</li>
<li>the <strong>ergodic phenomenon</strong> if easily shown; that the average velocity over the sample equals the average of one item in time</li>
<li>it&#8217;s quite difficult to create stable configurations; which mimics well how the real world is also constantly influenced by quantum fluctuations</li>
</ul>
<h2>References</h2>
<ul>
<li><a href="http://www.damonpayne.com/post/2011/02/07/Task-Parallel-Library-Ported-to-Silverlight-4.aspx" target="_blank">TPL library ported to Silverlight 4</a></li>
<li><a href="http://create.msdn.com/en-US/education/catalog/sample/particle" target="_blank">Particle system for games (XNA &amp; WP)</a></li>
<li><a href="http://code.google.com/p/flint-sharp/" target="_blank">Flint for C#</a></li>
<li><a href="http://writeablebitmapex.codeplex.com/" target="_blank">WriteableBitmapEx on CodePlex</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/silverlight-particle-systems/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cannot connect to WMI provider. You do not have permission or the server is unreachable.</title>
		<link>http://visualizationtools.net/default/wmi-provider-error/</link>
		<comments>http://visualizationtools.net/default/wmi-provider-error/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 04:41:43 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Business Inteliigence]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[BI]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/default/?p=5508</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>During upgrade or installation of some SQL Server packages you might encounter the error “<span style="color: #ff0000;">Cannot connect to WMI provider. You do not have permission or the server is unreachable</span>”. In particular, during the setup of <a href="http://msftdbprodsamples.codeplex.com/" target="_blank">the AdventureWorks sample databases</a> this often happens</p>
<p><a href="http://visualizationtools.net/default/wp-content/uploads/2011/06/image3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://visualizationtools.net/default/wp-content/uploads/2011/06/image_thumb3.png" border="0" alt="image" width="244" height="155" /></a></p>
<p>Most probably, if you receive this error you also will get it when opening the SQL Server Configuration tool with a message stating</p>
<p><a href="http://visualizationtools.net/default/wp-content/uploads/2011/06/image4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://visualizationtools.net/default/wp-content/uploads/2011/06/image_thumb4.png" border="0" alt="image" width="301" height="125" /></a></p>
<p>&nbsp;</p>
<p>It seems this happens when you run a 64bit version of SQL Server and have removed a 32bit one earlier. Both versions share the same WMI configuration and, hence, things get lost when uninstalling some stuff. In this Microsoft Support report you can find some background where the essential bit is:</p>
<p><strong>mofcomp &#8220;%programfiles(x86)%\Microsoft\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof&#8221;</strong></p>
<p>(run this in an elevated  CMD) as well as reconfiguring the server to enable file streaming.</p>
<p><strong>EXEC sp_configure filestream_access_level, 1<br />
</strong><strong>RECONFIGURE</strong></p>
<p>(run this as a SQL query).</p>
<p>Lo and behold, if you go through this you can move on and use SQL Server WMI again. If you&#8217;re curious about <em>mofcomp</em>, it&#8217;s the <a href="http://msdn.microsoft.com/en-us/library/aa392389%28v=vs.85%29.aspx" target="_blank">managed object format compiler parser</a> but very little info is available about this tool and it seems to me that it&#8217;s one of those things (like the registry) you better handle with silk gloves.</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/wmi-provider-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access denied by business data connectivity</title>
		<link>http://visualizationtools.net/default/access-denied-by-business-data-connectivity/</link>
		<comments>http://visualizationtools.net/default/access-denied-by-business-data-connectivity/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 11:33:32 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[BCS]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/folia/access-denied-by-business-data-connectivity/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Here’s a pesky error message from SharePoint which took me a while to figure out.</p>
<p><a href="/default/wp-content/uploads/2011/06/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="/default/wp-content/uploads/2011/06/image_thumb.png" border="0" alt="image" width="592" height="227" /></a></p>
<p>To resolve this simply drill down into the following  series of screens</p>
<p><strong>Central Administration &gt; Application Management &gt; Manage Service Applications &gt; Business Data Connectivity Service &gt; Your data screen &gt; Set Permissions</strong></p>
<p><a href="/default/wp-content/uploads/2011/06/image1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="/default/wp-content/uploads/2011/06/image_thumb1.png" border="0" alt="image" width="598" height="467" /></a></p>
<p>Add the administrator to the permissions and you can thereafter happily enjoy data from BCS!</p>
<p><a href="/default/wp-content/uploads/2011/06/image2.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="/default/wp-content/uploads/2011/06/image_thumb2.png" border="0" alt="image" width="590" height="476" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/access-denied-by-business-data-connectivity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Which CMS?</title>
		<link>http://visualizationtools.net/default/which-cms/</link>
		<comments>http://visualizationtools.net/default/which-cms/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 19:30:38 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Orbifold]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/folia/?p=5421</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>The CMS world seems an ever-expanding collection of remakes and novel frameworks. In fact, when you look around for a system it&#8217;s a bewildering experience; too many, too much. Inside the enterprise category there are some extremely sophisticated systems; SiteFinity, SiteCore, SharePoint and alike. In the open source category there are the famous ones like Drupal, Joomla and WordPress and Microsoft recently also released the wonderful Orchard. So, which one fits the bill?</p>
<p>Each business has its own needs and criteria but from this side the following criteria were important:</p>
<ul>
<li><strong>customization</strong>: API quality, documentation, programming language and support. A system like Sitecore is for sure the max but there is also a steep learning curve. On the other side of the scale, there are thousands of interesting CMS system with poor API or documentation.</li>
<li>availability of <strong>plugins. </strong>WordPress has a practically endless amount of plugins while SiteFinity is a bit thin in this respect.</li>
<li>choice of <strong>themes </strong>and skins. Here again, a system like SharePoint seems an all-rounder but assigning a brand to a site is, well, a project on its own.</li>
<li>ease of <strong>deployment </strong>and setup requirements. A great systems requires a great environment, whether in terms of security or in terms of cost, one cannot avoid administrative issues (aka requirements) with larger CMS systems.</li>
<li><strong>costs </strong>This one is relative, of course.<strong> </strong></li>
<li><strong>integrations</strong>: can the system integrate with other systems (billing, PM, mail&#8230;)?</li>
<li><strong>maintenance </strong>effort With the ubiquitous HTML5 wave and JavaScript madness one has to be prepared for changes. How does a CMS system evolve in an ever changing IT landscape?</li>
</ul>
<p>There is also the fact that</p>
<ul>
<li>if you have used a CMS before you probably have already a database full of <strong>content</strong>; can this content be transferred to another system and what does it take?</li>
<li>each system has a certain workflow or mechanics which one gets used to. Changing CMS means <strong>changing habits</strong> and rethinking e.g. the categorization (ontology) of the content delivery.</li>
<li>look-and-feel is to some extend bound to the underlying site logic. A theme from WordPress is not necessarily easily transferred to SiteFinity or vice versa.</li>
</ul>
<p>On a technical level there are obviously also certain aspects to consider like; .Net or PHP or Ruby, MySQL or SQL Server, WCF enabled or XML-RPC&#8230;?</p>
<p>So, choosing a CMS is really a project on its own and when chosen the real hard work is ahead; customization, content (re)formatting and so on. In as far as this small company is representative for you, our considerations were the following:</p>
<ul>
<li>we have used WordPress in the past seven years and fully satisfied with it. Content transfer and upgrade is reduced to nill in this case.</li>
<li>there are tons of themes, plugins, community articles and site using WordPress. Whatever you are looking for, someone already made it and WordPress has an easy plugin system to adorn your site to your taste with these themes and plugins.</li>
<li>cost and deployment are small. No need for high-end servers or special administrative priviledges.</li>
<li>it&#8217;s PHP and MySQL (though you have SQL Server and Azure solutions) but the learning curve is smooth. In fact, PHP is fun and MySQL is a wonderful RDBMS.</li>
<li>the biggest issue is integrations and the possibility to mix-match things with either home-made systems or third-party system. This is our compromise.</li>
</ul>
<p>This said, systems like SiteFinity or Orchard are really a joy and well worth a look. It just depends what you need and your business context.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/which-cms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Our new customer care system</title>
		<link>http://visualizationtools.net/default/our-new-customer-care-system/</link>
		<comments>http://visualizationtools.net/default/our-new-customer-care-system/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 18:02:08 +0000</pubDate>
		<dc:creator>Francois Vanderseypen</dc:creator>
				<category><![CDATA[Orbifold]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[MVC3]]></category>

		<guid isPermaLink="false">http://visualizationtools.net/folia/?p=5411</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="image-wrap portfolio"><a href="/default/wp-content/uploads/2011/06/CustomerCareUpdate1.png" rel="prettyPhoto" title="Login screen of our customer care system"><span class="zoom"></span>
<img class="alignnone size-medium wp-image-5412" title="Customer Care login" src="/default/wp-content/uploads/2011/06/CustomerCareUpdate1-224x300.png" alt="Customer Care login" width="224" height="300" />
</a></div><p style="clear:both;">&nbsp;</p><p style="clear: left;">&nbsp;</p>
<p>Together with this site update it was time to rethink the way accounting was functioning, how contracts and licenses were kept up to date, how customers could download updates and more. All of this sounds simple and straightforward but the effort it took to make it happen was surprisingly heavy. Maybe not so much a technical challenge than a conceptual challenge. Among other things, the aims was:</p>
<ul>
<li>to enable customers to log into the system, see their licenses, download updates, view previously sent invoices, view their SVN credentials and more</li>
<li>to replace our existing (and costly) CRM system with a more home-made and custom system</li>
<li>to keep track of flavors, versions and prices of our products</li>
<li>to create a base for a more elaborate software tracking system</li>
</ul>
<p>Indeed, how to make sure that an address which has been used in an invoice cannot be altered subsequently (but at the same time allowing a customer address to be changed of course)? How to design a database for multiple products, each having various flavors and all having potentially different prices? At the same time, we deliver more consulting services than really being a product-selling company, so the whole invoicing system had to be flexible in this sense as well. On the one hand this whole conceptual design process was challenging and required trial and error, on the other hand it was a lot of fun.</p>
<p>Not the least the fun of developing this project came from the fact that the entity framework 4.1 has this code-first features which allows one to develop things initially in a very organic fashion. I emphasize &#8216;initially&#8217; here since code-first is not good practice for larger and more enterprise-level software. Additionally, the ASP.Net MVC3 framework brought back the fun in developing websites. It&#8217;s just a great joy to use Razor and one cannot deny that with respect to webforms the razor approach makes one so much more productive.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://visualizationtools.net/default/our-new-customer-care-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  www.orbifold.net/default/feed/ ) in 1.09031 seconds, on Feb 23rd, 2012 at 1:42 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 23rd, 2012 at 2:42 am UTC -->
