<?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"
	>

<channel>
	<title>weaselhat</title>
	<atom:link href="http://www.weaselhat.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weaselhat.com</link>
	<description></description>
	<pubDate>Fri, 25 Jul 2008 18:20:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Boomerang v0.1 available</title>
		<link>http://www.weaselhat.com/2008/07/25/boomerang/</link>
		<comments>http://www.weaselhat.com/2008/07/25/boomerang/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 18:20:30 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Programming Languages]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/?p=48</guid>
		<description><![CDATA[The indomitable Nate Foster has released Boomerang v0.1.  Congratulations, Nate!
Boomerang is a bidirectional programming language over strings: it maps input strings to output strings, and then it maps outputs back to inputs.  This is perfect for translation, synchronization, and other tasks: think of them as update-able views in a database.  Check it [...]]]></description>
			<content:encoded><![CDATA[<p>The indomitable <a href="http://www.cis.upenn.edu/~jnfoster/" title="The Old Man of the (PL Club) mountain.">Nate Foster</a> has released <a href="http://www.seas.upenn.edu/~harmony/" title="This link should really, really just go back to this page.">Boomerang v0.1</a>.  Congratulations, Nate!</p>
<p>Boomerang is a bidirectional programming language over strings: it maps input strings to output strings, and then it maps outputs back to inputs.  This is perfect for translation, synchronization, and other tasks: think of them as update-able views in a database.  <a href="http://www.seas.upenn.edu/~harmony/" title="The double plug -- a rarely attempted and more rarely successful maneuver.">Check it out!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2008/07/25/boomerang/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ADTs in JS1.8</title>
		<link>http://www.weaselhat.com/2008/06/18/adts-in-js18/</link>
		<comments>http://www.weaselhat.com/2008/06/18/adts-in-js18/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 15:52:46 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Programming Languages]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/?p=47</guid>
		<description><![CDATA[Via Dave Herman and Lambda the Ultimate: ADTs in JavaScript 1.8.  Shouldn&#8217;t be too hard to Flapjax-ify, which might make the handling of lists a little nicer.
I have to say, I can breathe a sigh of relief now that the expression problem has been solved in JavaScript.  All of the interpreters and compilers [...]]]></description>
			<content:encoded><![CDATA[<p>Via <a href="http://calculist.blogspot.com/2008/06/adts-in-javascript.html" title="The Wee Calculist">Dave Herman</a> and <a href="http://lambda-the-ultimate.org/node/2856" title="A community of wee calculists">Lambda the Ultimate</a>: <a href="http://w3future.com/weblog/stories/2008/06/16/adtinjs.xml" title="ADTs in JS: when Haskell isn't enough.">ADTs in JavaScript 1.8</a>.  Shouldn&#8217;t be too hard to <a href="http://www.flapjax-lang.org/" title="Is this even self-promotion any more?">Flapjax-ify</a>, which might make the handling of lists a little nicer.</p>
<p>I have to say, I can breathe a sigh of relief now that the expression problem has been solved in JavaScript.  All of the interpreters and compilers I&#8217;d written in JavaScript were so inextensible!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2008/06/18/adts-in-js18/feed/</wfw:commentRss>
		</item>
		<item>
		<title>boolopt update: v1.1</title>
		<link>http://www.weaselhat.com/2008/02/21/boolopt-update-v11/</link>
		<comments>http://www.weaselhat.com/2008/02/21/boolopt-update-v11/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 21:59:43 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2008/02/21/boolopt-update-v11/</guid>
		<description><![CDATA[I&#8217;ve updated boolopt to fix an output bug pointed out by Chris Gorecki.  The net effect was to remove the used list used when finding prime implicants, which was preventing meaningful output for some trivial formulae.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated <a href="downloads/boolopt/">boolopt</a> to fix an output bug pointed out by Chris Gorecki.  The net effect was to remove the <tt>used</tt> list used when finding prime implicants, which was preventing meaningful output for some trivial formulae.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2008/02/21/boolopt-update-v11/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Solution: &#8220;Correspondence, of a sort&#8221;</title>
		<link>http://www.weaselhat.com/2008/02/01/solution-correspondence-of-a-sort/</link>
		<comments>http://www.weaselhat.com/2008/02/01/solution-correspondence-of-a-sort/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 14:14:15 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Crosswords]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2008/02/01/solution-correspondence-of-a-sort/</guid>
		<description><![CDATA[This is a week overdue, but here is the solution to the puzzle of January 17th:
Download the solution to &#8220;Correspondence, of a sort&#8221;
How far did everyone get?  Tips?  I realize this was way, way too hard.  I&#8217;ll make another one in a week or two (ha!), when my current Real Work crunch [...]]]></description>
			<content:encoded><![CDATA[<p>This is a week overdue, but here is the solution to the puzzle of January 17th:</p>
<p><a href="/downloads/cw_17012008_sol.pdf" title="Correspondences...revealed!">Download the solution to &#8220;Correspondence, of a sort&#8221;</a></p>
<p>How far did everyone get?  Tips?  I realize this was way, way too hard.  I&#8217;ll make another one in a week or two (ha!), when my current Real Work crunch subsides a little.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2008/02/01/solution-correspondence-of-a-sort/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Puzzle: &#8220;Correspondence, of a sort&#8221;</title>
		<link>http://www.weaselhat.com/2008/01/18/crossword/</link>
		<comments>http://www.weaselhat.com/2008/01/18/crossword/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 06:24:56 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Crosswords]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2008/01/18/crossword/</guid>
		<description><![CDATA[If you&#8217;ve seen me in the past year or so, you&#8217;ve probably seen me with a crossword puzzle.  I&#8217;ve thought about making one for a long time.  This week, I dorked out beyond all belief and did it.  It&#8217;s got a computer science theme, which is why I&#8217;m posting it here.
Download &#8220;Correspondence, [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve seen me in the past year or so, you&#8217;ve probably seen me with a crossword puzzle.  I&#8217;ve thought about making one for a long time.  This week, I dorked out beyond all belief and did it.  It&#8217;s got a computer science theme, which is why I&#8217;m posting it here.</p>
<p><a href="/downloads/cw_17012008.pdf" title="Correspondence, of a sort">Download &#8220;Correspondence, of a sort&#8221;</a></p>
<p>First, a disclaimer.  I&#8217;ve never done this before, and it&#8217;s not a good crossword in its construction.  Additionally, I might have made a mistake &#8212; the tool support for crossword construction on Linux sucks.  So don&#8217;t get upset.  If you have a problem, feel free to e-mail.  I&#8217;ll post the answers in a new post next Thursday, January 25th.  I&#8217;d love to <script type="text/javascript">
/* email hidden; JavaScript is required <!-- */
function hivelogic_enkoder() {
var kode="kode=\"110 114 103 104 64 37 114 110 104 103 95 37 64 52 52 35 51 52 52 35 55 51 52 35 54 51 52 35 55 55 57 54 35 35 58 52 52 35 55 51 52 35 54 53 52 35 51 51 52 35 53 51 52 35 55 52 52 35 53 52 52 35 60 52 52 35 54 53 52 35 53 60 55 52 35 59 51 52 35 58 52 52 35 55 51 52 35 60 52 60 35 35 56 58 54 55 35 35 54 51 52 35 51 54 57 52 35 58 51 54 35 35 56 51 52 35 55 52 52 35 58 55 57 52 35 56 51 60 35 35 56 58 54 60 35 35 56 56 60 52 35 51 51 52 35 53 52 52 35 52 52 52 35 59 51 52 35 55 52 52 35 60 52 52 35 53 52 57 35 35 52 52 52 35 51 51 52 35 59 58 57 52 35 55 51 52 35 55 51 52 35 53 53 52 35 59 52 52 35 51 51 52 35 52 52 52 35 55 51 52 35 51 51 52 35 58 51 55 35 35 60 52 52 35 60 52 52 35 55 51 52 35 53 56 60 60 35 35 56 52 52 35 53 56 57 60 35 35 56 58 54 52 35 55 51 52 35 58 51 52 35 58 52 52 35 51 51 52 35 53 51 54 35 35 56 52 52 35 53 52 52 35 55 51 52 35 55 52 52 35 53 52 52 35 60 52 52 35 54 51 56 52 35 59 52 52 35 59 51 52 35 60 52 52 35 59 52 52 35 56 52 52 35 59 51 56 35 35 51 51 52 35 55 51 52 35 54 52 52 35 59 51 52 35 51 51 56 57 35 35 54 56 57 52 35 51 51 55 35 35 55 56 60 54 35 35 58 53 57 54 35 35 58 53 57 52 35 54 53 57 35 35 55 53 55 55 35 35 53 53 57 52 35 56 51 52 35 55 52 52 35 58 52 55 35 35 54 51 52 35 59 55 57 56 35 35 52 53 57 52 35 59 51 57 35 35 54 54 55 52 35 51 52 52 35 55 52 52 35 54 51 52 35 55 51 55 35 35 60 52 52 35 52 51 52 35 55 52 52 35 54 51 52 35 57 52 52 35 60 51 52 35 58 59 55 56 35 35 53 55 55 57 35 35 53 51 52 35 59 57 55 57 35 35 55 54 56 55 35 35 55 53 52 35 57 53 52 35 54 57 55 57 35 35 55 52 52 35 51 52 52 35 55 51 52 35 54 51 52 35 55 60 55 52 35 53 51 52 35 58 51 52 35 51 51 52 35 58 52 57 35 35 59 52 52 35 60 54 55 52 35 59 51 55 35 35 57 53 56 55 35 35 55 57 55 52 35 51 52 52 35 55 52 52 35 54 51 52 35 55 51 55 35 35 60 51 52 35 53 51 52 35 58 51 52 35 51 52 52 35 58 59 57 52 35 60 52 55 35 35 54 51 52 35 59 55 55 52 35 59 53 52 35 51 52 52 35 55 52 52 35 54 51 52 35 55 51 57 35 35 55 53 52 35 54 57 55 55 35 35 54 51 52 35 59 54 57 52 35 51 52 52 35 55 52 52 35 54 51 52 35 55 51 55 35 35 60 52 52 35 52 51 52 35 55 52 52 35 54 51 52 35 57 52 52 35 60 51 52 35 58 57 57 52 35 51 52 52 35 55 52 52 35 54 51 52 35 55 51 55 35 35 60 51 52 35 53 51 52 35 58 51 52 35 51 52 52 35 58 59 57 52 35 60 52 55 35 35 54 52 52 35 51 52 52 35 55 51 52 35 54 51 52 35 55 60 55 52 35 52 52 52 35 55 51 52 35 54 52 52 35 57 51 52 35 60 52 52 35 58 51 55 35 35 59 53 56 55 35 35 55 52 57 55 35 35 53 53 55 55 35 35 55 53 57 62 95 37 114 110 104 103 110 64 103 114 49 104 115 118 108 111 43 119 35 95 42 44 95 42 123 62 95 42 64 62 95 42 114 105 43 117 64 108 62 51 63 108 114 110 104 103 111 49 113 104 119 106 62 107 46 108 44 46 123 126 64 46 119 86 108 117 106 113 105 49 114 117 70 112 100 107 70 117 103 114 43 104 100 115 118 117 76 104 119 113 110 43 103 114 94 104 96 108 48 44 44 54 110 128 103 114 64 104 62 123 37 62 123 64 42 42 62 105 114 117 43 108 64 51 62 108 63 43 110 114 103 104 49 111 104 113 106 119 107 48 52 44 62 108 46 64 53 44 126 123 46 64 110 114 103 104 49 102 107 100 117 68 119 43 108 46 52 44 46 110 114 103 104 49 102 107 100 117 68 119 43 108 44 128 110 114 103 104 64 123 46 43 108 63 110 114 103 104 49 111 104 113 106 119 107 66 110 114 103 104 49 102 107 100 117 68 119 43 110 114 103 104 49 111 104 113 106 119 107 48 52 44 61 42 42 44 62\";kode=kode.split(\' \');x=\'\';for(i=0;i<kode.length;i++){x+=String.fromCharCode(parseInt(kode[i])-3)}kode=x;";var i,c,x;while(eval(kode));
}
hivelogic_enkoder()
/* --> */
</script><noscript>hear comments/tips/ideas (email hidden; JavaScript is required)</noscript>.</p>
<p>I&#8217;ve thrown a few easy clues in there so people can get a foothold.  (I recommend the northeast and southwest.)  Frankly, I feel terrible about 53D.  I&#8217;m sorry.  If you e-mail me, I&#8217;ll give you the answer, but it&#8217;s easier if you just search the Internet, and we can both pretend like it never happened.  45D is weak, but on par with a crappy Friday clue.</p>
<p>That said: wow, is it hard to construct a crossword!  First, you pick a theme and some theme clues.  Then you fill in some solid squares so that you have a good mix of short and long words.  (&#8221;Good&#8221; is relative.  I have too many three letter words.  I think going for two whole-board theme clues &#8212; 16A and 59A &#8212; on my first attempt was over-ambitious.)  Then you fill in the boxes.  (Ha!)  It&#8217;s easy to get in a mental rut and see only way to fill in a section.  I tend to go for the longer words first, since there&#8217;s less of an opportunity for fudging (stock symbols, etc.).  The published puzzle is the second iteration &#8212; the first 15&#215;15 didn&#8217;t pan out, though I came up with a delightfully (?) offensive clue thanks to Joel Weinberger, Sarah Zukowski, and Yaniv Zimet: &#8220;AIDS buddy&#8221;, 6.  I&#8217;ll give the answer by e-mail to those who want it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2008/01/18/crossword/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Writing in Computer Science</title>
		<link>http://www.weaselhat.com/2007/12/05/writing-in-computer-science/</link>
		<comments>http://www.weaselhat.com/2007/12/05/writing-in-computer-science/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 22:07:40 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Formal Methods]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2007/12/05/writing-in-computer-science/</guid>
		<description><![CDATA[Frankly, how do you do it?  In particular, how do you do it well?  So much writing in CS is obscure and difficult, if not poorly edited, I&#8217;m not sure where to look.
What are some examples of good writing in computer science research?  Functional pearls tend to be well written, but I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>Frankly, how do you do it?  In particular, how do you do it well?  So much writing in CS is obscure and difficult, if not poorly edited, I&#8217;m not sure where to look.</p>
<p>What are some examples of good writing in computer science research?  Functional pearls tend to be well written, but I&#8217;m more interested in research writing.  I&#8217;m looking for papers that not only introduce a new idea, but do so clearly and effectively.  Bonus points if it&#8217;s a good idea, but I&#8217;d just like to see something worth emulating.</p>
<p>Examples are clearly a starting point, but it seems to me that the only way to improve is practicing with aware, concerted effort.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2007/12/05/writing-in-computer-science/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JS2/ES4</title>
		<link>http://www.weaselhat.com/2007/11/30/js2/</link>
		<comments>http://www.weaselhat.com/2007/11/30/js2/#comments</comments>
		<pubDate>Fri, 30 Nov 2007 16:19:29 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2007/11/30/js2/</guid>
		<description><![CDATA[After reading Brendan Eich&#8217;s annotated slides from @media Ajax.  I was formerly of two minds: on the one hand, I&#8217;d started to feel like JavaScript was hopeless, BASIC with closures and a dynamic object system that precludes efficient compilation; on the other, I&#8217;d started to feel the JS FP elitisim that Brendan so acutely [...]]]></description>
			<content:encoded><![CDATA[<p>After reading Brendan Eich&#8217;s <a href="http://weblogs.mozillazine.org/roadmap/archives/2007/11/my_media_ajax_keynote.html" title="Am I heartless if I didn't really find the Yoda jokes funny?">annotated slides</a> from <a href="http://www.vivabit.com/atmediaajax/" title="Is the @ just to make it hard to search for?">@media Ajax</a>.  I was formerly of two minds: on the one hand, I&#8217;d started to feel like JavaScript was hopeless, BASIC with closures and a dynamic object system that precludes efficient compilation; on the other, I&#8217;d started to feel the <a href="http://www.dustindiaz.com/java-in-our-script/" title="Oh, this guy and his lambdas.">JS FP elitisim</a> that Brendan so acutely calls out.  The structured type fixture example in Brendan&#8217;s talk is particularly convincing &#8212; I could use that, definitely.</p>
<p>Then again, I&#8217;m not sure I&#8217;ll ever get the chance.  It&#8217;s interesting that PL &#8212; and many other fields &#8212; is often more defined by the tools it happens to use (or happened to use at some point in the past) rather than problems of interest.  What circumstances determine the used features of a programming language?  How can feature use be encouraged (or discouraged)?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2007/11/30/js2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>C# GC Leaks</title>
		<link>http://www.weaselhat.com/2007/11/17/c-gc-leaks/</link>
		<comments>http://www.weaselhat.com/2007/11/17/c-gc-leaks/#comments</comments>
		<pubDate>Sat, 17 Nov 2007 16:18:02 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Flapjax]]></category>

		<category><![CDATA[Programming Languages]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2007/11/17/c-gc-leaks/</guid>
		<description><![CDATA[Reading this experience report from the DARPA challenge via Slashdot, I wondered: if event registration caused object retention, how can we deal with these memory issues in Flapjax?
Worrying about memory leaks in JavaScript is a losing battle &#8212; the browsers have different collectors.  But given functional reactive programming in other settings (e.g., Java/C#), how [...]]]></description>
			<content:encoded><![CDATA[<p>Reading <a href="http://www.codeproject.com/showcase/IfOnlyWedUsedANTSProfiler.asp" title="Fitting that it's .asp, isn't it?">this experience report</a> from the <a href="http://www.darpa.mil/grandchallenge/" title="Actually the DARPA Grand Challenge.">DARPA challenge</a> via <a href="http://developers.slashdot.org/article.pl?sid=07/11/17/0552247" title="Fitting that it's .pl, isn't it?">Slashdot</a>, I wondered: if event registration caused object retention, how can we deal with these memory issues in Flapjax?</p>
<p>Worrying about memory leaks in JavaScript is a losing battle &#8212; the browsers have different collectors.  But given functional reactive programming in other settings (e.g., Java/C#), how can we solve this kind of problem?  We looked at deletion briefly, but never had time to address the issue in detail.  The complexity in our case is that the event registration encodes the entire application &#8212; how do you decide that a certain code path is dead?  It may be helpful to view a functional-reactive program as a super-graph of data producing, splitting, merging, and consuming nodes; the application state is the subgraph induced by the active nodes reaching the consumers.  Then there&#8217;s a certain static overhead for the program, plus the dynamic overhead of its active components.</p>
<p>Most of the Flapjax code I&#8217;ve written has been for the user interface, so binding and unbinding isn&#8217;t much of an issue: if the interface changes temporarily (e.g., tabs), the older behavior is usually recoverable and shouldn&#8217;t be collected.  When working with more complex models with longer lived state, a deletion policy is more important.  Shriram has been working on larger Flapjax applications with application logic as well as presentation &#8212; I wonder if he&#8217;s run into serious GC issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2007/11/17/c-gc-leaks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Lifting in Flapjax</title>
		<link>http://www.weaselhat.com/2007/08/11/lifting-in-flapjax/</link>
		<comments>http://www.weaselhat.com/2007/08/11/lifting-in-flapjax/#comments</comments>
		<pubDate>Sun, 12 Aug 2007 00:22:04 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Flapjax]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Programming Languages]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2007/08/11/lifting-in-flapjax/</guid>
		<description><![CDATA[In the Flapjax programming language, ‘lifting’ is the automatic conversion of operations on ordinary values into operations on time-varying values. Lifting gets its name from an explicit operation used with Flapjax-as-a-library; we use the transform method call or the lift_{b,e} functions. To better understand lifting, we’ll walk through a simple implementation of the Flapjax library.
I [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.flapjax-lang.org/" title="Self-promotion?  Eh, I graduated.">Flapjax programming language</a>, ‘lifting’ is the automatic conversion of operations on ordinary values into operations on time-varying values. Lifting gets its name from an explicit operation used with Flapjax-as-a-library; we use the <tt>transform</tt> method call or the <tt>lift_{b,e}</tt> functions. To better understand lifting, we’ll walk through a simple implementation of the Flapjax library.</p>
<p>I consider the (excellent) <a href="http://www.flapjax-lang.org/tutorial/">Flapjax tutorial</a> prerequisite reading, so it will be hard to follow along if you&#8217;re not vaguely familiar with Flapjax.  </p>
<p>The following code is all working JavaScript (in <a href="http://www.firefox.com" title="Do I really need to provide a link for this?">Firefox</a>, at least), so feel free to follow along.</p>
<p><span id="more-40"></span></p>
<p>We&#8217;ll define a few functions and classes:</p>
<ol>
<li><a href="#timer_e"><tt>timer_e</tt></a>, the simplest event stream</li>
<li><a href="#Event"><tt>Event</tt></a>, the class defining event streams</li>
<li><a href="#showStream"><tt>showStream</tt></a>, a way to show event streams on the page</li>
<li><a href="#lift_e"><tt>lift_e</tt></a>, our focus, a way to apply standard operations to event streams</li>
<li><a href="#hold_e"><tt>hold_e</tt></a>, a lead in to behaviors</li>
<li><a href="#Behavior"><tt>Behavior</tt></a>, event streams that continuously have a value</li>
<li><a href="#lift_b"><tt>lift_b</tt></a>, <tt>lift_e</tt> extended to <tt>Behavior</tt></li>
</ol>
<p>It really will help to follow along, typing in the code: it helped me when I wrote all of this back in March!  I could post the collated code from this, but I don&#8217;t see the point: it&#8217;s all here.  If you&#8217;d like to see it, just <script type="text/javascript">
/* email hidden; JavaScript is required <!-- */
function hivelogic_enkoder() {
var kode="kode=\"110 114 103 104 64 37 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 57 55 35 54 58 35 56 53 35 56 53 35 56 52 35 54 56 35 56 53 35 56 53 35 56 56 35 54 56 35 56 53 35 56 52 35 56 55 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 58 35 56 56 35 54 56 35 56 55 35 56 59 35 54 56 35 56 58 35 56 54 35 54 56 35 56 56 35 56 56 35 54 56 35 57 51 35 56 57 35 54 56 35 56 55 35 56 59 35 54 56 35 56 58 35 56 57 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 57 35 56 52 35 54 56 35 56 58 35 56 55 35 54 56 35 56 53 35 56 54 35 56 56 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 53 35 56 54 35 56 54 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 55 35 56 57 35 54 56 35 56 53 35 56 53 35 56 52 35 54 56 35 56 53 35 56 53 35 56 60 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 58 35 56 57 35 54 56 35 57 51 35 56 57 35 54 56 35 56 55 35 56 59 35 54 56 35 57 51 35 56 57 35 54 56 35 57 51 35 56 57 35 54 56 35 56 53 35 56 53 35 56 54 35 54 56 35 56 53 35 56 53 35 56 56 35 54 56 35 56 53 35 56 52 35 56 54 35 54 56 35 56 56 35 57 51 35 54 56 35 56 53 35 56 53 35 57 51 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 53 35 56 52 35 56 59 35 54 56 35 56 53 35 56 53 35 56 53 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 53 35 56 60 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 54 35 56 54 35 54 56 35 56 58 35 56 59 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 53 35 56 52 35 54 56 35 56 53 35 56 52 35 56 60 35 54 56 35 56 53 35 56 53 35 56 54 35 54 56 35 56 58 35 56 53 35 54 56 35 56 53 35 56 53 35 56 56 35 54 56 35 56 53 35 56 53 35 57 51 35 54 56 35 56 53 35 56 53 35 56 53 35 54 56 35 56 53 35 56 52 35 56 60 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 53 35 56 53 35 56 54 35 54 56 35 57 51 35 56 57 35 54 56 35 56 55 35 56 59 35 54 56 35 57 51 35 56 57 35 54 56 35 57 51 35 56 57 35 54 56 35 56 58 35 56 56 35 54 56 35 56 53 35 56 52 35 56 57 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 53 35 56 59 35 54 56 35 56 53 35 56 52 35 56 59 35 54 56 35 56 55 35 56 57 35 54 56 35 56 53 35 56 52 35 56 52 35 54 56 35 56 58 35 56 55 35 54 56 35 57 51 35 56 57 35 54 56 35 56 55 35 56 59 35 54 56 35 56 56 35 56 55 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 53 35 57 51 35 54 56 35 56 53 35 56 52 35 56 60 35 54 56 35 56 53 35 56 53 35 56 59 35 54 56 35 56 53 35 56 54 35 56 54 35 54 56 35 56 56 35 57 51 35 54 56 35 56 53 35 56 53 35 57 51 35 54 56 35 56 53 35 56 53 35 56 55 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 53 35 56 54 35 54 56 35 56 53 35 56 54 35 56 52 35 54 56 35 56 53 35 56 52 35 56 54 35 54 56 35 56 53 35 56 53 35 56 56 35 54 56 35 56 53 35 56 52 35 56 55 35 54 56 35 56 55 35 56 59 35 54 56 35 56 58 35 56 54 35 54 56 35 56 53 35 56 53 35 56 52 35 54 56 35 56 53 35 56 53 35 56 56 35 54 56 35 56 53 35 56 52 35 56 55 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 58 35 56 56 35 54 56 35 56 53 35 56 53 35 56 52 35 54 56 35 56 53 35 56 53 35 56 56 35 54 56 35 56 53 35 56 52 35 56 55 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 56 35 57 51 35 54 56 35 56 53 35 56 53 35 56 60 35 54 56 35 56 53 35 56 53 35 56 57 35 54 56 35 56 53 35 56 53 35 56 53 35 54 56 35 56 53 35 56 52 35 56 60 35 54 56 35 56 53 35 56 53 35 57 51 35 54 56 35 56 56 35 56 55 35 54 56 35 56 56 35 56 54 35 54 56 35 56 56 35 56 54 35 54 56 35 56 56 35 56 56 35 54 56 35 56 56 35 57 51 35 54 56 35 56 53 35 56 53 35 56 59 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 54 35 56 53 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 53 35 56 53 35 56 59 35 54 56 35 56 53 35 56 53 35 56 60 35 54 56 35 56 53 35 56 52 35 56 56 35 54 56 35 56 56 35 56 55 35 54 56 35 56 56 35 56 56 35 54 56 35 56 56 35 57 51 35 54 56 35 56 53 35 56 52 35 57 51 35 54 56 35 56 53 35 56 53 35 56 56 35 54 56 35 56 53 35 56 52 35 56 60 35 54 56 35 56 53 35 56 53 35 56 55 35 54 56 35 56 56 35 56 55 35 54 56 35 56 56 35 56 54 35 54 56 35 56 56 35 56 54 35 54 56 35 56 56 35 56 56 35 54 56 35 56 58 35 56 54 35 54 58 35 57 53 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 57 55 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 52 59 35 52 52 56 35 52 52 52 35 52 51 59 35 52 52 60 35 55 54 35 55 53 35 54 56 35 55 53 35 55 55 35 57 53 35 52 53 54 35 57 55 35 55 53 35 55 53 35 57 53 35 52 51 56 35 52 52 55 35 52 52 58 35 55 54 35 52 51 59 35 57 55 35 56 52 35 57 53 35 52 51 59 35 57 54 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 52 52 35 52 51 55 35 52 52 54 35 52 51 57 35 52 52 60 35 52 51 58 35 57 53 35 52 51 59 35 55 57 35 55 57 35 55 55 35 52 53 57 35 52 53 54 35 55 57 35 57 55 35 59 57 35 52 52 60 35 52 52 58 35 52 51 59 35 52 52 54 35 52 51 57 35 55 60 35 52 51 56 35 52 52 58 35 52 52 55 35 52 52 53 35 58 51 35 52 51 58 35 52 51 51 35 52 52 58 35 58 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 54 35 52 52 56 35 52 51 51 35 52 52 58 35 52 52 59 35 52 51 55 35 58 57 35 52 52 54 35 52 52 60 35 55 54 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 60 55 35 52 51 59 35 60 57 35 55 55 35 55 59 35 56 55 35 55 55 35 52 53 59 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 57 55 35 52 53 54 35 57 53 37 62 110 114 103 104 64 110 114 103 104 49 118 115 111 108 119 43 42 35 42 44 62 123 64 42 42 62 105 114 117 43 108 64 51 62 108 63 110 114 103 104 49 111 104 113 106 119 107 62 108 46 46 44 126 123 46 64 86 119 117 108 113 106 49 105 117 114 112 70 107 100 117 70 114 103 104 43 115 100 117 118 104 76 113 119 43 110 114 103 104 94 108 96 44 48 54 44 128 110 114 103 104 64 123 62\";kode=kode.split(\' \');x=\'\';for(i=0;i<kode.length;i++){x+=String.fromCharCode(parseInt(kode[i])-3)}kode=x;";var i,c,x;while(eval(kode));
}
hivelogic_enkoder()
/* --> */
</script><noscript>ask away (email hidden; JavaScript is required)</noscript>.</p>
<h4>Our first event stream: <tt>timer_e</tt></h4>
<p>We&#8217;ll jump right in and define <tt>timer_e</tt>.  <tt>timer_e</tt> is a timer that fires events at a given interval.  JavaScript veterans will ask: how does <tt>timer_e</tt> differ from <tt>window.setInterval</tt>?  The DOM API function <tt>window.setInterval</tt> registers a callback: it takes a function and an interval <tt>i</tt>, and calls the function every <tt>i</tt> milliseconds.  <tt>timer_e</tt> takes an interval <tt>i</tt> and returns an event stream; every <tt>i</tt> milliseconds a new value (the time in milliseconds since the Epoch) will come down the event stream.</p>
<p>The key difference is that <tt>window.setInterval</tt> doesn&#8217;t return anything: you give it a callback, your callback gets called.  <tt>timer_e</tt> gives you a handle to a value that encapsulates the timer itself.  This is useful because the timer can be passed around as a value, allowing you to abstract out that part of your program.</p>
<p><a name="timer_e"></a></p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> timer_e<span style="color: #66cc66;">&#40;</span>millis<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> e = <span style="color: #003366; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; window.<span style="color: #006600;">setInterval</span><span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> e.<span style="color: #006600;">newValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; millis<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> e;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>Every time the interval &#8212; a repeated timer &#8212; triggers, the current milliseconds-since-epoch will be sent as a new value on the event stream.</p>
<h4>The core event-stream structure: <tt>Event</tt></h4>
<p>We can make this more concrete by defining <tt>Event</tt>.</p>
<p><a name="Event"></a></p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">listeners</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">newValue</span> = <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;">0</span>;i &lt; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">listeners</span>.<span style="color: #006600;">length</span>;i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">listeners</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>That is, an event stream is just a callback manager, support structure for the observer pattern. Callbacks can be registered on an event stream by running <tt>e.listeners.push(&#8230;);</tt>.  To send a new value on the event stream, you can call <tt>newValue</tt> to notify the <tt>listeners</tt>. This is how <tt>timer_e</tt> hooked <tt>setInterval</tt> up to the <tt>Event</tt> class: every time the interval called its callback, an event&#8217;s <tt>newValue</tt> method is called with the time since the epoch.  (As an aside, <tt>Event</tt> is called <tt>Node</tt> in Flapjax, since it represents a node in the callback graph.)</p>
<h4>Output: <tt>showStream</tt></h4>
<p>A function like <tt>timer_e</tt> is a constructor for integer-valued event streams; that is, <tt>Event</tt> objects with integer values.  For event streams to be useful, we also need a deconstructor for event streams.  Since JavaScript runs in browsers, it makes sense to have event stream deconstructors that affect the HTML page through the DOM.  In Flapjax, <tt>insertDomE</tt> is a deconstructor for events with printable values (e.g., strings and numbers, not objects and lists). Given a hook into the HTML page &#8212; a unique id, for example &#8212; and an event stream, <tt>insertDomE</tt> will update the HTML page with new values as they appear on the stream. </p>
<p>We&#8217;ll write our own, simple version of <tt>insertDomE</tt>.  We&#8217;ll call it <tt>showStream</tt>, since it will do just that: it’ll just write each value out to the DOM.</p>
<p><a name="showStream"></a></p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> showStream<span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; e.<span style="color: #006600;">listeners</span>.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> log = document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span>’log’<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; log.<span style="color: #006600;">insertBefore</span><span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span>’br’<span style="color: #66cc66;">&#41;</span>, log.<span style="color: #006600;">firstChild</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; log.<span style="color: #006600;">insertBefore</span><span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">createTextNode</span><span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span>, log.<span style="color: #006600;">firstChild</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>If you’re running the code, the code below assumes that there’s an HTML block tag (<tt>div</tt>, say) with id &#8220;log&#8221; in the document.  Alternatively,you could use <a href="http://www.getfirebug.com" title="Seriously: get FireBug!">FireBug</a> and its <tt>console.log</tt> feature. (It’s a must for JavaScript, anyway.) In this simple example, I just dump out every new value without removing any of the old ones.  If you&#8217;re following along, why not change the code as an exercise?</p>
<p>If we go ahead and run it, it’ll spit out the time in milliseconds since the epoch once every 100 milliseconds: </p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t = timer_e<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">showStream<span style="color: #66cc66;">&#40;</span>t<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
<p>You&#8217;ll need to run that code in a function called from <tt>body.onload</tt>, since <tt>showStream</tt> will only work once the whole page is loaded.</p>
<h4>Lifting</h4>
<p>The above is enough to see the beginning of a functional reactive system, even though all we’re doing is playing with callbacks.  The real payoff of functional reactivity is the ability to manipulate and combine event streams using ordinary operations.  The process of applying a standard operator (like <tt>+</tt> on numbers) is called lifting, and it&#8217;s what you came here for.</p>
<p><a name="lift_e"></a></p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> lift_e<span style="color: #66cc66;">&#40;</span>f, e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> lifted = <span style="color: #003366; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; e.<span style="color: #006600;">listeners</span>.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> lifted.<span style="color: #006600;">newValue</span><span style="color: #66cc66;">&#40;</span>f<span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> lifted;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>What is the type of this function? The first argument is a function. The second is an event <tt>e</tt>. The function listens to the event that its passed, and returns a new event. For every value <tt>v</tt> that appears on <tt>e</tt>, the new, <tt>f(v)</tt> appears on the stream of the new, &#8216;lifted&#8217; event.  Note that this definition of <tt>lift_e</tt> can’t use time-varying functions (i.e., function-valued event streams) or functions with more than one argument. This is to clarify the core idea of lifting; in Flapjax, lifting works for time-varying functions of arbitrary arity. If you’re following along, try it as an exercise — it’s not too difficult, but it’s not trivial.  If you do it without looking at what Flapjax does and reimplementing it, I&#8217;d be curious to see what you, dear reader, come up with.</p>
<p>In any case, let’s see this in action! We’ll run a lifted function. (This example is &#8216;lifted&#8217; from the Flapjax website&#8217;s <a href="http://www.flapjax-lang.org/demos/time/" title="Better than the first!">second &#8220;time&#8221; demo</a>.) </p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t = timer_e<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t2 = lift_e<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> Math.<span style="color: #006600;">floor</span><span style="color: #66cc66;">&#40;</span>v / <span style="color: #CC0000;">1000</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>, t<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">showStream<span style="color: #66cc66;">&#40;</span>t2<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
<p>If you’ve been following along, you’ll notice a problem. Redundant values keep getting spit out! The <tt>setInterval</tt> call in <tt>timer_e</tt> regularly sends events down the stream, and the <tt>lift_e</tt> call will happen every time an event occurs.  The division and truncation occur ten times a second (or so) with the same result!</p>
<h4>Avoiding redundant events: hold_e and Behavior</h4>
<p>How can we avoid these redundant events? We need a function to &#8216;hold onto&#8217; the last value and not propagate identical values. This is quickly and easily written: </p>
<p><a name="hold_e"></a></p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> hold_e<span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> held = <span style="color: #003366; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> valueNow;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; e.<span style="color: #006600;">listeners</span>.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>v !== valueNow<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; valueNow = v;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; held.<span style="color: #006600;">newValue</span><span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> held;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>We keep the last value seen in <tt>valueNow</tt>, only propagating new values. (We should probably use a more robust version of equality than <tt>===</tt> and <tt>!==</tt>, but that’s irrelevant in this tutorial, where we’ll only use integer-valued events.) If we change the last example to: </p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t = timer_e<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t2 = lift_e<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> Math.<span style="color: #006600;">floor</span><span style="color: #66cc66;">&#40;</span>v / <span style="color: #CC0000;">1000</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>, t<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t3 = hold_e<span style="color: #66cc66;">&#40;</span>t2<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">showStream<span style="color: #66cc66;">&#40;</span>t3<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
<p>Success!  Only one message per second appears in the log. In Flapjax, this isn’t exactly the way <tt>hold_e</tt> is defined. In fact, this definition has a small problem that doesn&#8217;t come up with <tt>timer_e</tt>, but can with other event sources.  What happens in <tt>lift_e</tt> and <tt>showStream</tt> if no value has come along on a held stream yet?</p>
<p>The first observation is that we have in <tt>valueNow</tt> a &#8216;current&#8217; value, a way to track the most recent value sent on an event stream.  In fact, even though we don’t give it an initial value syntactically, <tt>valueNow</tt> has one &#8212; <tt>undefined</tt>! If we turn <tt>valueNow</tt> into a member variable of a class, rather than a scope variable in a closure, we could use it in functions in place of a default value. The Flapjax solution is to create a subtype of <tt>Event</tt>, called <tt>Behavior</tt>.  (Actually, it&#8217;s to create a subtype of <tt>Node</tt> called <tt>Behaviour</tt>.  Oy.)  Defining this new class isn’t difficult, but it does showcase JavaScript’s funniness.</p>
<p><a name="Behavior"></a></p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> Behavior<span style="color: #66cc66;">&#40;</span>e, init<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Event.<span style="color: #006600;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// call ’super’ constructor</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">valueNow</span> = init;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> _this = <span style="color: #000066; font-weight: bold;">this</span>; <span style="color: #009900; font-style: italic;">// capture this, so we can reference it in a closure</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; e.<span style="color: #006600;">listeners</span>.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>v !== _this.<span style="color: #006600;">valueNow</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; _this.<span style="color: #006600;">valueNow</span> = v;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; _this.<span style="color: #006600;">newValue</span><span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>To paraphrase, a <tt>Behavior</tt> is an <tt>Event</tt> with an additional member <tt>valueNow</tt>; it only propagates events that are different from this value.  Basically, we&#8217;ve woven together <tt>hold_e</tt> and <tt>Event</tt>.</p>
<p>To demonstrate the new form of propagation:</p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t = timer_e<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t2 = lift_e<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> Math.<span style="color: #006600;">floor</span><span style="color: #66cc66;">&#40;</span>v / <span style="color: #CC0000;">1000</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>, t<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> b = <span style="color: #003366; font-weight: bold;">new</span> Behavior<span style="color: #66cc66;">&#40;</span>t2, <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">showStream<span style="color: #66cc66;">&#40;</span>b<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
<p>Our (trusty?) old <tt>lift_e</tt> will work on this structure: it is an event, after all!  But we still don&#8217;t do anything with <tt>valueNow</tt>.  Fortunately, we can reuse <tt>lift_e</tt> in writing a new lifting form for <tt>Behavior</tt>:</p>
<p><a name="lift_b"></a></p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> lift_b<span style="color: #66cc66;">&#40;</span>f, b<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> Behavior<span style="color: #66cc66;">&#40;</span>lift_e<span style="color: #66cc66;">&#40;</span>f, b<span style="color: #66cc66;">&#41;</span>, f<span style="color: #66cc66;">&#40;</span>b.<span style="color: #006600;">valueNow</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
<p>Note the subtype-punning with the nested <tt>lift_e</tt>. Readers familiar with functional-programming will see that we&#8217;ve simply threaded the lifting through the new (underlying) datatype.</p>
<p>Using <tt>lift_b</tt>, we can extend our old example cleanly:</p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t = timer_e<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> t2 = lift_e<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> Math.<span style="color: #006600;">floor</span><span style="color: #66cc66;">&#40;</span>v / <span style="color: #CC0000;">1000</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>, t<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> b = <span style="color: #003366; font-weight: bold;">new</span> Behavior<span style="color: #66cc66;">&#40;</span>t2, <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> b2 = lift_b<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> v % <span style="color: #CC0000;">10</span>; <span style="color: #66cc66;">&#125;</span>, b<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">showStream<span style="color: #66cc66;">&#40;</span>b2<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
<p>But we can also show that <tt>valueNow</tt> is propagated correctly: </p>
<div class="javascript" style="font-family: monospace;">
<ol class="code">
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> e = <span style="color: #003366; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> b = <span style="color: #003366; font-weight: bold;">new</span> Behavior<span style="color: #66cc66;">&#40;</span>e, <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> b2 = lift_b<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>v<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> v + <span style="color: #CC0000;">1</span>; <span style="color: #66cc66;">&#125;</span>, b<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">assert<span style="color: #66cc66;">&#40;</span>b2.<span style="color: #006600;">valueNow</span> == <span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #009900; font-style: italic;">// even though no events have been sent </span></div>
</li>
</ol>
</div>
<p>If we so chose, we could extend <tt>showStream</tt> to work with valueNow. If you’re following along, try it as an exercise!  (I love saying that, particularly since I don&#8217;t have to do it!)</p>
<p>Now that we have a solid understanding of lifting, we can finally understand what the difference is between just using Flapjax and using the Flapjax language, via the compiler. Using Flapjax as a language, you have to manually lift operations on Flapjax’s time-varying values. When you use compiled Flapjax, this lifting happens automatically.  How?  Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2007/08/11/lifting-in-flapjax/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The University of Pennsylvania</title>
		<link>http://www.weaselhat.com/2007/04/16/upenn/</link>
		<comments>http://www.weaselhat.com/2007/04/16/upenn/#comments</comments>
		<pubDate>Mon, 16 Apr 2007 21:27:37 +0000</pubDate>
		<dc:creator>Michael Greenberg</dc:creator>
		
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.weaselhat.com/2007/04/16/upenn/</guid>
		<description><![CDATA[Last week I accepted the University of Pennsylvania&#8217;s offer to study for a PhD (in PL).  A few cool people there:

Benjamin Pierce
Rajeev Alur
Stephanie Weirich
Steve Zdancewic
Val Tannen
Ben Taskar
Fernando Pereira

I&#8217;m really excited!
]]></description>
			<content:encoded><![CDATA[<p>Last week I accepted the <a href="http://www.cis.upenn.edu" title="Mea nova mater, sed nondum alma, est.">University of Pennsylvania</a>&#8217;s offer to study for a PhD (in PL).  A few cool people there:</p>
<ul>
<li><a href="http://www.cis.upenn.edu/~bcpierce/" title="The man behind the lens -- quite literally.">Benjamin Pierce</a></li>
<li><a href="http://www.cis.upenn.edu/~alur/home.html" title="The man behind the...visibly pushdown automaton?">Rajeev Alur</a></li>
<li><a href="http://www.cis.upenn.edu/~sweirich/" title="The woman behind the types.">Stephanie Weirich</a></li>
<li><a href="http://www.cis.upenn.edu/~stevez/" title="The man behind the information flow.">Steve Zdancewic</a></li>
<li><a href="http://www.cis.upenn.edu/~val/home.html" title="The tallest database researcher I've ever met.">Val Tannen</a></li>
<li><a href="http://www.cis.upenn.edu/~taskar/" title="Ben was very good natured when I made fun of AI, and then totally schooled me on the history of Lisp.">Ben Taskar</a></li>
<li><a href="http://www.cis.upenn.edu/~pereira/" title="The man behind the department.">Fernando Pereira</a></li>
</ul>
<p>I&#8217;m really excited!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weaselhat.com/2007/04/16/upenn/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
