<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lane&#039;s Blog</title>
	<atom:link href="http://blog.downstairspeople.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.downstairspeople.org</link>
	<description>A blog of fleshlings and robots.</description>
	<lastBuildDate>Sat, 17 Jul 2010 23:05:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Memoized Dataflow Streams</title>
		<link>http://blog.downstairspeople.org/2010/07/17/memoized-dataflow-streams/</link>
		<comments>http://blog.downstairspeople.org/2010/07/17/memoized-dataflow-streams/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 21:06:45 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=170</guid>
		<description><![CDATA[In reactive programming we can choose between two models: &#8220;pull,&#8221; in which we run a computation each time output is required, and &#8220;push,&#8221; in which we run the computation each time input arrives. Which model we use depends on whether we are working with high-frequency or low-frequency data.  If we are writing a piece of [...]]]></description>
			<content:encoded><![CDATA[<p>In reactive programming we can choose between two models: &#8220;pull,&#8221; in which we run a computation each time output is required, and &#8220;push,&#8221; in which we run the computation each time input arrives.</p>
<p>Which model we use depends on whether we are working with high-frequency or low-frequency data.  If we are writing a piece of avionics software that measures pitch, yaw, and roll, then we need to constantly adjust the plane&#8217;s aerodynamic surfaces based on those variables.  We don&#8217;t need a notification when these variables change, because they change constantly.  The pull model would be perfect in this case.</p>
<p>On the other hand, engine temperature is every bit as critical to the health of the vehicle, but presumably that variable remains in equilibrium for long stretches of time, and small variations aren&#8217;t important.  We don&#8217;t want to waste CPU time monitoring temperature 100 cycles per second.  We might simply want to receive a notification whenever the engine temperature changes by 1 degree or more.  The push model works better here.</p>
<p>The problem:  How do I efficiently embed a low-frequency signal in a high-frequency channel?  If I pass the low-frequency signal naively, it will work, but entail much redundant computation.</p>
<p>When we want to avoid recomputing a value, we often use a memoization strategy.  However, in this case we need to memoize a data stream, not a function.</p>
<p>In the engine temperature example, it would be easy to memoize a function of type Int -&gt; a.  But we want to compose this function as part of a signal.  After all, if the engine temperature is low frequency, then so is any signal derived from the engine temperature.  The chain of transformations should be memoized along its entire length.  Further, this function risks artificially escalating a meaningless low-amplitude high-frequency component of an otherwise low frequency signal by imposing an arbitrary boundary: suppose that some engine vibration causes the temperature to oscillate rapidly between 198.9 and 199.05 degrees, which would truncate to 198 and 199?  This does not yield the notification heuristic we are looking for.</p>
<p>The solution:  Tag information with a unique signature at its point of departure and then memoize it at the point of arrival.  Transformations of the data stream also need to be tagged.  A source signature is either a unique integer, or an annotation of applying one signature to another. There is some overhead associated with comparing signatures, but this overhead can not be greater than the cost of performing the underlying operations.</p>
<p>Memoizable messages are very similar to applicative functors.  They can not, however, implement the Control.Applicative interface, because any pure constructor would be unsigned and therefore destroy memoization.</p>
<p>This memoization scheme requires three operations:</p>
<ul>
<li>Transmit: Sign a message with a unique signature, indicating its source.  If a subsequent signal is sufficiently similar, reuse the same signature.</li>
<li>Receive: Unpack a signal, memoizing against the signature of the previous input.</li>
<li>Apply: Combine two signals with their signatures.</li>
</ul>
<div id="attachment_185" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.downstairspeople.org/wp-content/uploads/2010/07/diagram1.png"><img class="size-medium wp-image-185" title="Memoized Message Passing Semantics" src="http://blog.downstairspeople.org/wp-content/uploads/2010/07/diagram1-300x212.png" alt="Diagram demonstrating memoized message passing semantics." width="300" height="212" /></a><p class="wp-caption-text">Memoized Message Passing Semantics</p></div>
<p>My implementation is in a module of rsagl-frp called <a href="http://roguestar.downstairspeople.org/gitweb?p=roguestar.git;a=blob;f=rsagl-frp/RSAGL/FRP/Message.hs;h=df9ecbab763858a16f4d9551ef26bf4771714174;hb=6f2ed2d99698229be98b94104ef1a1dbb04745b5">Message.hs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2010/07/17/memoized-dataflow-streams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ANN: Roguestar-0.4.0.1</title>
		<link>http://blog.downstairspeople.org/2010/06/17/ann-roguestar-0-4-0-1/</link>
		<comments>http://blog.downstairspeople.org/2010/06/17/ann-roguestar-0-4-0-1/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 02:32:08 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[RSAGL]]></category>
		<category><![CDATA[Roguestar]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=150</guid>
		<description><![CDATA[Roguestar is a science fiction roguelike game written using Haskell and OpenGL.  It is in the early stages of development.  At this time, it is not a winnable game. $ cabal install roguestar-engine $ cabal install roguestar-gl $ ~/.cabal/bin/roguestar - or - $ git clone http://www.downstairspeople.org/git/roguestar.git $ cd roguestar $ git checkout 0.4.0.1 $ make [...]]]></description>
			<content:encoded><![CDATA[<p>Roguestar is a science fiction roguelike game written using Haskell and OpenGL.  It is in the early stages of development.  At this time, it is not a winnable game.</p>
<pre>$ cabal install roguestar-engine
$ cabal install roguestar-gl
$ ~/.cabal/bin/roguestar</pre>
<p>- or -</p>
<pre>$ git clone http://www.downstairspeople.org/git/roguestar.git
$ cd roguestar
$ git checkout 0.4.0.1
$ make install</pre>
<p>New gameplay features:</p>
<ul>
<li>Melee combat, sundering and disarming attacks</li>
<li>Weapons can sometimes overheat or explode</li>
<li>Gateway teleportation between planets</li>
<li>Use material-spheres to craft new tools</li>
<li>Use material-spheres to heal</li>
<li>Tab-completion of typed commands</li>
<li>Compass directions to significant artifacts</li>
<li>&#8220;Jump&#8221; short distances by teleporting</li>
</ul>
<p>New objects:</p>
<ul>
<li>Chromalite material spheres</li>
<li>Metallic material spheres</li>
<li>Gaseous material spheres</li>
<li>Energy sabres and fleurets</li>
<li>Gateways</li>
<li>Monoliths</li>
</ul>
<p>New graphics features:</p>
<ul>
<li>Randomly generated sky spheres and landscapes</li>
<li>Unique fractal trees</li>
<li>Zoom-in/zoom-out</li>
</ul>
<p>Changes under the hood:</p>
<ul>
<li>Major re-write of the RSAGL FRP architecture</li>
<li>Multi-threaded 3D scene assembly and rendering</li>
<li>Multi-threaded, anticipatory engine</li>
<li>Various OpenGL performance improvements</li>
</ul>
<p>For more information, links to the manual and git repository, visit <a href="http://roguestar.downstairspeople.org">http://roguestar.downstairspeople.org</a>.</p>
<p>Check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2010/06/17/ann-roguestar-0-4-0-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Brutal Introduction to Arrows</title>
		<link>http://blog.downstairspeople.org/2010/06/14/a-brutal-introduction-to-arrows/</link>
		<comments>http://blog.downstairspeople.org/2010/06/14/a-brutal-introduction-to-arrows/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 05:52:29 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=141</guid>
		<description><![CDATA[Imagine being killed by a bow and arrow. That would suck, an arrow killed you? They would never solve the crime. &#34;Look at that dead guy. Let&#8217;s go that way.&#34; &#8212; Mitch Hedberg I seem to be one of the few people who absolutely adores arrows. I thought it might be helpful if I provided [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>Imagine being killed by a bow and arrow. That would suck, an arrow killed you? They would never solve the crime. &quot;Look at that dead guy. Let&#8217;s go that way.&quot;</em> &#8212; Mitch Hedberg</p>
</blockquote>
<p>I seem to be one of the few people who absolutely adores <a href="http://haskell.org/arrows/">arrows</a>. I thought it might be helpful if I provided some insight to the advanced-level newbies regarding the practical use of arrows in Haskell. Plenty has already been written about what arrows are in category theory, how to implement the Arrow typeclass, and how to use the special arrow syntax. I want to talk about why I occasionally wake up in the morning thinking, &quot;Maybe I could solve this problem using arrows!&quot;</p>
<p>This article is just to share an extremely simple, intuitive and concrete example of an arrow. I&#8217;m not going to get into all the crazy amazing things arrows can do. I just want to show that they can do at least one cool useful thing.</p>
<p>Arrows are closely related to monads. For example, both arrows and monads can be used to capture side-effecting operations.</p>
<p>Monads have the kind <code>* -&gt; *</code>, indicating a side-effecting operation with a single output type, and a binding operation <code>m a -&gt; (a -&gt; m b) -&gt; m b</code>. The input to a monadic operation is provided via a pure function. Arrows, on the other hand, have a kind <code>* -&gt; * -&gt; *</code>, indicating a side-effecting operation with a single input type and a single output type, and a binding operation <code>a b c -&gt; a c d -&gt; a b d</code>.</p>
<p>When binding monads, it&#8217;s obvious from the type signature that the subsequent side-effecting operation does not even exist until after the output of the previous operation becomes available. It cannot, because it depends on the previous output and because we can inject any pure function to construct the subsequent operation based on completely arbitrary criteria.</p>
<p>When binding arrows, the subsequent side-effecting operation exists before execution begins.</p>
<p>All monads are arrows, but not all arrows are monads, and this observation is pertinent to their implementation in Haskell, but I&#8217;m going to restrict this article&#8217;s discussion to &quot;interesting arrows,&quot; specifically, arrows that aren&#8217;t monads because they don&#8217;t implement <code>ArrowApply</code>. Interesting arrows are basically monads without flow control: you can&#8217;t generally choose what side-effecting actions to perform based on things you learn during the execution of the arrow.</p>
<p>This is why arrow-notation creates two scopes. Between the <code>&lt;- -&lt;</code> symbols, only values that were in scope before execution of the Arrow are in scope. Outside the <code>&lt;- -&lt;</code>, values that appear during the execution of the Arrow are also in scope.</p>
<p>For example, we (you and I) might have a monad that allows us to perform certain dangerous operations, like overwriting files. In a monadic context, we can not anticipate what any particular instance of the monad will choose to do. We might write a very complicated installation script that accesses many files. Do we have permission to write to all of those files? Do the files we want to read even exist? Do we access an infinite number of files?</p>
<p>Do we ever write to <code>/dev/nuclear_missiles</code>?</p>
<p>We would like to know the answers to these questions before running the installation script, otherwise we could be interrupted and leave the system in a chaotic state. Even if we could recover from an error, we would still be wasting the user&#8217;s time, which is the opposite of the thing that computers are for.</p>
<p>But if we implemented our IO environment using an arrow, we could anticipate all of the side-effecting operations, even have a list of files to be overwritten before the operation begins.</p>
<p>In our new file IO arrow, it will be impossible to read the name of a file from a file, and then write to that file dynamically, because all file names must be specified at the time the arrow is bound. That&#8217;s a pretty onerous restriction, but we can always add new operations later, if we need them.</p>
<p>Our arrow needs a list of accessed files and an IO action. The list of file paths is going to take the form of a monoid, while the sequence of IO actions will take the form of a Kleisli arrow.</p>
<blockquote><p><code>data IORWA a b = IORWA [FilePath] (a -&gt; IO b)</code></p>
</blockquote>
<p>We need a category instance.</p>
<blockquote><p><code>instance Category IORWA where</code></p>
</blockquote>
<p>Implementing <code>id</code> is easy. <code>Id</code> accesses no files, so we give an empty file list. <code>Return</code> is the simplest monadic action that type checks.</p>
<blockquote><p><code>id = IORWA [] return</code></p>
</blockquote>
<p>The bind operation requires that we concatenate two lists of file paths, and bind the IO actions. (This is a little annoying, but note that the <code>(.)</code> operator specifies the preceding action second and the subsequent action first.)</p>
<blockquote><p><code>(IORWA sa actionA) . (IORWA sb actionB) = IORWA (sa ++ sb) (\x -&gt; actionB x &gt;&gt;= actionA)</code></p>
</blockquote>
<p>At this point, we only have a category, which has only slightly more sophistication than a monoid. To get our tricky arrow syntax, we need to implement <code>arr</code> and <code>first</code>.</p>
<blockquote><p><code>instance Arrow IORWA where</code></p>
</blockquote>
<p><code>Arr</code>, like <code>id</code>, doesn&#8217;t touch any files, so we provide an empty file list and inject the function into the arrow.</p>
<blockquote><p><code>arr f = IORWA [] $ return . f</code></p>
</blockquote>
<p><code>First</code> is a little tricky. We&#8217;re accepting a side-effecting operation as a parameter, so we need to preserve that operation&#8217;s file list.</p>
<blockquote><p><code>first (IORWA s action) = IORWA s $ \(x,k) -&gt; do { x' &lt;- action x; return (x',k) }</code></p>
</blockquote>
<p>And we need read/write operations, in which we simply pack the file path parameter into the file list. Notice that we take the file path as a static parameter, but we take the data to write as an input to the arrow.</p>
<blockquote><p><code>writeFileA :: FilePath -&gt; IORWA String ()</code></p>
<p><code>writeFileA path = IORWA [path] $ \s -&gt; writeFile path s</code></p>
<p><code>readFileA :: FilePath -&gt; IORWA () String</code></p>
<p><code>readFileA path = IORWA [path] $ \_ -&gt; readFile path</code></p>
</blockquote>
<p>Using our arrow is as simple as exporting a function to the accessed file list and the IO action, as long as we refuse to export any way to corrupt the synchronization between the two fields.</p>
<p>Looking at <a href="http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Arrow.html">Control.Arrow</a> and the <a href="http://hackage.haskell.org/package/arrows">arrows library on hackage</a>, there are a few things we could add to all this:</p>
<ul>
<li>We could implement <code>ArrowChoice</code>. This would allow us to choose at runtime between accessing two different sets of files. Both possibilities would appear in our static accessible file list, but only one would actually be accessed.</li>
<li>We could use a modified <code>ReaderArrow</code> to capture rewriting rules for file paths, e.g., to specify a current working directory. We can&#8217;t use <code>ReaderArrow</code> directly, because it would route information through the monadic component of the computation.</li>
<li>We could use a <code>WriterArrow</code> to retain a log of all of the data we actually write.</li>
<li>We could use an <code>ErrorArrow</code> to recover from file system errors.</li>
<li>We could implement <code>ArrowLoop</code> based on the <code>MonadFix</code> instance of IO.</li>
<li>We could use the <code>Automaton</code> arrow to implement multi-phase read/write cycles. Perhaps the first phase would be read-only, then we could check the file list again before proceeding to the second phase.</li>
<li>We could re-implement what we just wrote in terms of the <code>StaticArrow</code> and <code>Kleisli</code> arrows, and get a metric ton of the above for free.</li>
</ul>
<p>To play with this example, you could always <code>git clone http://www.downstairspeople.org/git/IORWA.git</code>.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2010/06/14/a-brutal-introduction-to-arrows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Composable Blocking Transactions</title>
		<link>http://blog.downstairspeople.org/2010/06/06/composable-blocking-transactions/</link>
		<comments>http://blog.downstairspeople.org/2010/06/06/composable-blocking-transactions/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 08:07:19 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=133</guid>
		<description><![CDATA[Background: Software Transactional Memory (STM) is a foundation for atomic composable non-blocking transactions. An STM transaction consists of a set of variables and a monadic sequence of read/write operations on those variables. As the transaction progresses, a transaction table is constructed detailing the specific variables to be modified. At the end of the transaction, either [...]]]></description>
			<content:encoded><![CDATA[<p>Background: Software Transactional Memory (STM) is a foundation for atomic composable non-blocking transactions. An STM transaction consists of a set of variables and a monadic sequence of read/write operations on those variables. As the transaction progresses, a <em>transaction table</em> is constructed detailing the specific variables to be modified. At the end of the transaction, either the changes are written atomically (that is, none of the intermediate modifications are visible to the outside world), or the transaction is aborted as though nothing had happened.</p>
<p><a href="http://roguestar.downstairspeople.org/gitweb?p=blocking-transactions.git;a=summary">Blocking-transactions</a> is an alternative library that implements atomic transactions using locks. This library is strictly less expressive than STM, but does have some advantages.</p>
<p>First, I will demonstrate why such a library is even possible. In order to implement a blocking transaction, we must:</p>
<ol>
<li>Sort all of the variables that could participate in the transaction.</li>
<li>Sieze a lock on each variable in sorted order.</li>
<li>Perform the transaction.</li>
<li>Release all of the locks.</li>
<li>Notify any waiting threads that the variables have been modified.</li>
</ol>
<p>Acquiring locks in sorted order guarantees that the program can not deadlock. Acquiring a lock effectively acquires the exclusive right to acquire any greater-ordered locks before any thread that has acquired a lesser-ordered lock.</p>
<p>None of this is possible unless we know the entire set of variables before the transaction takes place. In traditional models of computation, this is impossible. However, arrows provide an environment of restricted flow control in which all computations are either inevitable or in which there is a finite set of branches. The <a href="http://hackage.haskell.org/packages/archive/arrows/0.4.2.0/doc/html/Control-Arrow-Transformer-Static.html">StaticArrow</a> is an example of an Arrow that can do this.</p>
<p>It is also possible to build a monad with similarly restricted flow control. If the side-effectful operations of a monad always return an opaque value (meaning that there is no function that can transform the value or any combination of values into a boolean) then no flow control within the monad is possible.</p>
<p>Such a library has a profound limitation: although we can store a transactional variable inside another transactional variable, we can not retrieve it without considerable contortions. Blocking transactions therefore do not seem to be suitable for working with complex graphs of transactional variables.</p>
<p>On the other hand, the restricted flow control that blocking transactions require presents an unexpected opportunity: transactions can be made inevitably lazy. A lazy transaction completes in the time it takes to entangle the variables in a system of unevaluated thunks. This means that the locks are held for the shortest time possible, but increases the CPU time needed to complete the entire program.</p>
<p>These systems of unevaluated thunks constitute a potentially hazardous memory leak. I choose to write the library in such a way that each variable is forced after the transaction completes, by means of a parallel spark.</p>
<p>This is not the only strategy for evaluating a transaction. We could also choose to:</p>
<ul>
<li>Allow values to be forced within the transaction, but locks could be held while an expensive and unimportant computation completes. We would then want a strategy to release unneeded locks early, but this would add overhead.</li>
<li>Sequentially force each variable after the transaction, but this was not efficient in the benchmark.</li>
<li>Specify a per-variable strategy for forcing each variable, but this is adds complexity with little apparent benefit.</li>
<li>Tolerate the memory leak on the assumption that the caller must manually force the contents of the transaction, but this had catastrophic implications for performance in the benchmark.</li>
</ul>
<p>Note that the blocking transactions library at the moment is not exception safe.</p>
<p>My implementation is available as a <a href="http://www.downstairspeople.org/git/blocking-transactions.git/">git repository</a>. You can also link directly to the <a href="http://roguestar.downstairspeople.org/gitweb?p=blocking-transactions.git;a=blob;f=BlockingTransactions/BlockingTransactions.hs;h=b4d0512be20efbb605a6054a1d2c7ba99dcc8770;hb=ece101e8fd2b2d25026bc33d63467aac6bee0395">source code</a> and a <a href="http://roguestar.downstairspeople.org/gitweb?p=blocking-transactions.git;a=blob;f=Examples/RandomAccounts.hs;h=db1893e0eb01b77d5c1d9def1e6e9aa669ad2a95;hb=ece101e8fd2b2d25026bc33d63467aac6bee0395">simple benchmark</a>.</p>
<p><code>$ git clone http://www.downstairspeople.org/git/blocking-transactions.git/</code></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2010/06/06/composable-blocking-transactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paintable User Interfaces</title>
		<link>http://blog.downstairspeople.org/2009/11/30/paintable-user-interfaces/</link>
		<comments>http://blog.downstairspeople.org/2009/11/30/paintable-user-interfaces/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 18:32:54 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=106</guid>
		<description><![CDATA[It seems like it should be possible to have some kind of GUI library in which user interface elements can be painted onto the screen frame-by-frame, instead of the common practice of assembling an object-oriented hierarchy of widgets. I&#8217;m thinking of something like (rough ECMA-like pseudocode): static var clicks = 0; drawRectangle( 0, 0, 100, [...]]]></description>
			<content:encoded><![CDATA[<p>It seems like it should be possible to have some kind of GUI library in which user interface elements can be painted onto the screen frame-by-frame, instead of the common practice of assembling an object-oriented hierarchy of widgets.</p>
<p>I&#8217;m thinking of something like (rough ECMA-like pseudocode): </p>
<p><tt><br />
static var clicks = 0;</p>
<p>drawRectangle( 0, 0, 100, 100)<br />
drawText( 0, 50, "This button has been clicked " + clicks + " times" )<br />
drawClickListener( 0, 0, 100, 100, function() { clicks++ } )<br />
</tt></p>
<p>Now we should be able to wrap this &#8220;button&#8221; inside affine transformations and clipping operations.  We would call and draw the button during each frame of animation, and the button would cease to exist on the first frame in which it stopped being called.</p>
<p>I&#8217;m not looking for a revolutionary GUI paradigm; I just want the ability to do some specific, weird effects when the situation calls for it.  For example, a car driving by with a clickable button on it&#8217;s side.  If the button is behind a tree in the same scene, then it shouldn&#8217;t be click-able.</p>
<p>In fact, ideally, drawing user interface elements would use the same path as drawing visible shapes, but would pass in an event handler instead of a color or fill pattern.  I could even imagine that there would be one or more channels of callback information alongside the RGB channels.</p>
<p>This is in the category of &#8220;things that I can&#8217;t possibly be the first person to think of but haven&#8217;t actually ever seen done.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2009/11/30/paintable-user-interfaces/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New Roguestar Screenshot: Gateway</title>
		<link>http://blog.downstairspeople.org/2009/09/26/new-roguestar-screenshot-gateway/</link>
		<comments>http://blog.downstairspeople.org/2009/09/26/new-roguestar-screenshot-gateway/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 02:20:53 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Roguestar]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=96</guid>
		<description><![CDATA[When you are done on a planet, step through a gateway to move to the next one.]]></description>
			<content:encoded><![CDATA[<div id="attachment_97" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.downstairspeople.org/wp-content/uploads/2009/09/roguestar-screenshot.jpg"><img src="http://blog.downstairspeople.org/wp-content/uploads/2009/09/roguestar-screenshot-300x173.jpg" alt="An Androsynth standing in front of a stargate." title="roguestar-screenshot" width="300" height="173" class="size-medium wp-image-97" /></a><p class="wp-caption-text">An Androsynth standing in front of a stargate.</p></div>
<p>When you are done on a planet, step through a gateway to move to the next one.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2009/09/26/new-roguestar-screenshot-gateway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FactoryArrow</title>
		<link>http://blog.downstairspeople.org/2009/08/09/factoryarrow/</link>
		<comments>http://blog.downstairspeople.org/2009/08/09/factoryarrow/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 19:21:29 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[RSAGL]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=87</guid>
		<description><![CDATA[I&#8217;ve been playing around with an Arrow concept, which to my knowledge is original. I&#8217;ve decided to call this a FactoryArrow: newtype FactoryArrow m n a b = FactoryArrow { runFactory :: m (Kleisli n a b) } Where m and n are Monads. m is a single-pass initialization monad, while n is a multiple-pass [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with an Arrow concept, which <em>to my knowledge</em> is original.  I&#8217;ve decided to call this a FactoryArrow:</p>
<p><code><br />
newtype FactoryArrow m n a b = FactoryArrow { runFactory :: m (Kleisli n a b) }<br />
</code></p>
<p>Where <tt>m</tt> and <tt>n</tt> are Monads.  <tt>m</tt> is a single-pass initialization monad, while <tt>n</tt> is a multiple-pass working monad.  The arrow supports all of the standard accessory arrow typeclasses, including <tt>ArrowLoop</tt> if <tt>n</tt> implements <tt>MonadFix</tt>, and <tt>ArrowApply</tt> if <tt>m</tt> and <tt>n</tt> are the same.</p>
<p>This arrow simply captures a two-phase initialize-and-run design pattern.</p>
<p>To the best of my imagination, there cannot be a corresponding useful FactoryMonad.  I would be extremely interested if anyone can contradict me on that point.</p>
<p>My current interest is in using the FactoryArrow as a replacement for the mealy-style arrows by using IORefs (or potentially even STM transaction variables) to store automaton states instead of unevaluated thunks.</p>
<p>The <a href="http://roguestar.downstairspeople.org/gitweb?p=rsagl.git;a=blob;f=RSAGL/FRP2/FactoryArrow.hs;h=1b6b74732da7ef803819602a892adf3bfb5551e0;hb=d3a506aca2bd244596f6b8879ca16bc4bda44c49">corresponding implementation</a> as of the time of this writing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2009/08/09/factoryarrow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vec is Good</title>
		<link>http://blog.downstairspeople.org/2009/05/05/vec-is-good/</link>
		<comments>http://blog.downstairspeople.org/2009/05/05/vec-is-good/#comments</comments>
		<pubDate>Tue, 05 May 2009 19:45:47 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[RSAGL]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=84</guid>
		<description><![CDATA[Last night I checked out Scott E. Dillard&#8217;s Vec library. It&#8217;s a good, fast, pure implementation of the basic matrix operations applicable to 3D graphics. Switching to Vec has shaved off quite a bit of time from one of my demo apps and relieved me of the need to maintain my own matrix manipulation code, [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I checked out Scott E. Dillard&#8217;s <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Vec-0.9.6">Vec</a> library.  It&#8217;s a good, fast, pure implementation of the basic matrix operations applicable to 3D graphics.  Switching to Vec has shaved off quite a bit of time from one of my demo apps and relieved me of the need to maintain my own matrix manipulation code, which was causing me repeated headaches.</p>
<p>It&#8217;s very heavy with MPTCs, fundeps, and type families, which will cause ghc to render some pretty inane error messages, but if you&#8217;re already accustomed to this then it&#8217;s actually very straightforward to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2009/05/05/vec-is-good/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ANN: priority-sync</title>
		<link>http://blog.downstairspeople.org/2009/04/29/ann-priority-sync/</link>
		<comments>http://blog.downstairspeople.org/2009/04/29/ann-priority-sync/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 21:28:53 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=81</guid>
		<description><![CDATA[Provides cooperative task prioritization. The priority-sync package on hackage.haskell.org. $ cabal install priority-sync $ git clone http://www.downstairspeople.org/git/priority-sync.git Feedback will be greatly appreciated. This package is a spin-off from my work on roguestar, where I need to do significant background processing while retaining enough resources to perform smooth animation.]]></description>
			<content:encoded><![CDATA[<p>Provides cooperative task prioritization.</p>
<p>The <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/priority-sync">priority-sync</a> package on hackage.haskell.org.</p>
<p>$ cabal install priority-sync</p>
<p>$ git clone http://www.downstairspeople.org/git/priority-sync.git</p>
<p>Feedback will be greatly appreciated.  This package is a spin-off from my work on roguestar, where I need to do significant background processing while retaining enough resources to perform smooth animation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2009/04/29/ann-priority-sync/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trends in Profiling Haskell</title>
		<link>http://blog.downstairspeople.org/2009/04/16/trends-in-profiling-haskell/</link>
		<comments>http://blog.downstairspeople.org/2009/04/16/trends-in-profiling-haskell/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 23:22:27 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=68</guid>
		<description><![CDATA[I spent some time yesterday profiling roguestar. I do this every few months just to see where things stand, and there are always two culprits at the top of roguestar-gl.prof, every single time: * typeclass dictionary lookups in inner loops * Rational In the first case, I think the simplest solution is to INLINE the [...]]]></description>
			<content:encoded><![CDATA[<p>I spent some time yesterday profiling roguestar.  I do this every few months just to see where things stand, and there are always two culprits at the top of roguestar-gl.prof, every single time:</p>
<p>* typeclass dictionary lookups in inner loops<br />
* Rational</p>
<p>In the first case, I think the simplest solution is to INLINE the puppy.  Can the ghc inliner be a little bit more aggressive when it sees dictionary lookups?  Inliners are tricky business.  I&#8217;m not sure I see a simple heuristic.  Vaguely: leaf functions that require dictionary lookups need to be specialized.</p>
<p>Rational can sneak into an unsuspecting program through <tt>realToFrac</tt>, and absolutely *kills* performance.</p>
<p>I sit down thinking to myself, &#8220;Ok, today I&#8217;m going to streamline my Super Mumbo Jumbo Widget and get 15% faster performance,&#8221; or some such goal I set for myself.  And I run the profiler and 75% of my time is being spent in <tt>fromRational . toRational</tt>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.downstairspeople.org/2009/04/16/trends-in-profiling-haskell/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
