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

<channel>
	<title>Khoo Yit Phang</title>
	<atom:link href="http://khooyp.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://khooyp.wordpress.com</link>
	<description>Collecting my ideas and musings about programming</description>
	<lastBuildDate>Fri, 16 Jan 2009 16:21:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='khooyp.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Khoo Yit Phang</title>
		<link>http://khooyp.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://khooyp.wordpress.com/osd.xml" title="Khoo Yit Phang" />
	<atom:link rel='hub' href='http://khooyp.wordpress.com/?pushpress=hub'/>
		<item>
		<title>New release of Arrowlets: now with pair (***), split (&amp;&amp;&amp;), bind and join</title>
		<link>http://khooyp.wordpress.com/2008/11/03/new-release-of-arrowlets-now-with-pair-split-bind-and-join/</link>
		<comments>http://khooyp.wordpress.com/2008/11/03/new-release-of-arrowlets-now-with-pair-split-bind-and-join/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 22:54:29 +0000</pubDate>
		<dc:creator>Khoo Yit Phang</dc:creator>
				<category><![CDATA[Arrowlets]]></category>

		<guid isPermaLink="false">http://khooyp.wordpress.com/?p=33</guid>
		<description><![CDATA[I&#8217;ve just released a new version of Arrowlets which finally implements all the basic arrow combinators. Where then (a nicer alias of next1) expresses sequential composition—i.e., connect the output of f into the input of g—the combinators pair (***) and split (&#38;&#38;&#38;) express parallel composition—i.e., running f and g on the same input and outputting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khooyp.wordpress.com&amp;blog=4984473&amp;post=33&amp;subd=khooyp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released a new version of <a href="http://www.cs.umd.edu/projects/PL/arrowlets/download.xhtml">Arrowlets</a> which finally implements all the basic arrow combinators. Where <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-combinators.xhtml#compose"><code>then</code></a> (a nicer alias of <code>next</code><sup><a id="jump1" href="#ref1">1</a></sup>) expresses sequential composition—i.e., connect the output of <em>f</em> into the input of <em>g</em>—the combinators <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-combinators.xhtml#product"><code>pair</code></a> (<em>***</em>) and <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-combinators.xhtml#fanout"><code>split</code></a> (<em>&amp;&amp;&amp;</em>) express parallel composition—i.e., running <em>f</em> and <em>g</em> on the same input and outputting the combined result:</p>
<ul>
<li><code><em>f</em>.pair(<em>g</em>)</code> takes a <code><a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-tuples.xhtml#Pair">Pair</a>(<em>x</em>, <em>y</em>)</code> as input, runs <em>f</em> on <em>x</em> and <em>g</em> on <em>y</em> respectively, and combines the outputs into a <code>Pair(<em>fx</em>, <em>gy</em>)</code>;</li>
<li><code><em>f</em>.split(<em>g</em>)</code> takes any input <em>x</em>, runs both <em>f</em> and <em>g</em> on <em>x</em>, and combines the outputs into a <code>Pair(<em>fx</em>, <em>gx</em>)</code>.</li>
</ul>
<p>In previous releases of Arrowlets, arrowlets can be run in parallel, but they are not easy to synchronize as they run independently of each other. Using <code>pair</code> and <code>split</code> makes it much easier to perform synchronization, since they will wait for their constituent arrowlets to complete before outputting the combined result.</p>
<h3>Collecting outputs</h3>
<p>Oftentimes I need to keep the results from an earlier arrowlet in addition to that from the most recent arrowlet in a sequence. Two new combinators—<a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-combinators.xhtml#bind"><code>bind</code></a> and <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-combinators.xhtml#join"><code>join</code></a>—are useful for this purpose: they are similar to <code>then</code>, but will combine the input and the output in a <code>Pair</code>:</p>
<ul>
<li><code><em>f</em>.bind(<em>g</em>)</code> takes the input <em>x</em>, runs <em>f</em> on <em>x</em>, runs <em>g</em> on the <code>Pair(<em>x</em>, <em>fx</em>)</code> and outputs its result;</li>
<li><code><em>f</em>.join(<em>g</em>)</code> takes the input <em>x</em>, runs <em>f</em> on <em>x</em>, runs <em>g</em> on the output <em>fx</em> and combines the outputs into a <code>Pair(<em>fx</em>, <em>gfx</em>)</code>.</li>
</ul>
<h3>JavaScript <code>Function</code>, <code>Tuple</code> and <code>Arr</code></h3>
<p>If you haven&#8217;t yet noticed, all the new combinators above uses <code>Pair</code> objects, which is simply a tuple with two values (a tuple can be thought of as a collection of values). While arrows in Haskell can be naturally defined with pair tuples, it is a problem in JavaScript which has no notion of tuples! So, this release of Arrowlets introduces <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-tuples.xhtml#Tuple"><code>Tuple</code></a> objects as well as <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-tuples.xhtml#Pair"><code>Pair</code></a> objects (which are instances of <code>Tuple</code> with additional methods <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-tuples.xhtml#fst"><code>fst</code></a> and <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-tuples.xhtml#snd"><code>snd</code></a>), with support for <a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-tuples.xhtml#pattern-matching">pattern-matching</a>.</p>
<p>However, introducing tuples leads to compatibility issues with existing JavaScript functions which do not understand <code>Tuple</code> objects. Since one of my design goal for Arrowlets is to be as compatible as possible with existing JavaScript code, I spent a great while trying to bridge the mismatch between two different usage of functions:</p>
<ul>
<li><em>tuple-aware</em> functions that take a single tuple argument (e.g., for defining arrow combinators);</li>
<li><em>standard</em> JavaScript functions which take any number of arguments (and can be called with more or less arguments than declared).</li>
</ul>
<p>JavaScript doesn&#8217;t have Haskell&#8217;s sophisticated type system, so it is not possible to detect these two usage automatically. So, the solution I&#8217;ve come up with is to explicitly distinguish between these two usage of functions, and call them differently when the input is a tuple:</p>
<ul>
<li>tuple-aware functions are explicitly created as <code><a href="http://www.cs.umd.edu/projects/PL/arrowlets/api-arrowlets.xhtml#Arr">Arr</a>(function(tuple) { ... })</code>, and are called with the tuple as the only argument (somewhat resembles <code>arr</code> in Haskell);</li>
<li>standard JavaScript functions are declared normally as <code>function(x, y, ...) { ... }</code>, but are called with a <em>flattened</em> representation of the tuple as the argument list. E.g., <code>(function() { return Tuple(1,2,Tuple(Tuple(3,100),4,5)); }).then(Math.max)</code> will output <code>100<span style="font-family:'Lucida Grande';">. </span></code></li>
</ul>
<p>So far, this seems to me like the most intuitive way to use standard JavaScript functions with Arrowlets. I might revisit this issue in the future: I wonder if there is a way to define combinators in terms of records (JavaScript objects) instead of tuples?</p>
<h3>Next up&#8230;</h3>
<p>At this point, I need a testing framework for Arrowlets, but from my cursory survey, it seems that most JavaScript-based unit-testing framework aren&#8217;t adequately equipped to handle the asynchronous nature of Arrowlets. It occurs to me that with support for exceptions, Arrowlets itself makes a nice basis for a unit-testing framework, so that&#8217;s my plan for the next release.</p>
<p>I hope you enjoy this latest release of Arrowlets, and please use the comments to let me know of any issues!</p>
<p>P.S. I can&#8217;t quite figure out why Firefox/Tracemonkey takes 6x as long as WebKit/Squirrelfish Extreme to complete my <a href="http://www.cs.umd.edu/projects/PL/arrowlets/example-matrix-multiplication.xhtml">matrix multiplication</a> example. Any ideas why?</p>
<hr /><a id="ref1" href="#jump1">1</a> Thanks to Andrew Davey for this suggestion.</p>
<br />Posted in Arrowlets  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khooyp.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khooyp.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khooyp.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khooyp.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khooyp.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khooyp.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khooyp.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khooyp.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khooyp.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khooyp.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khooyp.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khooyp.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khooyp.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khooyp.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khooyp.wordpress.com&amp;blog=4984473&amp;post=33&amp;subd=khooyp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://khooyp.wordpress.com/2008/11/03/new-release-of-arrowlets-now-with-pair-split-bind-and-join/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yit</media:title>
		</media:content>
	</item>
		<item>
		<title>Introducing Path Projection and Arrowlets (and me)</title>
		<link>http://khooyp.wordpress.com/2008/10/16/introducing-path-projection-and-arrowlets-and-me/</link>
		<comments>http://khooyp.wordpress.com/2008/10/16/introducing-path-projection-and-arrowlets-and-me/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 19:57:15 +0000</pubDate>
		<dc:creator>Khoo Yit Phang</dc:creator>
				<category><![CDATA[Arrowlets]]></category>
		<category><![CDATA[Path Projection]]></category>
		<category><![CDATA[Site News]]></category>

		<guid isPermaLink="false">http://khooyp.wordpress.com/?p=5</guid>
		<description><![CDATA[I recently found a couple of blog posts writing my Arrowlets library. Also, I presented a poster at ICFP 2008, and it was quite exciting to meet with various researchers and bloggers who knew about my work. These events have inspired me to start blogging about Path Projection and Arrowlets, two of my research projects, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khooyp.wordpress.com&amp;blog=4984473&amp;post=5&amp;subd=khooyp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently found a couple of blog posts writing my <a href="http://www.cs.umd.edu/projects/PL/arrowlets/">Arrowlets</a> library. Also, I presented a poster at <a href="http://www.cs.umd.edu/projects/PL/arrowlets/">ICFP 2008</a>, and it was quite exciting to meet with various researchers and bloggers who knew about my work. These events have inspired me to start blogging about Path Projection and Arrowlets, two of my research projects, and exchange ideas with fellow bloggers.</p>
<h3>Path Projection</h3>
<p><a href="http://khooyp.files.wordpress.com/2008/10/pathproj-closeup.png"><img class="alignright size-medium wp-image-17" title="Path Projection Close-up Screenshot" src="http://khooyp.files.wordpress.com/2008/10/pathproj-closeup.png?w=221&#038;h=300" alt="Path Projection Close-up Screenshot" width="221" height="300" /></a><a href="http://www.cs.umd.edu/projects/PL/PP/">Path Projection</a>, my main research project, is a user interface for exploring program paths, such as call stacks or execution traces. It is designed to work with defect detection tools that typically produce paths as part of their error report; taking as input an XML file describing the path and the program source code, and automatically generating a visualization that makes it easier for programmers to understand the cause of the error. We have some promising results from a user study that showed users performing a bug triaging task 18% faster compared to a conventional source code viewer.</p>
<p>I developed Path Projection because I believe that, while there are many useful defect detection tools today, they are often very difficult to use. A good tool should consider the user interface to be just as important as the algorithm, because ultimately, a programmer has to understand the reported error to be able to fix it.</p>
<h3>Arrowlets</h3>
<p>You might be surprised to know that Path Projection is a web-browser based tool. It is written mainly in JavaScript with some offline preprocessing, but no server component. In developing Path Projection however, I found the standard way of writing responsive event-driven programs in JavaScript to be quite unmanageable, invariably leading to a complicated spaghetti mess of event handlers and callback plumbing.</p>
<p>And that&#8217;s the motivation for my <a href="http://www.cs.umd.edu/projects/PL/arrowlets/">Arrowlets</a> library: it is a JavaScript library based on <a href="http://www.haskell.org/arrows/">arrows</a> that makes it easy to write event-driven programs. Arrowlets allows you to compose asynchronous event listeners, synchronous event handlers or any function using a uniform arrow combinator interface. My favorite example is drag-and-drop, which in Arrowlets, the entire control-flow can be composed as in the following snippet:</p>
<p><pre class="brush: jscript;">var dragOrDropA =
    (   (EventA(&quot;mousemove&quot;).next(dragA).next(Repeat))
     .or(EventA(&quot;mouseup&quot;).next(dropA).next(Done))
    ).repeat();

var dragDropOrCancelA =
       (EventA(&quot;mousemove&quot;).next(dragA).next(dragOrDropA))
    .or(EventA(&quot;mouseup&quot;).next(cancelA));

var dragAndDropA = /* drag-and-drop */
    EventA(&quot;mousedown&quot;).next(setupA).next(dragDropOrCancelA);
ElementA(&quot;dragtarget&quot;).next(dragAndDropA).run();</pre></p>
<p>Arrowlets cleanly separates the actual event handling code from the callback plumbing, and also makes it much easier to write event-driven programs in a modular fashion (and quite elegantly too, if I may add).</p>
<p>(I should thank <a href="http://blog.tupil.com/look-ma-no-callbacks/">Chris Eidhof</a> and <a href="http://notes-on-haskell.blogspot.com/2008/08/arrows-in-javascript.html">Adam Turoff</a> for blogging about Arrowlets.)</p>
<h3>About Me</h3>
<p>And lastly, let me introduce myself: I&#8217;m a graduate student at the University of Maryland and a member the <a href="http://www.cs.umd.edu/projects/PL/">PL group</a> with <a href="http://www.cs.umd.edu/~mwh/">Mike Hicks</a>, <a href="http://www.cs.umd.edu/~jfoster/">Jeff Foster</a>, and <a href="http://www.cs.umd.edu/~vibha/">Vibha Sazawal</a> as my advisors. My research interest lies in developing tools or libraries that make programming tasks easy, and make sophisticated program techniques accessible to programmers of various skill levels.</p>
<p>P.S. I write my name in Chinese order which tends to confuse people, so Khoo is my last name and Yit Phang my first name, and you can call me Yit.</p>
<br />Posted in Arrowlets, Path Projection, Site News  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khooyp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khooyp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khooyp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khooyp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khooyp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khooyp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khooyp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khooyp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khooyp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khooyp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khooyp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khooyp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khooyp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khooyp.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=khooyp.wordpress.com&amp;blog=4984473&amp;post=5&amp;subd=khooyp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://khooyp.wordpress.com/2008/10/16/introducing-path-projection-and-arrowlets-and-me/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Yit</media:title>
		</media:content>

		<media:content url="http://khooyp.files.wordpress.com/2008/10/pathproj-closeup.png?w=221" medium="image">
			<media:title type="html">Path Projection Close-up Screenshot</media:title>
		</media:content>
	</item>
	</channel>
</rss>
