<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter/RSS"></atom:link>
	<image>
		<url>http://ecn.channel9.msdn.com/o9/previewImages/100/569400_100x75.jpg</url>
		<title>Channel 9 - C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<link></link>
	</image>
	<description>
In&amp;nbsp;part&amp;nbsp;3 of the Advanced Functional Programming lecture series, Dr. L&#228;mmel focuses on the domain of language interpretation as a&amp;nbsp;method of understanding some important functional programming techniques. As a side effect, some basics of programming language
 theory are also informally presented. 
More specifically, this lecture develops an interpreter for a simple functional programming language that contains Booleans, natural numbers, lambdas, and recursive lets. The interpreter is actually developed in a stepwise manner, which is why the lecture
 is called &amp;quot;Evolution of an Interpreter.&amp;quot;In each step, another construct is added and the impact of the extension onto the interpreter is analyzed. In this manner, several interesting programming techniques are exercised. For instance, the Maybe type constructor is pervasively used for dealing with
 partiality, and Haskell&#39;s fixed point combinator is used to model the semantics (i.e., interpretation) of recursive bindings.
This lecture also prepares us&amp;nbsp;for some more advanced subjects. For instance, the next lecture in this series will cover the intriguing subject of monads while using interpretation as the application scenario. Soon, generalized folds (or
 bananas, according to Erik Meijer) will also be discussed (the folds will traverse abstract syntax trees as opposed to lists).Enjoy. Learn. Thanks to Ralf for providing another excellent lecture!Earlier lectures 
here. 
Slides: 
https://developers.svn.sourceforge.net/svnroot/developers/repository/ralfs-channel9-lectures/decks/interpretation.pdf 
Related Blog Post and Code:http://professor-fish.blogspot.com/2010/08/bunch-of-interpreters-using-cpp-and.html 
</description>
	<link></link>
	<language>en</language>
	<pubDate>Thu, 23 May 2013 21:26:13 GMT</pubDate>
	<lastBuildDate>Thu, 23 May 2013 21:26:13 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Love the shirt, Ralf! <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /><br />C</p>
<p>&nbsp;</p>
<p>EDITPS: After this lecture, you should solve the <a href="https://developers.svn.sourceforge.net/svnroot/developers/repository/ralfs-channel9-lectures/decks/interpretation.pdf">
problems/riddles on slides 16, 31, 38 in the deck</a>. Then, read the <a href="http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=3638E59968F7B2462EA33C607DF7B685?doi=10.1.1.41.125&amp;rep=rep1&amp;type=pdf">
Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire</a>&nbsp;paper by our very own Erik Meijer and friends.</p>
<p>&nbsp;</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634188819590000000</link>
		<pubDate>Tue, 31 Aug 2010 20:05:59 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634188819590000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>I promise a new shirt for each lecture. This provides a natural limit to the number of lectures we could expect.</p>
<p>posted by user42</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634188820480000000</link>
		<pubDate>Tue, 31 Aug 2010 20:07:28 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634188820480000000</guid>
		<dc:creator>user42</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Excellent!</p>
<p>C</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634188835020000000</link>
		<pubDate>Tue, 31 Aug 2010 20:31:42 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634188835020000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Have you looked at that paper? The notation used makes it almost impenetrable. I appreciate the ideas but I couldn't make sense of it when I was learning Haskell ... Maybe after Erik's category theory lectures it will make sense to me. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>posted by Justin Bailey</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189659210000000</link>
		<pubDate>Wed, 01 Sep 2010 19:25:21 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189659210000000</guid>
		<dc:creator>Justin Bailey</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>I get what you are saying. I can assure you that my bananas lecture will be very&nbsp;eatable. I consider myself reasonably skilled when it comes to formal notation but have suffered headache (multiple times) because of Erik's bananas paper. Perhaps, it had been
 conceived indeed (I sense) in a very domain-specific geek mode. Also, I should add that the paper did not discuss all the kinds of bananas that we need in practice. For example, large bananas were missing. So I am looking forward to come clean with bananas.
 It's two lectures from now. Next one is about monads. I am geeking around with the code right now, and I can't wait to record the lecture.</p>
<p>&nbsp;</p>
<p>But hey yes, I also want to encourage Erik to tell us about category theory.</p>
<p>&nbsp;</p>
<p>posted by user42</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189664420000000</link>
		<pubDate>Wed, 01 Sep 2010 19:34:02 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189664420000000</guid>
		<dc:creator>user42</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Actually, it provides you with great incentive to go shopping! <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-2.gif' alt='Big Smile' /></p>
<p>&nbsp;</p>
<p>Watching...</p>
<p>posted by exoteric</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189757630000000</link>
		<pubDate>Wed, 01 Sep 2010 22:09:23 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189757630000000</guid>
		<dc:creator>exoteric</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Yes. The symbolic expressions are ugly (or beautiful, depending on your perspective...), but the ideas are explained. The mathematics prove points, but the points aren't only mathematical. At any rate, yes, the paper is dense and the title makes it seem
 less so, perhaps. </p>
<p>&nbsp;</p>
<p>An entire&nbsp;lecture dedicated to Monads will be so welcome, Ralf. Thank you!<br />C</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189761200000000</link>
		<pubDate>Wed, 01 Sep 2010 22:15:20 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189761200000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p><span class="Apple-style-span"><span class="Apple-style-span">All young grasshoppers please remember &quot;wax on, wax off, wax on, wax off, ...&quot;</span></span></p>
<p>posted by head.in.the.box</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189824910000000</link>
		<pubDate>Thu, 02 Sep 2010 00:01:31 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189824910000000</guid>
		<dc:creator>head.in.the.box</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Thank you, grandfather. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>C</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189858010000000</link>
		<pubDate>Thu, 02 Sep 2010 00:56:41 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634189858010000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>another good article in the series. I need to go back and look more closely at the fixed point operator, as I kind of got a bit out of my depth when we got onto implementing recursion into the interpreter... but that's the whole point I guess: if I didn't
 get out of my depth there would be nothing to learn!</p>
<p>&nbsp;</p>
<p>Talking of the Fixed point operator/combinator it reminded me of Bart De Smet's post on implementing the trampoline for safe recursion in c#:</p>
<p><a href="http://community.bartdesmet.net/blogs/bart/archive/2009/11/08/jumping-the-trampoline-in-c-stack-friendly-recursion.aspx">http://community.bartdesmet.net/blogs/bart/archive/2009/11/08/jumping-the-trampoline-in-c-stack-friendly-recursion.aspx</a></p>
<p><a href="http://community.bartdesmet.net/blogs/bart/archive/2009/11/08/jumping-the-trampoline-in-c-stack-friendly-recursion.aspx"></a>where he uses a fixed point combinator. I'm not sure I'd want to implement that in production code as none of my&nbsp;collogues&nbsp;would
 understand how it worked! I'd have to bow to simplicity and introduce local mutation and use an explicit stack rather than the function stack. It's a very interesting article though.</p>
<p>posted by Parmenio</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634192946580000000</link>
		<pubDate>Sun, 05 Sep 2010 14:44:18 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634192946580000000</guid>
		<dc:creator>Parmenio</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Thanks! Bart's post is amazing.</p>
<p>&nbsp;</p>
<p>I would like to add a few bits.</p>
<p>&nbsp;</p>
<p>Bart mentions this Y combinator:</p>
<p>&nbsp;</p>
<p><pre class="brush: text">static Func&lt;T, R&gt; Fix&lt;T, R&gt;(Func&lt;Func&lt;T, R&gt;, Func&lt;T, R&gt;&gt; f) { FuncRec&lt;T, R&gt; fRec = r =&gt; t =&gt; f(r(r))(t); return fRec(fRec); } delegate Func&lt;T, R&gt; FuncRec&lt;T, R&gt;(FuncRec&lt;T, R&gt; f); </pre></p>
<p>&nbsp;</p>
<p>It is not so easy to see why it works. (It works because Bart leverages recursive types, c.f., FuncRec, and this is one way of getting a fixed point combinator; see
<a href="http://en.wikipedia.org/wiki/Fixed_point_combinator#Example_of_encoding_via_recursive_types">
here</a>.) Anyway, let's try something else. Our Haskell-based Y-combinator, as mentioned in my talk, would be rendered in C# as follows:</p>
<p>&nbsp;</p>
<p><pre class="brush: csharp">static Func&lt;T, R&gt; Fix&lt;T, R&gt;(Func&lt;Func&lt;T, R&gt;, Func&lt;T, R&gt;&gt; f) { return f(Fix(f)); }</pre></p>
<p>&nbsp;</p>
<p>You have to admit that this definition looks much simpler. We do not rely on recursive types; instead Fix is recursively defined. It is, in fact,
<strong>the definitional property of a fixed point</strong>. That is, the fixed point of a function must be such that if we apply the function to the fixed point, then we get back the fixed point. The reason that it works in Haskell (or a lazy language in general)
 is that it essentially also captures<strong> the computational notion of recursive unfolding</strong>. That is, to compute the fixed point of a function, what we do is, we apply the function, and as we hit its recursive reference we just compute the fixed
 point, which means that we apply the function, and as we hit its recursive reference, but only then, we compute the fixed point,&nbsp;which means that we apply the function, etc. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>&nbsp;</p>
<p>Now, the bad news is that C# is not lazy and hence the above transcription of our really easy to understand Y combinator does not work. We get a stack overflow (not just for greater arguments but for any arguments). However, there is simple trick that gives
 us <strong>a computationally useful Y combinator that is still easy to understand</strong>; we need to defer recursive evaluation until it is really needed, i.e., we need to make the application of the Y combinator lazy.</p>
<p>&nbsp;</p>
<p>Hence, this works:</p>
<p>&nbsp;</p>
<p><pre class="brush: csharp">static Func&lt;T, R&gt; Fix&lt;T, R&gt;(Func&lt;Func&lt;T, R&gt;, Func&lt;T, R&gt;&gt; f) { return f(t =&gt; Fix(f)(t)); } static void Main(string[] args) { var factorial = Fix&lt;int,int&gt;(fac =&gt; n =&gt; n == 0 ? 1 : n * fac(n-1)); Debug.WriteLine(factorial(5)); }</pre></p>
<p>posted by user42</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634193391220000000</link>
		<pubDate>Mon, 06 Sep 2010 03:05:22 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634193391220000000</guid>
		<dc:creator>user42</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Hi,</p>
<p>&nbsp;</p>
<p>while watching this new lecture, at 8:00 after adding Pred into the simple language interpreter, you say there's no change in its semantic domain. I'd expect there is a change, from type Value = Nat to type Value = Maybe Nat, and the definition for Nat staying
 the same, as type Nat = Int. Does this make sense? </p>
<p>&nbsp;</p>
<p>And, thanks a lot for the lectures! Very interesting stuff, and a clear presentation. Can't wait for the next ones, monads especially. Interpreters are of course the essence of Monads (?) (and vice versa <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> ). In that light, when you have { interpret (Succ
 x) = (Just.(&#43;1)) $$ interpret x }, it could've been redefined as an optimizing monad to push the (&#43;1) inside, hoping to catch the rogue Pred early on, making&nbsp; { interpret (Succ (Pred x))&nbsp; } always equivalent to { interpret (Pred (Succ x)) }, transforming it
 on the fly into just { interpret x }. Making { Succ(Pred Zero) } an invalid expression is too operational-minded IMO. I mean it in general, not here in this lecture of course where you have to keep things simple. And partial application would still be needed
 of course.</p>
<p>posted by Will48</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634193819130000000</link>
		<pubDate>Mon, 06 Sep 2010 14:58:33 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634193819130000000</guid>
		<dc:creator>Will48</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>re: &quot;semantic domain change from Value = Nat to Value = Maybe Nat&quot;</p>
<p>&nbsp;</p>
<p>We had first:</p>
<p>&nbsp;</p>
<p><pre class="brush: text">interpret :: Term -&gt; Value where Value = Nat</pre></p>
<p>&nbsp;</p>
<p>Then we had (option 1):</p>
<p>&nbsp;</p>
<p><pre class="brush: text">interpret :: Term -&gt; Maybe Value where Value = Nat</pre></p>
<p>&nbsp;</p>
<p>As you mention, we could also have done instead (option 2):</p>
<p>&nbsp;</p>
<p><pre class="brush: text">interpret :: Term -&gt; Value where Value = Maybe Nat</pre></p>
<p>&nbsp;</p>
<p>The reason for favoring option 1 on my side is that I view partiality (i.e., the application of Maybe) really as &quot;effect&quot; involved in computing values. Here, I use the terms &quot;values vs. computations&quot;&nbsp;in the sense of monadic style already. (Interestingly,
 Wadler, in his essence paper, makes partiality part of his Value domain, see his constructor &quot;Wrong&quot;, but it is only needed for as long as he doesn't replace it by the use of an error monad.) Another reason for my preference is that the used style for Value
 makes it also accessible to extension (as needed for Boolean values and functions later).</p>
<p>&nbsp;</p>
<p>Now, when I said that no semantic domain changed, I should really have emphasized that no *named* domain changed, but the result type of the meaning-giving function, i.e., the denotation type for terms, has changed. Precision would be gained by assigning
 an explicit name to the result type as in:</p>
<p>&nbsp;</p>
<p><pre class="brush: text">interpret :: Term -&gt; Meaning where Meaning = Maybe Term Value = Nat</pre></p>
<p>&nbsp;</p>
<p>Thanks for catching this.</p>
<p>&nbsp;</p>
<p>re: &quot;Admitting&nbsp;Succ(Pred Zero)&quot;</p>
<p>re: &quot;interpret (Succ (Pred x)) &nbsp;\equiv interpret (Pred (Succ x))&quot;</p>
<p>&nbsp;</p>
<p>Not sure. If you can suggest some patched code, perhaps, I can say whether I like it or not <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>&nbsp;</p>
<p>Do you agree with the following views?</p>
<p>&nbsp;</p>
<p>If someone really consumes the result of (Pred Zero) as in Console.WriteLn, then we have to throw.</p>
<p>&nbsp;</p>
<p>If someone's code is not strict in the result of&nbsp;(Pred Zero), then we can succeed (in a lazy language).</p>
<p>&nbsp;</p>
<p>Thanks for the comments.&nbsp;</p>
<p>&nbsp;</p>
<p>Regards,</p>
<p>Ralf</p>
<p>&nbsp;</p>
<p>posted by user42</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634193861020000000</link>
		<pubDate>Mon, 06 Sep 2010 16:08:22 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634193861020000000</guid>
		<dc:creator>user42</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Thanks for clarifying the (Maybe Value) thing for me. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> I really did have Meaning and Value conflated.</p>
<p>&nbsp;</p>
<p>Your &quot;views&quot; at the end of the post make total sense to me. About the code, I was thinking along the lines of</p>
<p>&nbsp;</p>
<p>&nbsp; interpret Zero = Just 0</p>
<p>&nbsp; interpret (Succ x) = interpret' 1 x</p>
<p>&nbsp; interpret (Pred x) = interpret' (-1) x</p>
<p>&nbsp; interpret' n (Succ x) = interpret' (n&#43;1) x</p>
<p>&nbsp; interpret' n (Pred x) = interpret' (n-1) x</p>
<p>&nbsp; interpret' n Zero = if n&gt;=0 then Just n else Nothing</p>
<p>&nbsp;</p>
<p>This really goes to the separation of <em>timelines </em>(<em>combination </em>
time vs <em>execution/run </em>time) as I see it as the essential feature of monads. To do something (here, (1&#43;) )
<em>after</em> the processing is done, or <em>while</em> processing - <em>after </em>
combining all the monadic actions, or <em>while </em>combining them. </p>
<p>&nbsp;</p>
<p>But it <em>is </em>an embellishement.</p>
<p>posted by Will48</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194437900000000</link>
		<pubDate>Tue, 07 Sep 2010 08:09:50 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194437900000000</guid>
		<dc:creator>Will48</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Wonderful proposal!</p>
<p>&nbsp;</p>
<p>There is nothing essentially monadic about this code.</p>
<p>In fact, I don't know how to usefully classify this approach, but is very systematic of course.</p>
<p>It smells a bit like CPS because of the way you pass around the current result of interpreted constructors so far.</p>
<p>&nbsp;</p>
<p>At a general level, I think what you are proposing is to try to remain defined in cases where the partiality of a surface domain (such as Nat) can be accommodated for with a more liberal, internal domain (such as Int). I can see that this overall idea of
 being more restricted at the interface level than in the internal design of a system with intermediate results of computation makes very much sense.</p>
<p>&nbsp;</p>
<p>This is an unusual technique in interpretation <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>&nbsp;</p>
<p>Would you say that your code is sufficiently equivalent (and in intention and behavior) to the following perhaps more direct approach?</p>
<p>&nbsp;</p>
<p><pre class="brush: text">data Term = Zero | Succ Term | Pred Term type Nat = Int -- We won't use negative numbers. interpret :: Term -&gt; Maybe Nat interpret x = case interpret' x of n | n &gt;= 0 -&gt; Just n otherwise -&gt; Nothing where interpret' :: Term -&gt; Int interpret'
 Zero = 0 interpret' (Succ x) = interpret' x &#43; 1 interpret' (Pred x) = interpret' x - 1 main = do print $ interpret $ Succ $ Succ $ Succ $ Pred $ Pred $ Zero </pre></p>
<p>&nbsp;</p>
<p>This version makes interpretation operate on Int but it projects to Nat at the very end.</p>
<p>&nbsp;</p>
<p>Cool, this made me thinking!</p>
<p>&nbsp;</p>
<p>posted by user42</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194531610000000</link>
		<pubDate>Tue, 07 Sep 2010 10:46:01 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194531610000000</guid>
		<dc:creator>user42</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>Yes, but what if we didn't have full Int to use at the intermediate level? My approach would still work, as in</p>
<p>&nbsp;</p>
<p><pre class="brush: text"> interpret Zero = Just 0 interpret (Succ x) = interpretPos 1 x interpret (Pred x) = interpretNeg 1 x interpretPos n Zero = Just n interpretPos n (Succ x) = interpretPos (n&#43;1) x interpretPos n (Pred x) = if n&gt;0 then interpretPos (n-1) x
 else interpretNeg 1 x interpretNeg n Zero = if n&gt;0 then Nothing else Just n interpretNeg n (Pred x) = interpretNeg (n&#43;1) x interpretNeg n (Succ x) = if n&gt;0 then interpretNeg (n-1) x else interpretPos 1 x</pre></p>
<p>&nbsp;</p>
<p>This way we don't demand the existence of extended domain prior to our defining it (we
<em>didn't</em> define negatives above, but we could, now - just using Either instead of Maybe).</p>
<p>&nbsp;</p>
<p>What I mean by my reference to monads is that I see it as essential to monads the separation of monad composition timeline and monad execution timeline, which makes optimization (pre-processing) while composing, possible - and that's what my version it doing.
 Also &quot;monadic&quot; is that my interpretPos/Neg pair encode and carry along the additional data. Or something like that. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>
<p>posted by Will48</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194636010000000</link>
		<pubDate>Tue, 07 Sep 2010 13:40:01 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194636010000000</guid>
		<dc:creator>Will48</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[
<p>One might say that your revised approach effectively does operate on Int (incl. negative numbers) in the sense of using this encoding of Int (even though you switch between alternatives through functions but not through constructors):</p>
<p>&nbsp;</p>
<p><pre class="brush: text">data PosNat = One | Succ PosNat data Int = Zero | PosInt PosNat | NegInt PosNat</pre></p>
<p>&nbsp;</p>
<p>... and yes, you could be using the reader (environment) monad for passing around the data except that all your equations are non-oblivious to the extra argument (excerpt perhaps the interpretPos case for Zero). In such a setting, the reader monad gives
 you little leverage.</p>
<p>&nbsp;</p>
<p>posted by user42</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194665110000000</link>
		<pubDate>Tue, 07 Sep 2010 14:28:31 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634194665110000000</guid>
		<dc:creator>user42</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Dr. Ralf L&#228;mmel - Advanced Functional Programming - Evolution of an Interpreter</title>
		<description>
			<![CDATA[Hi Ralf,<br />Could you please share the solution to the last riddle in the video?<br />Regards,<br />Kashyap<p>posted by Kashyap</p>]]>
		</description>
		<link>http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634254014460000000</link>
		<pubDate>Mon, 15 Nov 2010 07:04:06 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter#c634254014460000000</guid>
		<dc:creator>Kashyap</dc:creator>
	</item>
</channel>
</rss>