<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8072464059979174136</id><updated>2011-12-26T20:49:41.941-08:00</updated><category term='good'/><category term='iso'/><category term='garden'/><category term='Budapest'/><category term='pondering'/><category term='waymarking'/><category term='termination'/><category term='crazy'/><category term='Apple'/><category term='syntax extension'/><category term='evolution'/><category term='ghc'/><category term='types'/><category term='speculation'/><category term='hackage'/><category term='GADT'/><category term='clang'/><category term='category theory'/><category term='PostScript'/><category term='dylan'/><category term='haskell'/><category term='family'/><category term='llvm'/><category term='omega'/><category term='lout'/><category term='OpenCL'/><category term='work'/><category term='contest'/><category term='weather'/><category term='leipzig'/><category term='inertia'/><category term='generalization'/><category term='emacs'/><category term='research'/><category term='personal'/><category term='logic'/><category term='PDF'/><category term='vacation'/><category term='bsd'/><category term='ICFP'/><category term='language'/><category term='monads'/><category term='cabal'/><category term='quickcheck'/><category term='algorithm'/><category term='gravity'/><category term='philosophy'/><category term='hoare-triple'/><category term='filesystem'/><category term='jobs'/><category term='applicative'/><category term='mac'/><category term='thrist'/><category term='optimization'/><category term='dependent types'/><category term='house'/><category term='shiraz'/><category term='sadness'/><title type='text'>don't count on finding me</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>80</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6956296696677631568</id><published>2011-12-26T17:11:00.000-08:00</published><updated>2011-12-26T17:11:57.062-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='ghc'/><title type='text'>Showing Thrists Revisited</title><content type='html'>More than three years ago I &lt;a href="http://heisenbug.blogspot.com/2008/08/id-like-to-see-but-do-you-want-to-show.html"&gt;lamented&lt;/a&gt; that it's impossible to to define a &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;show&lt;/span&gt;&lt;/span&gt; function on thrists, generally, even when the element type is member of the &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Show&lt;/span&gt;&lt;/span&gt; class.&lt;br /&gt;&lt;br /&gt;In the meantime I succeeded to declare &lt;a href="http://svn.berlios.de/svnroot/repos/al4nin/trunk/purgatory/Appli.hs?p=1129"&gt;certain thrist parametrizations&lt;/a&gt; and convince GHC to accept show instances for them. The &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Appli&lt;/span&gt;&lt;/span&gt; thrist is such an example.&lt;br /&gt;&lt;br /&gt;With the &lt;a href="http://www.haskell.org/pipermail/glasgow-haskell-users/2011-December/021310.html"&gt;upcoming GHC 7.4&lt;/a&gt; things may improve considerably, as it will bring &lt;i&gt;constraint kinds&lt;/i&gt;. Remember, thrists are (currently) parameterized like this &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(* → * → *) → * → * → *&lt;/span&gt;&lt;/span&gt;, i.e. on &lt;i&gt;types&lt;/i&gt;, and with the new &lt;i&gt;kind variable&lt;/i&gt; feature we can probably generalize to &lt;i&gt;user-defined kinds&lt;/i&gt;. Then the parameters may match Ωmega's: &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(a → a → *) → a → a → *&lt;/span&gt;&lt;/span&gt;. So we still result in a type, but we can choose our indices from a vastly bigger domain. Enter constraint kinds! These may be part of our user-defined kinds, so we can form stuff like &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(Show, *)&lt;/span&gt;&lt;/span&gt; and supply it for the parameter &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;a&lt;/span&gt;&lt;/span&gt;. With some luck deriving &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Show&lt;/span&gt;&lt;/span&gt; can be more successful and not attached to particular parametrizations.&lt;br /&gt;&lt;br /&gt;I regrettably still haven't gotten around building a GHC v7.4.1 candidate, so I cannot verify the above, but my gut feeling is that this'll work out...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6956296696677631568?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6956296696677631568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6956296696677631568' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6956296696677631568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6956296696677631568'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2011/12/showing-thrists-revisited.html' title='Showing Thrists Revisited'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-2987404362787476177</id><published>2011-11-22T15:03:00.000-08:00</published><updated>2011-11-22T15:03:38.059-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Pondering about the Foundations</title><content type='html'>As I am thinking about how a possible Ω&lt;i&gt;mega 2.0&lt;/i&gt; could be implemented, I am trying to come up with some interesting concepts w.r.t. parsing and type checking. Since no single line is written yet, it is easy and cheap to ponder.&lt;br /&gt;&lt;br /&gt;Some key elements are already taking shape in my mind. These are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;parsed entities carry their start and end coordinates in their types&lt;/li&gt;&lt;li&gt;there is no difference between patterns and expressions&lt;/li&gt;&lt;li&gt;each expression carries a typing thrist.&lt;/li&gt;&lt;/ul&gt;The second item has been elaborated by me in an earlier post. The third must wait a bit until I have something coherent (but the curious reader might visit my &lt;a href="http://code.google.com/p/omega/wiki/HomologyTypes"&gt;sketch of ideas&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;I'd like to talk about item one here. The essence is that every grammar element obtains a type that describes where this element is located. For example a function declaration may occupy the text portion between &lt;i&gt;start&lt;/i&gt; and &lt;i&gt;end&lt;/i&gt;, where these are type-level triples (file, line, column). In order to consider parsed input&amp;nbsp;consistent, the start coordinates must be aligned with the prior element's end coordinates, i.e. we have another thrist here.&lt;br /&gt;&lt;br /&gt;Things get interesting when we model naming and scope. Name definition and referral must somehow match the types, after the match is done the semantics can be read off the user. To give an example:&lt;br /&gt;&lt;blockquote class="tr_bq"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Ref definer :: Exp (`foo, 42, 7) (`foo, 42, 11)&lt;br /&gt;&amp;nbsp;&amp;nbsp;where&amp;nbsp;definer :: Exp&amp;nbsp;(`foo, 41, 1) (`foo, 45, 37)&amp;nbsp;= ...&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;Both the reference and the definition live in the same file "foo.prg". The former is on line 42 from column 7 to 11 (exclusive). The definition it refers to is in fact enclosing it (a recursive call, maybe?) extending from line 42 to 45. With this representation the name of the indentifier becomes secondary, all that counts is the evidence in &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;definer&lt;/span&gt;&lt;/span&gt; which contributes to its type! We have created a &lt;i&gt;globally nameless&lt;/i&gt; representation.&lt;br /&gt;&lt;br /&gt;We can expand this world view to also include the level of the grammatical entity (value, type, kind, etc.) as a fourth coordinate. So a reference to a ›25‹ somewhere in the text at floor 0 would point to an integer literal, the same place at floor 1 to the type &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Int&lt;/span&gt;&lt;/span&gt; and at floor 2 it would be the kind &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;*&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;My hope is that all the proof obligations arising in such a scheme can be cleverly extracted from a parsec-like engine.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-2987404362787476177?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/2987404362787476177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=2987404362787476177' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2987404362787476177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2987404362787476177'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2011/11/pondering-about-foundations.html' title='Pondering about the Foundations'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-285097843367482020</id><published>2011-10-05T21:39:00.000-07:00</published><updated>2011-10-06T06:07:22.856-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sadness'/><category scheme='http://www.blogger.com/atom/ns#' term='family'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><title type='text'>Macs and me</title><content type='html'>I am profoundly saddened since I woke up at 4:00am in the morning, and saw the news headline about the passing of Steve Jobs. I have seen this coming for a long time, as my father died in a very similar way back 1993 with only 52. Looking at the thin appearance of Jobs in the last month or even years I constantly get reminded of him. Basically the same story of suffering, loss of weight, liver transplant (in vain), death. RIP, Dad, RIP, Steve.&lt;br /&gt;&lt;br /&gt;I am writing this on a rusty vintage 2000 PowerBook G4 Titanium, I bought on eBay last year, because the video of my own 2001 TiBook went black. By today's web standards completely inadequate, it serves me well for news reading, terminal logins, etc. My son Pedro got his MacBook Pro 15'' delivered just today. An awesome piece of technology.&lt;br /&gt;&lt;br /&gt;My father bought the first Mac in 1986, just after opening his practice as a neurologist. This was two years after cutting all strings in Hungary and fleeing to Germany in a pretty bold move. Must have been a moment of total self-overestimation when I promised to my dad "if you buy that Mac Plus I'll write you the best software for it for your doctor's office". A crazy time began. At day the Mac was used to keep patient's data with a DTP program "RagTime", at 5pm I hauled the Mac home (in a big black bag) and started writing the program. Sometimes deep into the night. I used Turbo Pascal (and later MPW) after figuring out that the Lisp environment I preferred simply did not cut it due to insufficient support of the Toolbox. In the morning my father carried the Mac back and powered it up.&lt;br /&gt;&lt;br /&gt;Less than year later the program was ready for productive work. A Mac SE joined the party and we had a networked doctor's application with a really neat windowed user interface, that would put even today's programs to shame in this regard.&lt;br /&gt;&lt;br /&gt;There was even a time when we fancied marketing this product, but my university duties and the early death of my father simply negated all plans to this end.&lt;br /&gt;&lt;br /&gt;When I had my diploma in my hands I picked up the phone and called the guy who sold us the Mac Plus and a copy of "Inside Macintosh" back in '86. In the meantime he founded a pretty successful company around a networked admin solution called 'netOctopus' which was his baby. We occasionally met at Apple developer events and I new that he was a pretty damn good coder. He hired me and I was earning money by programming Macs!&lt;br /&gt;&lt;br /&gt;So yes, I love Macs and there is no reason that this will change in the foreseeable future.&lt;br /&gt;&lt;br /&gt;I kept telling to myself, should Jobs die one day, I'll put that Mac Plus (now in my basement and still functional) up for sale at eBay. My thought today: "screw it – too many fond memories attached".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-285097843367482020?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/285097843367482020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=285097843367482020' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/285097843367482020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/285097843367482020'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2011/10/macs-and-me.html' title='Macs and me'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-41809207004280589</id><published>2011-09-09T12:02:00.000-07:00</published><updated>2011-09-09T12:29:40.901-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='ghc'/><title type='text'>GHC 7.0.4 on CentOS</title><content type='html'>This is mainly a post for myself so that I can look back any time how I did it.&lt;br /&gt;&lt;br /&gt;Basically I fell in every possible hole while wandering around in the dark but I could get out of them :-)&lt;br /&gt;&lt;ul&gt;&lt;li&gt;after downloading I configured the binary installation for x86-64. &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;configure&lt;/span&gt;&lt;/span&gt; starts &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ghc-pwd&lt;/span&gt;&lt;/span&gt;, which is built with the wrong &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;glibc&lt;/span&gt;&lt;/span&gt;-versions. Bummer.&lt;/li&gt;&lt;li&gt;found out that I have to get the source install. Downloaded and configured, it died in the middle because &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;base-4.2&lt;/span&gt;&lt;/span&gt; was not available. Bummer.&lt;/li&gt;&lt;li&gt;so I had to install &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ghc-6.12.3&lt;/span&gt;&lt;/span&gt; first. Fortunately this went smoothly (binary install). With this new friend I reconfigured v7.0.4 and started building. When linking the stage1 compiler I got an error from binutils that some relocation went awry. Bummer.&lt;/li&gt;&lt;li&gt;the internets are full of hints that the system compiler (&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;gcc-4.1&lt;/span&gt;&lt;/span&gt;) uses the bad linker. To my luck I found a new gcc-4.4 in an amicable colleague's home directory, so I reconfigured thus:&lt;blockquote&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;./configure --prefix=/home/gabor --with-gcc=/home/msichel/local_x86/bin/gcc&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;but configure told me that the shiny new &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;gcc&lt;/span&gt;&lt;/span&gt; cannot build executables. Bummer.&lt;/li&gt;&lt;li&gt;it turned out (I had to write a &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hello-world&lt;/span&gt;&lt;/span&gt; to figure that out) that some &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;gcc&lt;/span&gt;&lt;/span&gt;-internal shared libraries were not found. Luckily they came into scope with &lt;blockquote&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;LD_LIBRARY_PATH=/home/msichel/local_x86/lib:/opt/lsf/6.2/linux2.6-glibc2.3-x86_64/lib&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;at this point I could smell victory, but it was still out of reach. A &lt;a href="http://klevstul.posterous.com/haskell-ghc-702-on-centos-55"&gt;blog post&lt;/a&gt; suggested to &lt;span style="color: purple; font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cp mk/build.mk.sample mk/build.mk&lt;/span&gt;&lt;/span&gt; and edit it in two ways:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;uncomment &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;BuildFlavour = quick&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;and change to &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;GhcLibWays = v p dyn&lt;/span&gt;&lt;/span&gt;, i.e. append "&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;p dyn&lt;/span&gt;&lt;/span&gt;"&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;I did both, reconfigured and typed &lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;make install&lt;/span&gt;&lt;/span&gt;.&lt;/li&gt;&lt;/ul&gt;It went through without a hitch :-)&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-41809207004280589?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/41809207004280589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=41809207004280589' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/41809207004280589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/41809207004280589'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2011/09/ghc-704-on-centos.html' title='GHC 7.0.4 on CentOS'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-81230911897817518</id><published>2011-08-21T22:58:00.000-07:00</published><updated>2011-08-21T22:58:05.937-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Poor Man's Haskell Kinds</title><content type='html'>After finalizing some of my idea prototypes in &lt;a href="http://omega.googlecode.com/"&gt;Ωmega&lt;/a&gt;, I intend to port a part of the code to Haskell, to enjoy the speed advantages of a compiled language.&lt;br /&gt;&lt;br /&gt;Unfortunately Haskell does not support &lt;i&gt;user-defined kinds&lt;/i&gt;, so I was wondering how to simulate them at least, in order to get some confidence that my type-level constructs do not drift into no-no-land.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://svn.berlios.de/svnroot/repos/al4nin/trunk/purgatory/PoorKinds.lhs"&gt;This literate haskell file&lt;/a&gt; demonstrates how I put &lt;i&gt;instance constraints&lt;/i&gt; to work, and thereby define the inference rules for well-kinded phantom type indexes. I am sure somebody has already done this, I would like to hear about it. Anyway, this almost allows me to introduce Ωmega's checked singleton types in Haskell.&lt;br /&gt;&lt;br /&gt;Sadly GHC does not yet allow instance definitions for type families, but it would be cool if somebody could provide me a workaround.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-81230911897817518?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/81230911897817518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=81230911897817518' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/81230911897817518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/81230911897817518'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2011/08/poor-mans-haskell-kinds.html' title='Poor Man&apos;s Haskell Kinds'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6848647235943395135</id><published>2011-02-10T18:45:00.000-08:00</published><updated>2011-02-10T18:45:50.298-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pondering'/><category scheme='http://www.blogger.com/atom/ns#' term='inertia'/><category scheme='http://www.blogger.com/atom/ns#' term='gravity'/><title type='text'>My Thoughts about Inertia</title><content type='html'>Big caveat: I am very much of a layman when it comes to physics and this is consequence of having heard elementary physics lectures more than 15 years ago.&lt;br /&gt;&lt;br /&gt;But I like the occasional book on the subject (&lt;a href="http://en.wikipedia.org/wiki/The_Elegant_Universe"&gt;The Elegant Universe&lt;/a&gt; comes to my mind) and am fascinated by the theoretical possibility of a grand unified theory of Nature's forces.&lt;br /&gt;&lt;br /&gt;There is a small niggling idea in my head that wants to get out from time to time, and this post is the evidence that it finally made it into the wild. (I will probably appear as a bloody idiot because of this...)&lt;br /&gt;&lt;br /&gt;Being Hungarian-born has made me somewhat receptive for advances in physics performed by the pretty smart folks coming from this small country, and already as a pupil I was taught that the "&lt;a href="http://en.wikipedia.org/wiki/Equivalence_principle"&gt;equivalence principle&lt;/a&gt;" (of gravitational mass and inertial mass coinciding to an amazing degree) was shown by &lt;a href="http://en.wikipedia.org/wiki/Lor%C3%A1nd_E%C3%B6tv%C3%B6s"&gt;Eötvös&lt;/a&gt;. This cannot be a simple coincidence but must be a fundamental thing.&lt;br /&gt;&lt;br /&gt;A completely ununderstood fundamental thing, as it appears to me. A quick googling for "inertia quantum gravity" brings up some outright lunatics and some rather exotic theory of "zero field fluctuations" causing inertia:&lt;br /&gt;&lt;br /&gt;http://www.calphysics.org/articles/PRA94.pdf&lt;br /&gt;http://www.calphysics.org/articles/gravity_arxiv.pdf&lt;br /&gt;&lt;br /&gt;But, electromagnetism causing the same mass as gravity (i.e. linking two of the fundamental forces with an unbelievable precision) appears very far-fetched to me.&lt;br /&gt;&lt;br /&gt;Wikipedia seems to be no help when inquiring for the &lt;a href="http://en.wikipedia.org/wiki/Inertia#Source_of_Inertia"&gt;source of inertia&lt;/a&gt;. &lt;a href="http://en.wikipedia.org/wiki/Mach%27s_principle"&gt;Mach's principle&lt;/a&gt;&amp;nbsp;referenced therein, namely that the existence of the rest of the universe leads to the phenomenon of inertia does not sound right; after all, when all the other stars (galaxies etc.) would be removed &lt;i&gt;but the Sun&lt;/i&gt;, would you expect that the inertia of your body suddenly would fall to almost zero?&lt;br /&gt;&lt;br /&gt;I cannot believe that modern theories of gravity (such as quantum gravity approaches) do not try to explain the equivalence of gravitational mass and inertial mass. My intuition says that this should be the first step!&lt;br /&gt;&lt;br /&gt;Now I'll begin a steep descent in the land of speculation and respectlessly mix stuff told by others with vague ideas and metaphors of mine. I won't even make effort to cite or link, but at some point I'll tell what my main idea is. Be warned: at that point probably each self-respecting physicist (that is, a person who successfully solved a differential equation about movement of a body under external force) will turn away with disgust, but okay, let it be...&lt;br /&gt;&lt;br /&gt;There is this idea that gravity is so weak in comparison to electromagnetism, because the circular (closed) &amp;nbsp;strings corresponding to the graviton do not permanently bind to our three dimensional space (or four-dimensional spacetime). They are just passing through, and there is little time for them to establish the force between bodies. So, the gravitational force exerted between two glasses of red wine is very small on each other. But when they are accelerated (say, by clinking them) perceptible forces appear. So I conjecture that both forces are caused by the same mass, and by the same gravitons, but they differ in magnitude, because the gravitons &lt;i&gt;stay around longer&lt;/i&gt;&amp;nbsp;in the second case, so &lt;i&gt;as messenger particles&lt;/i&gt; they establish a force many orders of magnitude stronger.&lt;br /&gt;&lt;br /&gt;How can they stay around longer to &lt;a href="http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/100000/10000/2000/300/112314/112314.strip.gif" title="Dilbert.com"&gt;become relevant&lt;/a&gt;? Perhaps by traveling orthogonally to the gravitational gravitons. Okay, inertial gravitons travel (more or less) orthogonally to our space, that is, along the time axis and thus following the trajectories of the particles the matter is built of.&lt;br /&gt;&lt;br /&gt;I think it was &lt;a href="http://en.wikipedia.org/wiki/Feynman"&gt;Feynman&lt;/a&gt; who mentioned that an anti-particle traveling 'backwards' in time can be equated with its particle traveling forward in time. Now, what is the anti-graviton? I believe that I read sometime that it is the same as the graviton. Just like a photon is not differing from an anti-photon. So the time inversion does not change any property of the graviton. Good. We have gravitons which make a short visit in our spacetime, and vanish just as fast as they appeared, and there are those which accompany mass-like particles (even when at rest) along their trajectory in time, possibly &lt;i&gt;bouncing&lt;/i&gt; back and forth &lt;i&gt;between earlier and later&lt;/i&gt;. This constitutes (my IDEA!) a force between a body now and its earlier appearance in spacetime. Of course this is the same as a force between now and the &lt;i&gt;future&lt;/i&gt; of the body. Actually there is a force between me and (me one second later). Or ten seconds or even a year!&lt;br /&gt;&lt;br /&gt;Two things become clear now. First we have to perform an integration (over all time destinations) to get the resulting force. And second, the force toward the past will bear a negative sign, so for stationary bodies all inertial forces will cancel out. I think this can be asserted for uniform movement too (i.e. constant velocity vector) but I did not waste any thoughts on this yet. Anyway, this is Newton's first law.&lt;br /&gt;&lt;br /&gt;Time to get to the second one. Here I want to make some further remarks. The inverse-square(-like) law should hold for inertial gravitons too, so that a longer time-span enters into the integral with a smaller effect. Kind of like the gravitational force between objects a light-second apart also decrease substantially. Second, causality is a bit smeared at the very short intervals where the forces are really relevant (Planck time?) so the reality a bit before pulls hard backwards and the reality a bit later pulls hard forward. Both look pretty much the same, differing only in the arrow of the force. I do not know whether this is essential, though.&lt;br /&gt;&lt;br /&gt;Back to Newton's second law. Imagine a stroboscope lighting a scene where a body moves, accelerated by a constant force along its movement direction. When you make a photo (with reasonable exposition time) you'll obtain a picture of several bodies, with the earlier ones nearer together, and the later ones successively more distant. Now let's declare the middle one as being &lt;i&gt;now&lt;/i&gt;. Then the &lt;i&gt;prior&lt;/i&gt; one is less distant than the &lt;i&gt;next&lt;/i&gt; one so the force between the prior and now is bigger than the force between now and next. These do not cancel out any more. This is a consequence of the inverse-square law. Of course the stroboscope should flash with Planck frequency etc. (so that the spacetime distance is small enough), but the principle is clear: We get a resultant force that points backwards, namely the difference between the (bigger) half-integral towards the past and the (smaller) half-integral towards the future.&lt;br /&gt;&lt;br /&gt;All the time I was using the wrong word 'force' for something space-time-like (a vector with 4 components). What we perceive or measure as accelerating force is the projection of that 4 component vector into our 3-dimensional space. So I conjecture that &lt;i&gt;F = ma&lt;/i&gt; is the projection of the resultant 4-force which I explained in the last paragraph to our 3 dimensions.&lt;br /&gt;&lt;br /&gt;If this little idea holds any water then it should be possible to calculate the inverse law for the 4-force. I'd bet it is inverse-cubic. If this succeeds, then the next test would be to figure out how the 4-force looks like when a relativistic (say half-lightspeed) particle is accelerated by a 3-force. Clearly the 4-speed rotates out of time, but does the the mass of the particle increase?&lt;br /&gt;I do not dare to think about whether we can ever get to the point where this idea gets tested in an even more comprehensive setting.&lt;br /&gt;&lt;br /&gt;But it was sure a lovely night when I was drinking that red wine with a good friend from Brasil two days ago, who dared to ask a quantum-mechanical question and received a long story as an answer, unknowingly liberating this&amp;nbsp;small niggling idea from the confines of my head!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6848647235943395135?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6848647235943395135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6848647235943395135' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6848647235943395135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6848647235943395135'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2011/02/my-thoughts-about-inertia.html' title='My Thoughts about Inertia'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-2525818754424584258</id><published>2011-01-09T12:38:00.000-08:00</published><updated>2011-01-10T06:38:20.815-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='types'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Quantifiers: Dark Matter</title><content type='html'>Modern cosmology routinely deals with &lt;i&gt;dark matter&lt;/i&gt;, a source of gravity necessary to explain certain things. In the last days I discovered a kind of dark matter in Ωmega too, and here is the related story.&lt;br /&gt;&lt;br /&gt;As we know type constructors arise when the data definition is equipped with parameters, like below:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;data Tree a = Tip a | Fork (Tree a) (Tree a)&lt;/code&gt;&lt;/blockquote&gt;&lt;code&gt;a&lt;/code&gt; is a &lt;i&gt;type variable&lt;/i&gt; and gets &lt;i&gt;instantiated&lt;/i&gt; (to a type) when we want the tree to contain actual information.&lt;br /&gt;&lt;br /&gt;Actually I could have written the second recursive occurrence of &lt;code&gt;Tree a&lt;/code&gt; in the &lt;code&gt;Fork&lt;/code&gt; branch as &lt;code&gt;Tree Char&lt;/code&gt;, and the type checker would have accepted it. Why? Because at each instantiation site the type variable &lt;code&gt;a&lt;/code&gt; is created &lt;i&gt;fresh&lt;/i&gt;, and can be bound to a new expression.&lt;br /&gt;&lt;br /&gt;But what is the kind of &lt;code&gt;a&lt;/code&gt;? In Haskell it can only be &lt;code&gt;*&lt;/code&gt;, which classifies all types, as the other possible kinds (&lt;code&gt;* → *&lt;/code&gt;, etc.) do not classify types. But this kinding relation is not spelled out directly, so let's choose a more explicit definition:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;data Tree :: *&amp;nbsp;→&amp;nbsp;* where ...&lt;/code&gt;&lt;/blockquote&gt;When talking about &lt;code&gt;Tree Integer&lt;/code&gt;, then it gets pretty clear that &lt;code&gt;Integer&lt;/code&gt;'s kind must be &lt;code&gt;*&lt;/code&gt; and that the resulting&amp;nbsp;&lt;code&gt;Tree Integer&lt;/code&gt; is itself kinded by &lt;code&gt;*&lt;/code&gt;.&lt;br /&gt;But there is a fine distinction between explicit and implicit kinding in Ωmega: in the latter case &lt;code&gt;a&lt;/code&gt; is kinded by a &lt;i&gt;unification variable&lt;/i&gt; instead of by &lt;code&gt;*&lt;/code&gt;. The reason is that Ωmega allows us to define custom kinds, which can classify other type-like things. These are usually used for indexing of type constructors.&lt;br /&gt;&lt;br /&gt;The unification variables that are present, but hidden from the user only become manifest when we have multiple levels of data definitions, with the higher levels indexing the lower ones and some constructor function tries to bind the unification variable to different kinds. Of course that won't work and all you'll see is a very cryptic error message. The smallest example I have encountered is &lt;a href="http://code.google.com/p/omega/issues/detail?id=70"&gt;issue 70&lt;/a&gt;, which I will present as an example here.&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;&lt;br /&gt;data Pat :: *3 where&lt;br /&gt;&amp;nbsp;&amp;nbsp;Q :: Pat ~&amp;gt; Pat&lt;br /&gt;&lt;br /&gt;data Pat' :: Pat ~&amp;gt; *2 where&lt;br /&gt;&amp;nbsp;&amp;nbsp;Q' :: Pat' n ~&amp;gt; Pat' (Q n)&lt;br /&gt;&lt;br /&gt;data Pat'' :: Pat' p ~&amp;gt; *1 where&lt;br /&gt;&amp;nbsp;&amp;nbsp;Q'' :: Pat'' n ~&amp;gt; Pat'' (Q' n)&lt;br /&gt;&lt;br /&gt;data Pat''' :: Pat'' p ~&amp;gt; *0 where&lt;br /&gt;&amp;nbsp;&amp;nbsp;Q :: Pat''' n → Pat''' (Q'' n)&lt;/code&gt;&lt;/blockquote&gt;Look at the last line, it induces these two kind equations:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;n = Pat'' p1&lt;br /&gt;Q'' n = Pat'' p2&lt;/code&gt;&lt;/blockquote&gt;Each equality at some level induces an equality at one level up. But &lt;code&gt;p1&lt;/code&gt; and &lt;code&gt;p2&lt;/code&gt; are kinded by the same unification variable, &lt;code&gt;k&lt;/code&gt;. Let's note the two equations with &lt;code&gt;k&lt;/code&gt; in the middle:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;m = k = Q' m&lt;/code&gt;&lt;/blockquote&gt;where &lt;code&gt;m&lt;/code&gt; is the kind of &lt;code&gt;n&lt;/code&gt;.&lt;br /&gt;You can see now that &lt;code&gt;m&lt;/code&gt; is forced to be equal to &lt;code&gt;Q' m&lt;/code&gt;, which is clearly incommensurable.&lt;br /&gt;The solution is clearly to spell out kinding quantifiers explicitly with type variables. Since these get instantiated to fresh copies on the fly, the above problem does not occur.&lt;br /&gt;&lt;br /&gt;So we arrive at (only showing the last definition for brevity's sake)&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;data Pat''' :: forall (o::Pat) (p::Pat' o) . Pat'' p ~&amp;gt; *0 where&lt;br /&gt;&amp;nbsp;&amp;nbsp;Q :: Pat''' n → Pat''' (Q'' n)&lt;/code&gt;&lt;/blockquote&gt;Black magic? Only when you let the kinds live in the dark!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-2525818754424584258?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/2525818754424584258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=2525818754424584258' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2525818754424584258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2525818754424584258'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2011/01/quantifiers-dark-matter.html' title='Quantifiers: Dark Matter'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8595457617118091135</id><published>2010-12-27T14:57:00.000-08:00</published><updated>2010-12-27T14:57:48.322-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><category scheme='http://www.blogger.com/atom/ns#' term='syntax extension'/><title type='text'>Recently Implemented Syntax Extensions</title><content type='html'>The alert reader must have noticed that in my &lt;a href="http://heisenbug.blogspot.com/2010/12/zipping-through-it.html"&gt;recent post&lt;/a&gt; I refer to a syntax extension called &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;LeftList&lt;/span&gt;, intended to model left-associative lists, which are naturally showing up in many contexts.&lt;br /&gt;&lt;br /&gt;But that's not all, I've been busy adding more goodness. After realizing that the frontend for expressions of the form &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;()u&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;(42)i&lt;/span&gt; was already present, I decided to add these as &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Unit&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Item&lt;/span&gt; syntactic extensions. I documented them in the manual, so the next release will be up-to-date documentation-wise.&lt;br /&gt;&lt;br /&gt;Today, being given some idle time, I came around to finish up the &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;LeftRecord&lt;/span&gt; extension, which is just what you would expect. Implementing it turned out to be even easier than the same process performed for &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;LeftList&lt;/span&gt;, not only because of the lessons learned, but for want of the ambiguous parsing of &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;{tail; tag=val}lr&lt;/span&gt; which does happen with &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;LeftLists&lt;/span&gt;: &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;[tail; head]ll&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;There is one itch left: adding &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;LeftPair&lt;/span&gt;s, which should be a piece of cake, and could happen anytime. And then there is a &lt;i&gt;pie-in-the-sky&lt;/i&gt; enhancement request (a.k.a. &lt;a href="http://code.google.com/p/omega/issues/detail?id=64"&gt;issue 64&lt;/a&gt;), which is somewhat tricky, so do not expect it being done any day now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8595457617118091135?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8595457617118091135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8595457617118091135' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8595457617118091135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8595457617118091135'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/12/recently-implemented-syntax-extensions.html' title='Recently Implemented Syntax Extensions'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-4275775444584895571</id><published>2010-12-14T00:01:00.000-08:00</published><updated>2010-12-14T00:24:04.364-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dependent types'/><category scheme='http://www.blogger.com/atom/ns#' term='logic'/><category scheme='http://www.blogger.com/atom/ns#' term='dylan'/><title type='text'>Singleton Types are the Key to Co-dependency</title><content type='html'>Since the last time I wrote &lt;a href="http://heisenbug.blogspot.com/2010/11/more-on-existentials.html"&gt;about existentials&lt;/a&gt; I had a plenty of time to ponder how they fit into the &lt;i&gt;qualifier-typed typed&lt;/i&gt; lambda calculus which de Bruijn &lt;a href="http://alexandria.tue.nl/repository/freearticles/597608.pdf"&gt;has proposed&lt;/a&gt;, and I am very proud of &lt;a href="http://svn.berlios.de/viewvc/al4nin/trunk/purgatory/Kinding.omg?revision=924"&gt;implementing a formalization&lt;/a&gt; for.&lt;br /&gt;&lt;br /&gt;The headline has already spoiled the suspense, but the interesting part is how I arrived at that assertion. It happened last night and it carries all the attributes of an &lt;i&gt;epiphany&lt;/i&gt; :-)&lt;br /&gt;&lt;br /&gt;There were some anomalies that worried me about the introduction of existential qualifiers in the &lt;a href="http://heisenbug.blogspot.com/2010/11/more-on-existentials.html"&gt;prequel post&lt;/a&gt;:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;the treatment of patterns that are values was missing,&lt;/li&gt;&lt;li&gt;the handwavy argument how the proposition corresponding to the condition is encoded,&lt;/li&gt;&lt;li&gt;that the dependent sum binder introduced &lt;i&gt;two variables&lt;/i&gt; (where lambdas only introduce one),&lt;/li&gt;&lt;li&gt;and finally that parenthesized condition after the ∃-quantor which do not seem to appear in logic textbooks.&lt;/li&gt;&lt;/ol&gt;It was the first worry that kept me awake this night. Here is a prototypic definition:&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;fac 0 = 1&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;fac (1+n) = (1+n) * fac n&lt;/span&gt;&lt;/blockquote&gt;In &lt;a href="http://www.opendylan.org/"&gt;Dylan&lt;/a&gt; (an object-oriented functional language) one would write the first branch of same function as&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;define method fac (n :: singleton(0)) 1 end&lt;/span&gt;&lt;/blockquote&gt;Here the&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;a href="http://www.opendylan.org/books/drm/Constructing_and_Initializing_Instances#singleton"&gt;singleton&lt;/a&gt;&lt;/span&gt; function &lt;i&gt;returns a type&lt;/i&gt; whose sole inhabitant is the argument to&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;singleton&lt;/span&gt;.&amp;nbsp;This analogy pushed me over the top. What if I introduced the concept of &lt;i&gt;co-dependency&lt;/i&gt; in my formalization? Say,&lt;br /&gt;&lt;blockquote&gt;∃x:singleton 1 . x&lt;/blockquote&gt;where values can be lifted up in the type realm and appear at the right-hand-side of the type judgement (:). I prefer to call this co-dependency because it is opposite to regular dependency which happens in the &lt;i&gt;returned expression&lt;/i&gt;. Consider the following type-theory expression:&lt;br /&gt;&lt;blockquote&gt;λx:Int . 〈y:singleton (5*x)〉 . y&lt;/blockquote&gt;here a universally quantified variable (x) is entering an expression which is the argument to the singleton construct giving the type to y. What does it mean? That for every x there is an y of 5 times the magnitude, which becomes the result.&lt;br /&gt;&lt;br /&gt;With this interpretation all my worries have vanished: there is just one variable added by the dependent sum quantification and the condition is now neatly tucked away on the right side of the colon!&lt;br /&gt;&lt;br /&gt;Next to come: introduce this idea into the formalization.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-4275775444584895571?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/4275775444584895571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=4275775444584895571' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4275775444584895571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4275775444584895571'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/12/singleton-types-are-key-to-co.html' title='Singleton Types are the Key to Co-dependency'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-4870411078037436652</id><published>2010-12-11T04:23:00.000-08:00</published><updated>2010-12-11T04:34:39.846-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Zipping through it</title><content type='html'>In my email conversation with &lt;a href="http://coder.bsimmons.name/blog/"&gt;Brandon&lt;/a&gt; prior to the release of &lt;a href="http://hackage.haskell.org/package/thrist"&gt;thrist-0.2&lt;/a&gt;, I told him that I did not come around implementing reverse thrists, and I showed how they arise naturally when doing computational passes over thrists: &lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;(((a, b), c), d) e (f, (g, (h, i)))&lt;/span&gt;. He asked me whether this has anything to do with &lt;a href="http://www.haskell.org/haskellwiki/Zipper"&gt;zippers&lt;/a&gt;, which I answered to the affirmative, my previous ideogram being essentially a &lt;i&gt;thrist zipper&lt;/i&gt;. As it maneuvers through the data structure it deconstructs the original thrist, places a new element into focus and zips together a left-associative structure behind. Visually it (kind of) corresponds to the zipper on your jacket.&lt;br /&gt;&lt;br /&gt;This post is dedicated to this versatile tool being applied to thrists to obtain an isomorphic data structure which I call the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ThristZipper&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;As the ideogram demonstrates, this zipper consists of three parts:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;the left-associate thrist (usually holding the already visited portion),&lt;/li&gt;&lt;li&gt;the focus element &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;e&lt;/span&gt;,&lt;/li&gt;&lt;li&gt;the (right-associative) thrist (usually to be iterated over).&lt;/li&gt;&lt;/ol&gt;So first we have to define &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;LeftThrist&lt;/span&gt; (this is how I prefer to call it).&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;data&amp;nbsp;LeftThrist :: (* → *&amp;nbsp;→&amp;nbsp;*)&amp;nbsp;→&amp;nbsp;*&amp;nbsp;→&amp;nbsp;*&amp;nbsp;→&amp;nbsp;* where&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;LeftNil ::&amp;nbsp;LeftThrist k a a&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;LeftCons ::&amp;nbsp;LeftThrist k a b&amp;nbsp;→&amp;nbsp;k b c&amp;nbsp;→&amp;nbsp;LeftThrist k a c&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Again, the types match up. Now we can define&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ThristZipper&lt;/span&gt;:&lt;/div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;data&amp;nbsp;ThristZipper&amp;nbsp;:: (*&amp;nbsp;→&amp;nbsp;*&amp;nbsp;→&amp;nbsp;*)&amp;nbsp;→&amp;nbsp;*&amp;nbsp;→&amp;nbsp;*&amp;nbsp;→&amp;nbsp;* where&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;Focus ::&amp;nbsp;LeftThrist k a b&amp;nbsp;→&amp;nbsp;k b c&amp;nbsp;→&amp;nbsp;Thrist k c d&amp;nbsp;→&amp;nbsp;ThristZipper k a d&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;It remains to define all the operations on&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ThristZipper&lt;/span&gt; that will make it a versatile tool.&lt;/div&gt;&lt;div&gt;We start with &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;zipInto&lt;/span&gt;:&lt;/div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;zipInto ::&amp;nbsp;Thrist k a b&amp;nbsp;→&amp;nbsp;Maybe (ThristZipper k a b)&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;zipInto Nil = Nothing&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;zipInto (Cons e r) = Just (Focus LeftNil e r)&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;We can similarly define&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;zipLeftInto&lt;/span&gt;, &lt;i&gt;advancing&lt;/i&gt;, &lt;i&gt;focus manipulation&lt;/i&gt;,&amp;nbsp;&lt;i&gt;maps&lt;/i&gt;, &lt;i&gt;folds&lt;/i&gt; and &lt;i&gt;getting out&lt;/i&gt; on the right or in the left. These are of course left as an exercise to the reader, but I will define retract (the opposite movement from &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;advance&lt;/span&gt;) here for good measure:&lt;/div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;retract ::&amp;nbsp;ThristZipper k a b&amp;nbsp;→&amp;nbsp;Maybe (ThristZipper k a b)&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;retract (Focus&amp;nbsp;LeftNil _ _) =&amp;nbsp;Nothing&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;retract (Focus (LeftCons r e') e t) = Just (Focus r e' (Cons e t))&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;And a lot prettier in Ωmega (&lt;a href="http://code.google.com/p/omega/source/browse/#svn/trunk/src"&gt;svn HEAD&lt;/a&gt;):&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;retract (Focus&amp;nbsp;[]lt _ _) =&amp;nbsp;Nothing&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;retract (Focus [r; e']lt e t) = Just (Focus r e' [e; t]l)&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;PS: I definitely plan to make all this part of thrist-1.0 when it arrives.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-4870411078037436652?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/4870411078037436652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=4870411078037436652' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4870411078037436652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4870411078037436652'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/12/zipping-through-it.html' title='Zipping through it'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-7741350798543567179</id><published>2010-12-10T15:09:00.000-08:00</published><updated>2010-12-10T16:58:52.735-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='category theory'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>The Sky was the Limit</title><content type='html'>Everyone remembers&amp;nbsp;Tom Petty's song &lt;a href="http://www.chordie.com/chord.pere/www.guitaretab.com/p/petty-tom/14484.html"&gt;'Into the Great Wide Open'&lt;/a&gt; with it's famous refrain&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;i&gt;The sky was the limit&lt;/i&gt;&lt;/span&gt;&lt;/blockquote&gt;I was thinking about limits (the category theory ones) for many years now, but could never really visualize the concept. (I should really start reading &lt;a href="http://ukcatalogue.oup.com/product/9780199237180.do"&gt;Awodey's 'Category Theory'&lt;/a&gt; which will be my present to self at Xmas.) I tried to get hold of the related problems with a mental construction of a lazy, self-building thrist. It was clear that each element should increase the type, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Z&lt;/span&gt;, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(S Z)&lt;/span&gt;, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(S (S Z))&lt;/span&gt;, etc. ad infinitum, so the start type would be clear: &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Thrist Up Z ?&lt;/span&gt;. But the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;?&lt;/span&gt;, let's call it the limit, is not clear at all. Anyway it would be an infinite type, not like in the simple analogy of &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;let count = 0 : count in count&lt;/span&gt;, where &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;count :: [Int]&lt;/span&gt; holds. As we know type checkers do not like infinite types, as it would take forever and two days to check them :-)&lt;br /&gt;&lt;br /&gt;Fortunately the sky is not a limit anymore and I came up with a solution that is nice and short even in Ωmega, which is a strict language (albeit with a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;lazy&lt;/span&gt; construct). Since it is only a few lines I can effortlessly reproduce it here.&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;data Count :: Nat ~&amp;gt; Nat ~&amp;gt; * where&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;Incr :: Nat' n -&amp;gt; Count n (1+n)t&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;The &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Incr&lt;/span&gt; constructor states the typing rule, namely one higher to the right than to the left. We can try it out:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;prompt&amp;gt; [Incr 0v, Incr 1v, Incr 2v]l&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;[(Incr 0v),(Incr 1v),(Incr 2v)]l :&amp;nbsp;Thrist Count 0t 3t&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Not surprisingly, this is the only value of type&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Thrist Count 0t 3t&lt;/span&gt;. We follow the example of &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;count&lt;/span&gt; above and write:&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;a = [Incr 0v; lazy (shift a)]l&lt;/span&gt;&lt;/blockquote&gt;Naturally &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;shift&lt;/span&gt; will shift a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Count&lt;/span&gt; thrist to the right, thus satisfying the type constraint of thrists, that at each joining point the left and right types must match up. The&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;lazy&lt;/span&gt;&amp;nbsp;keyword is needed here to delay the evaluation, it is however pointless in Haskell.&lt;br /&gt;&lt;br /&gt;All that remains is to write the&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;shift&lt;/span&gt;&amp;nbsp;function which will create the ominous limit type:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;shift :: Thrist Count n a -&amp;gt; Thrist Count (1+n)t a&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;shift [Incr n; r]l = [Incr (1+n)v; lazy (shift r)]l&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;It is probably not a surprise that the limit value is ⊥ (i.e. nonexistent), so any type will do (along the constraints of the &lt;i&gt;kind&lt;/i&gt; in question). I settled with a universal type.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we can pattern match on &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;a&lt;/span&gt; to see that it really grows into the sky:&lt;/div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;case a of {[a,aa,aaa,aaaa; b]l -&amp;gt; show b}&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;prints&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"[(Incr 4v) ; ...]l"&lt;/span&gt; thanks to &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;show&lt;/span&gt;'s magic. The&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;...&lt;/span&gt;&amp;nbsp;corresponds to the suspended computation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hey, it wasn't that hard at all! Where is the infinite type? It is hidden behind the existential barrier that is formed at each thrist joining point, and since it cannot escape we do not have to worry it...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Good night!&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-7741350798543567179?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/7741350798543567179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=7741350798543567179' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7741350798543567179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7741350798543567179'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/12/sky-was-limit.html' title='The Sky was the Limit'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3835680705161238787</id><published>2010-12-01T18:08:00.000-08:00</published><updated>2010-12-01T18:10:07.739-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dependent types'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Es taut nicht</title><content type='html'>The subject is German, meaning "it doesn't thaw", which is rather true: as I write this we have chilly -10 °C (14 °F) and 25 cm (10 inches) snow on the ground. And it keeps snowing. I cannot remember a winter like this.&lt;br /&gt;&lt;br /&gt;But this is not the reason of my posting! Instead I have hidden a pun in there: "there is no &lt;i&gt;tau&lt;/i&gt;", yes, the Greek letter (τ). Which proposition is definitely false, because as of today I succeeded to encode de Bruijn's &lt;i&gt;higher degree binders&lt;/i&gt; in &lt;a href="http://code.google.com/p/omega/"&gt;Ωmega&lt;/a&gt;. I've fought a lot (on and off) against this fortress...&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://svn.berlios.de/viewcvs/al4nin/trunk/purgatory/Kinding.omg?pathrev=868"&gt;code is here&lt;/a&gt;, see and comment.&lt;br /&gt;&lt;br /&gt;PS: Does anybody know a better quality URL for &lt;a href="http://www.cedar-forest.org/forest/papers/journals-publications/jfp6-2.ps"&gt;this paper&lt;/a&gt;?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3835680705161238787?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3835680705161238787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3835680705161238787' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3835680705161238787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3835680705161238787'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/12/es-taut-nicht.html' title='Es taut nicht'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5611043195645969364</id><published>2010-11-27T16:27:00.000-08:00</published><updated>2010-12-13T22:42:04.561-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dependent types'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='logic'/><title type='text'>More on Existentials</title><content type='html'>&lt;div&gt;In a &lt;a href="http://heisenbug.blogspot.com/2010/11/patterns-and-existentials.html"&gt;previous post&lt;/a&gt; I suggested a new (?) interpretation for pattern variables in case branches. This post is my way to understand matters more.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let's start with the basic example&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;data Temp :: * where&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&amp;nbsp;&amp;nbsp;Kelvin :: Float -&amp;gt; Temp&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Then &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Kelvin 273.2&lt;/span&gt; is about the temperature at which water freezes (or dually, thaws). Okay, let's demonstrate my point by this code:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;diff :: Temp -&amp;gt; Temp -&amp;gt; Bool&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;diff (Kelvin a) (Kelvin b) = a == b&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;test t = case t of { Kelvin a -&amp;gt; diff t (Kelvin a) }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;What do you expect the function &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;test&lt;/span&gt; is? Yes, the &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;const True&lt;/span&gt; one! The explanation is simple, as we are in a referentially transparent context, destructuring a value by pattern matching and reconstructing it the same way from its parts creates a value undistinguishable from the original. This of course means that &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;diff&lt;/span&gt; will not be able to detect a difference.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let's switch to a different interpretation. Some oracle invokes the case branch and says:&amp;nbsp;I am not allowed to tell you what it is but here is a &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Float&lt;/span&gt; named &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;a&lt;/span&gt; and you can assume that &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Kelvin a&lt;/span&gt; is indistinguishable from &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;t&lt;/span&gt;!&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;blockquote&gt;Look ma, no 'pattern matching' or 'destructuring' needed!&lt;/blockquote&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;a&lt;/span&gt; may contain 3.14 or 3.15 or 100.1 or ..., ad infinitum, we simply do not know. But we know that it names a &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Float&lt;/span&gt;! It &lt;i&gt;exists&lt;/i&gt; as a &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Float&lt;/span&gt;. Mathematically the case branch can be written as&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;∃&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;a&lt;/span&gt;:&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Float&lt;/span&gt; (&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;t&lt;/span&gt; ≡ &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Kelvin a&lt;/span&gt;) . &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;diff t (Kelvin a)&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;which is the english phrase "compute &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;diff t (Kelvin a)&lt;/span&gt; under the assumption that there is a &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Float&lt;/span&gt;-valued number that when passed to the function &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Kelvin&lt;/span&gt; becomes undistinguishable from the case scrutinee".&lt;/div&gt;&lt;div&gt;After seeing the same thing in three languages we have to reformulate it one more time. Into logic, that is the language of &lt;i&gt;type theory&lt;/i&gt;. Types are propositions and any value one type inhabit proves the corresponding proposition. The existential quantifier (∃) above gets mapped to a &lt;i&gt;dependent sum&lt;/i&gt; that is the input to the computation&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;t : Temp&lt;span class="Apple-style-span" style="font-size: medium;"&gt; ⊦ &lt;/span&gt;〈a : Float, proof : SomeProp(t, a)〉. diff t (Kelvin a)&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;I took this formulation (and other wisdom) from Appendix A of Steve Awodey's &lt;a href="http://www.andrew.cmu.edu/user/awodey/preprints/TTH.pdf"&gt;recent paper&lt;/a&gt;. This part unfortunately is not my strongest side. My best guess is that SomeProp(t, a) is a type that encodes the &lt;i&gt;same&lt;/i&gt;ness fact, and depends on a. Moreover, proof is an inhabitant of that type. The&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;〈a : Float, proof : SomeProp(t, a)〉&lt;/span&gt; construct binds two existential variables.&amp;nbsp;The I hope to come up with a nicer formulation sometime.&amp;nbsp;(&lt;i&gt;Please comment if I got something wrong, thanks!&lt;/i&gt;)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After understanding this, we can advance to more involved issues, namely one level higher. Take a look at this gorgeous definition:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;data Ex :: * where&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&amp;nbsp;&amp;nbsp;Hide :: a -&amp;gt; Ex&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;This is a pretty useless data type but should be sufficient for my purposes. Then we need a function that pattern matches on it:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;f :: Ex -&amp;gt; Bool&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;f e = case e of { Hide it -&amp;gt; True }&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;We see that pattern matching unhides the hidden value. It is said that &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;it&lt;/span&gt; receives an existential type in the case branch where it is bound. But you will see no type annotation on &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;it&lt;/span&gt;, ever.&lt;/div&gt;&lt;div&gt;So, what happens in the case branch this time? While the type of &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;it&lt;/span&gt; might have been known at the moment of construction, at this point the type system does not know it. So it is assumed to have some type &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;t&lt;/span&gt;. After giving our unknown a name (thus qualifying it existentially) we can ponder about the value of &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;it&lt;/span&gt;.  This is something we have explored above already, so we can reformulate the case branch mathematically like follows:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;∃a:* (true) . ∃&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;it&lt;/span&gt;:a (e ≡ &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Hide it&lt;/span&gt;) . &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;True&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The first qualifier has just a trivial condition attached to it, I believe I could also have omitted it. I am on pretty thin ice at this point so I'll refrain from giving a type-theoretic transcription, but you can imagine that there will be two dependent sum binders where the first enters in the&amp;nbsp;second in the &lt;i&gt;classifier position&lt;/i&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;One more closing thought on the oracles involved. They sound mysterious but they aren't at all. For example in Ωmega the oracle for values it the reduction machinery for runtime values. It is obvious how this machinery is able to look into closures and deconstruct instances of polynomial datatypes. On the type (also kind and up) level, however&amp;nbsp;Ωmega &lt;a href="http://web.cecs.pdx.edu/~sheard/papers/sheardPLPV.ps"&gt;resorts to narrowing&lt;/a&gt;, an evaluation mechanism usually employed in logic programming. In the typing rules these mechanisms do not have a place, thus how the variables get bound remains elusive to those.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5611043195645969364?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5611043195645969364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5611043195645969364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5611043195645969364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5611043195645969364'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/11/more-on-existentials.html' title='More on Existentials'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8111835205519120627</id><published>2010-11-27T06:37:00.001-08:00</published><updated>2010-12-27T15:26:34.257-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='applicative'/><title type='text'>Applicative Structures and Thrists</title><content type='html'>&lt;div&gt;I've been toying with the idea of furnishing the the applicative framework into &lt;a href="http://hackage.haskell.org/package/thrist"&gt;thrist-like clothing&lt;/a&gt;, with early attempts &lt;a href="http://svn.berlios.de/viewvc/al4nin/trunk/purgatory/Applicative.omg?pathrev=842"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Last night I might have gotten it, finally...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is the idea. Since function application is left-associative, but thrists are right associative, I'll reverse the application's direction to right-to-left, i.e. &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;f a b c&lt;/span&gt;&lt;/span&gt; will become &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;c b a f&lt;/span&gt;&lt;/span&gt;. This uglyness is another reason to finally whip up a &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;RevThrist&lt;/span&gt;&lt;/span&gt;, which would be SNOC-like and left-associative.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We need following ingredients:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Fun - functions perform the reduction to a new object,&lt;/li&gt;&lt;li&gt;Arg - arguments successively saturate the applicable structure to the right,&lt;/li&gt;&lt;li&gt;Par - partial application (or parent) initiates the reduction.&lt;/li&gt;&lt;/ul&gt;I'll explain these elements next, but first rewrite the above expression a bit to get a parentesized form &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;(c(b(a f)))&lt;/span&gt;, and now with roles marked up in thrist syntax:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Cons (Arg c) $ Cons (Arg b) $ Cons (Arg a) $ Cons (Fun f) Nil&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;Looks almost reasonable. Time to define the ingredients mentioned above. Remember, that it must be a two-parameter data type and that the types must match up between &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Arg c&lt;/span&gt;&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Arg b&lt;/span&gt;&lt;/span&gt;, etc., and finally between &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Arg a&lt;/span&gt;&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Fun f&lt;/span&gt;&lt;/span&gt;. This is a pretty hefty requirement!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can attempt passing the effective application type between the ingredients, defining the data structure as&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;data Appli :: * → * → * where&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&amp;nbsp;&amp;nbsp;Fun :: (a → b) → Appli (a → b) c&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&amp;nbsp;&amp;nbsp;Arg :: a → Appli b (a → b)&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;This means functions pass their own type to the left (and ignoring what comes from the right), while arguments expect a saturable effective type from the right, store an appropriate value and propagate the remaining type to the left. This should work now: &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Cons (Arg 'a') $ Cons (Fun ord) Nil&lt;/span&gt;, with the type being &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Thrist Appli Int c&lt;/span&gt;. As you can see, no function type gets passed to the left, so you cannot prepend any more arguments.&lt;/div&gt;&lt;div&gt;But this all appears useless since we cannot nest things. The &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Par&lt;/span&gt; ingredient will take care of this:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Par :: Thrist Appli a c → Appli b (a → b)&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Par&lt;/span&gt; has a double role, it acts just like an argument, but holding a thrist inside, and thus groups a sub-application.&lt;/div&gt;&lt;div&gt;The &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;c&lt;/span&gt; type variable occurring in &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Par&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Fun&lt;/span&gt; troubled me a lot, because it allows building up illegal thrists. Consider &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Cons (Fun f) $ Cons (Fun f) Nil&lt;/span&gt;. This gibberish cannot be assigned any reasonable semantics! Finally it occurred to me to use a phantom type for filling in this breach:&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;data Peg&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Since &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Peg&lt;/span&gt; is uninhabited, no function signature can include it (unless it is a divergent one). It also ensures that the leftmost ingredient in a thrist is a function, how practial for &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Par&lt;/span&gt;! Anyway, our &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;Appli&lt;/span&gt; is done now:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;data Appli :: * → * → * where&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&amp;nbsp;&amp;nbsp;Fun :: (a → b) → Appli (a → b) Peg&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&amp;nbsp;&amp;nbsp;Arg :: a → Appli b (a → b)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&amp;nbsp;&amp;nbsp;Par :: Thrist Appli a Peg → Appli b (a → b)&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;So what brave soul will try this out? Because I must confess, up to this point I've been too lazy to fire up GHC!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;You might be inclined to say, why this whole circus? An awkward notation for something as simple as function application? Any Haskell implementation can do this with a beautiful syntax!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;Yes, we can build up applications but can't even compute them. This is a toy at the moment. But try to pull apart an application in Haskell! You can't! Here you can add an evaluator (&lt;/span&gt;&lt;span class="Apple-style-span"&gt;foldlThrist&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;?) and also instrument, trace, debug your evaluation process.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;Also, there is a reason I say 'Applicative Structures' in the title. Here is a generalization of &lt;/span&gt;&lt;span class="Apple-style-span"&gt;Appli&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt; that is parametrized:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;data Appli :: (&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;* → * → *&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) → * → * → * where&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;Fun :: (a ~&amp;gt; b) → Appli (&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;~&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) (a ~&amp;gt; b) Peg&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;Arg :: a → Appli &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;~&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;b (a ~&amp;gt; b)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;Par :: Thrist (Appli &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;~&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)) &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;a Peg → Appli &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;~&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;b (a ~&amp;gt; b)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;You are free now to create your own function and value space with attached typing rules and still be able to use &lt;/span&gt;&lt;span class="Apple-style-span"&gt;Thrist (Appli MySpace)&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;The possibilities are endless, e.g. encrypted execution on remote hosts or abstract interpretation, you say it.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;Have &lt;/span&gt;Fun&lt;span class="Apple-style-span" style="font-family: Georgia, serif;"&gt;!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8111835205519120627?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8111835205519120627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8111835205519120627' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8111835205519120627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8111835205519120627'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/11/applicative-structures-and-thrists.html' title='Applicative Structures and Thrists'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-7098681385143947117</id><published>2010-11-25T15:06:00.000-08:00</published><updated>2010-11-25T15:23:43.398-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='crazy'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Type Synonyms Generalized</title><content type='html'>Type functions are the new trend. Ωmega has them with the following syntax:&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;tfun :: Nat ~&gt; Nat&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{tfun Z} = S Z&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Haskell (that is GHC) has them in the flavor of type families.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It has just occurred to me that they can be considered as a syntactic relaxation of type synonyms! Look:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;tfun :: Nat ~&gt; Nat&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;type tfun Z = S Z&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;type tfun (S n) = Z&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;When conventional type synonyms are used they must be fully applied. This should be the case here too. I am not sure whether type families or Ωmega-style type functions can be partially applied, though.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, a bit more to write at the definition site but less curlies to type at the call site; it may well be worth it.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-7098681385143947117?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/7098681385143947117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=7098681385143947117' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7098681385143947117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7098681385143947117'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/11/type-synonyms-generalized.html' title='Type Synonyms Generalized'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-4914953349085630843</id><published>2010-11-25T14:21:00.000-08:00</published><updated>2010-11-25T15:32:58.830-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='crazy'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='GADT'/><title type='text'>Patterns and Existentials</title><content type='html'>I am reading papers again and this always activates my creative fantasy. I want to explain a small revelation I had just now.&lt;div&gt;&lt;blockquote&gt;Patterns are the same thing as declaring &lt;i&gt;existential values&lt;/i&gt; corresponding to all pattern variables according to their respective types as stated in their respective constructors and asserting that the &lt;i&gt;pattern interpreted as a value&lt;/i&gt; is the same as the scrutinee.&lt;/blockquote&gt;The body behind the pattern in turn is similarly evaluated with the existential variables in scope. Of course the existential values are filled in by some oracle which is uninteresting from the typing perspective. A strong corollary of the asserted value identity is that we can also assert that the type of the scrutinee unifies with the type of the pattern-value (in the scope of the existentials, but not outside of it)!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Just as universally quantified values are typed by dependent products (∏-stuff) the existentially quantified values are typed by dependent sums (∑-stuff). Note that the stuff is at stratum 1, e.g. types. This is in contrast to the Haskell data declaration&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;data Foo = forall a . Foo a&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;where a is at stratum 1, being an &lt;i&gt;existential type&lt;/i&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hmm, when thinking this to the end we may either end up at the conventional non-inference for GADTs or something like the generalized existentials as proposed in Chuan-kai Lin's thesis.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I conjecture also that this is the same thing as the post-facto type inference I &lt;a href="http://code.google.com/p/omega/issues/detail?id=12"&gt;suggested here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now all remains to is to reinterpret function calls as a data type being a tuple with existential values and to apply the above trick.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-4914953349085630843?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/4914953349085630843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=4914953349085630843' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4914953349085630843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4914953349085630843'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/11/patterns-and-existentials.html' title='Patterns and Existentials'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3141202997732626062</id><published>2010-11-23T18:09:00.000-08:00</published><updated>2010-11-23T18:21:22.669-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='types'/><category scheme='http://www.blogger.com/atom/ns#' term='GADT'/><title type='text'>Hats off</title><content type='html'>The &lt;a href="http://www.reddit.com/r/types"&gt;types subreddit&lt;/a&gt; references Chuan-kai Lin's &lt;a href="http://sites.google.com/site/chklin/research"&gt;PhD thesis&lt;/a&gt; about GADT type inference. I already have read the &lt;i&gt;pointwise paper&lt;/i&gt;, but this is of course a revelation. He actually did implement an algorithm that inferred types for 25 (out of 30) little benchmark programs with GADTs. Previous attempts accomplished at most one!&lt;div&gt;&lt;br /&gt;&lt;div&gt;But the thing that impressed me the most wasn't the technical side of his story but the beautifully crafted slides of his PhD defense talk. I am baffled...&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Congratulations Chuan-kai!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3141202997732626062?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3141202997732626062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3141202997732626062' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3141202997732626062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3141202997732626062'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/11/hats-off.html' title='Hats off'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8440565951853593525</id><published>2010-11-12T17:55:00.000-08:00</published><updated>2010-11-12T18:35:49.845-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='hackage'/><title type='text'>Cooperation</title><content type='html'>I have just uploaded the &lt;a href="http://hackage.haskell.org/package/thrist"&gt;thrist-0.2&lt;/a&gt; package to hackage. All credit goes to &lt;a href="http://coder.bsimmons.name/"&gt;Brandon Simmons&lt;/a&gt;, who has added significant functionality and now provides some functions for thrists that are more in line with the prelude. Brandon has accepted to be a co-author to the library and I am very happy about it. Welcome, Brandon!&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For the users of the package this is good news, as I am a little dim spot on the outer sectors of the haskell radar, while Brandon is a savvy and ambitioned person, and to continue with my previous metaphor, a bright green dot on the screen, swiftly moving towards the center :-)&lt;div&gt;&lt;br /&gt;&lt;div&gt;This post is a kind of mini release note for the release. Being an experimental package we do not intend to guarantee API stability, so we took the freedom to rename routines to make naming more consistent with the prelude. &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foldThrist&lt;/span&gt; is now &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;foldrThrist&lt;/span&gt; and it got a bunch of new cousins too. Notably the types are much wider now, which allows for some more magic to happen. Finally, the haddock comments have been enhanced and as-of-present actually tell something.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Please ignore the sub-modules for now, they are unfinished, and much more experimental than the rest (I have not got around researching a compelling solution yet). A &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;RevThrist&lt;/span&gt; (or similar) GADT did not make it into the release, I hope I can cram it in sometime later.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, enjoy the lib!&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8440565951853593525?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8440565951853593525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8440565951853593525' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8440565951853593525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8440565951853593525'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/11/cooperation.html' title='Cooperation'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-2337676947217909753</id><published>2010-10-18T13:56:00.000-07:00</published><updated>2010-10-18T15:14:37.241-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='speculation'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Lion's Share</title><content type='html'>I am sick. Five days already, and counting. My brain feels like &lt;a href="http://en.wikipedia.org/wiki/Sauerkraut"&gt;Sauerkraut&lt;/a&gt; and thinking is hard. But my dysregulated sleep cycle lets me ponder all kinds of idle things.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One of them is the upcoming "Back to Mac" announcements on Wednesday 11/9. It seems pretty sure that Mac OS X 10.7 (or 11.0 possibly) will be introduced under the 'Lion' code name. This is pretty exciting as nothing really revolutionary happened in the Mac world since 'Leopard'.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Many people are speculating what the foundations will be. My bet is a fully-LLVM compiled system: good-bye GCC, we had a nice time together. The majority of the LLVM team is virtually absent from the IRC channel and the mailing lists, they must be working on something big...&lt;/div&gt;&lt;div&gt;That is, ironing out the latest bugs so that nothing embarrassing can happen while Steve is on stage. But clang v2.8 already compiles e.g. the FreeBSD kernel and userland with pretty good quality, so this cannot be the entire reason. The (already filled-in) job posting for a "revolutionary new feature in the very foundations of Mac OS X" is probably LLVM-related. Modern GPUs have hundreds of very potent processors that excel at floating-point computations. To use them effectively one needs a flexible compiler that can specialize snippets of code to run on each with optimal throughput. OpenCL attempts this but mostly in the graphical domain, and it sources from a C-like language. What we have in this case, however, is not about graphics... I am going on a limb here and suggest that the new feature is about ... conscience! Yeah, a primitive (compared to humans) but effective way of reflection, that is, understanding of its own existence and goals. Also the goals of the user! This will pave the way to new forms of assistance the OS can provide for us to get our jobs done. It has been tried many times, but to cite the job description, "Something that has never been done before and will truly amaze everyone".&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My neuronal storm has ceased, I feel limp and tired. Time for another nap. Bye.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-2337676947217909753?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/2337676947217909753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=2337676947217909753' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2337676947217909753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2337676947217909753'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/10/lions-share.html' title='Lion&apos;s Share'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3281478009903682914</id><published>2010-08-27T20:29:00.000-07:00</published><updated>2010-08-27T20:59:26.032-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='clang'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Link as link can</title><content type='html'>Today I made my first significant contribution to &lt;a href="http://clang.llvm.org"&gt;clang&lt;/a&gt;, by fixing &lt;a href="http://llvm.org/bugs/show_bug.cgi?id=8007"&gt;PR8007&lt;/a&gt;, which was a showstopper for building the codebase that I develop at my workplace. I added a testcase that validates the fix, too. In a nutshell, everything compiled well, but failed to link because of a non-instantiated type-dependent friend function.&lt;div&gt;&lt;br /&gt;&lt;div&gt;Admittedly, I am a green-horned newbie when it comes to clang, but even so I succeeded debugging the problem with some hints from Doug Gregor (on &lt;a href="irc://irc.oftc.net/llvm"&gt;IRC&lt;/a&gt;) in two hours. The fix arrived on short order after the conception of the solution idea.&lt;div&gt;&lt;br /&gt;&lt;div&gt;That I could get this working in a few hours is an astonishing feat (that I am pretty proud of) and a tell-tale aspect of clang's awesome design. Naturally, I still have to survive post-commit review, especially w.r.t. performance regressions; OTOH I am rather confident that I got the semantics right. Some loose ends in testing remain, which I hope to wrap up this weekend, so that I can see my application linking with clang (LLVM) on monday. That will burst up the doors towards &lt;a href="http://clang-analyzer.llvm.org/"&gt;static analysis&lt;/a&gt;...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Go CLANG!&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;PS: Hopefully I won't need &lt;i&gt;months&lt;/i&gt; to make &lt;a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38392"&gt;this&lt;/a&gt; working ;-)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3281478009903682914?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3281478009903682914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3281478009903682914' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3281478009903682914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3281478009903682914'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/08/link-as-link-can.html' title='Link as link can'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6520438082717770122</id><published>2010-07-21T15:00:00.000-07:00</published><updated>2010-07-21T16:54:10.066-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='waymarking'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>64-bit Waymarking</title><content type='html'>Finally I came around working on the 64bit variant of my (array) waymarking algorithm, the result of which can be observer &lt;a href="https://svn.berlios.de/viewvc/al4nin/trunk/purgatory/GetUser.lhs?revision=835&amp;amp;view=markup"&gt;here&lt;/a&gt; (starting at line 77). But I'd like to provide some background first.&lt;div&gt;Back when I implemented the original waymarking algorithm with a 2-bit alphabet used as the marks, I hoped that extending the alphabet to have 3 bits could be a major win. 64-bit pointers are by ABI rules aligned on an eight byte boundary, so pointers to these have their 3 lowest bits cleared, and I can use this space for jotting down the marks. With eight letters I can fully encode four digits and the two stops. This almost halves the number of accesses. The big question is how to assign a lucrative rôle to the remaining two characters! After some thinking I settled with the idea to make them &lt;i&gt;valued&lt;/i&gt; stops. Clearly, increasing the frequency of stops reduces the chance of long linear searches. In the current incarnation 'x' carries a value of (binary) 01 at the &lt;i&gt;start and at the end&lt;/i&gt; of a digit sequence, while 'y' carries 02 in the start rôle only. 's' is not carrying any value and is used when neither of the others fit. Since "s0" is a silly fragment to create, so I assign a special meaning of "s10" to it.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I designed the decoder (d3code) first. It is essential that it obtains the correct length for the string tail wherever it starts out. And it should minimize the number of accesses to characters in the string. The decoding rules are taylored to only need maximally 4 accesses to compute the correct length for the last 12 characters. Actually the last couple of marks were a result of a co-evolution with the decoder's rules. In the front of this part the digit sequences become longer and there is less wiggle room, this part can be automatically generated.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The code as it is now needs some serious cleanup, but it does QuickCheck and I am pretty confident that it is correct for all lengths. Of course you are encouraged to find a better scheme, but so far I am happy with it.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;PS: As I wrote this I discovered that I can eliminate another 2 characters of my hand-written seed string.&lt;/div&gt;&lt;div&gt;PPS: I do not employ the &lt;i&gt;'x' terminates with a value&lt;/i&gt; rule in the generator yet, only in the hand-written seed. But it should be easy enough to change every "3sx" to "x" in the generator.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6520438082717770122?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6520438082717770122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6520438082717770122' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6520438082717770122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6520438082717770122'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/07/64-bit-waymarking.html' title='64-bit Waymarking'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-910319422886762529</id><published>2010-07-14T16:12:00.000-07:00</published><updated>2010-07-14T16:31:42.391-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><category scheme='http://www.blogger.com/atom/ns#' term='bsd'/><title type='text'>The Proof is in the Pudding</title><content type='html'>Looks like I've finally done it! &lt;a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20100712/104198.html"&gt;r108240&lt;/a&gt; stuck and no broken external projects have been reported. I've prepared some little &lt;a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20100712/104256.html"&gt;statistic&lt;/a&gt; and quietly celebrating the 1%+ speed gain of LLVM in the last week.&lt;div&gt;Now on, plucking some more low-hanging fruit before adventuring into some more hard-core changes!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Update: The &lt;a href="http://www.listware.net/201007/freebsd-current/49889-testing-updated-clangllvm-needs-testing-in-clangbsd.html"&gt;ClangBSD&lt;/a&gt; project will surely put it through some serious regression testing...&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-910319422886762529?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/910319422886762529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=910319422886762529' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/910319422886762529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/910319422886762529'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/07/proof-is-in-pudding.html' title='The Proof is in the Pudding'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8654617609859570004</id><published>2010-06-24T07:55:00.000-07:00</published><updated>2010-06-24T08:17:22.020-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Emacs the Lifesaver</title><content type='html'>I was not thrilled of the task in front of me. Refreshing an old mega-patch, revise virtually every hunk to use a different interface, and committing it piecemeal to the repository again. Sounds like a long error prone job of suffering.&lt;br /&gt;&lt;br /&gt;Fortunately here is where the power tools come in. I&lt;br /&gt;&lt;ol&gt;&lt;li&gt;re-merged the backed out revision, postponing conflicts;&lt;/li&gt;&lt;li&gt;saved the diff away and reverted the repository;&lt;/li&gt;&lt;li&gt;wrote a small &lt;span style="font-family: courier new;"&gt;awk&lt;/span&gt; script to massage the hunks in the diff to get a new patch;&lt;/li&gt;&lt;li&gt;fired up &lt;span style="font-family: courier new;"&gt;emacs&lt;/span&gt; with the patch and applied each hunk after thorough review (and seldom with minor changes);&lt;/li&gt;&lt;li&gt;some hunks are not ready to go in yet as they do not qualify as refactoring, these are kept for later;&lt;/li&gt;&lt;li&gt;commit almost every file as a separate revision.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;I spend the most time in Emacs (the Mac OS X incarnation, &lt;a href="http://aquamacs.org/"&gt;Aquamacs&lt;/a&gt; is fantastic). It provides me all the comfort and productivity I need:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;it provides all necessary hunk operations such as apply, reverse, go to original, drop etc.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;I can transparently work from a remote machine via ssh, including editing, version control and the above diff operations&lt;/li&gt;&lt;li&gt;peace of mind, by being rock solid and autosaving stuff.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;The only inconvenience is the sheer amount of keyboard equivalents, but I am getting used to them too.&lt;br /&gt;&lt;br /&gt;Thanks Emacs, without you I would probably drop!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8654617609859570004?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8654617609859570004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8654617609859570004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8654617609859570004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8654617609859570004'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/06/emacs-lifesaver.html' title='Emacs the Lifesaver'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8205858033239821003</id><published>2010-06-22T17:24:00.000-07:00</published><updated>2010-06-22T17:34:38.806-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='filesystem'/><category scheme='http://www.blogger.com/atom/ns#' term='iso'/><title type='text'>Burning ISO CDs</title><content type='html'>I wasted some hours with trying to burn ISO CDs on the mac.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I tried various methods like converting .dmg to .cdr (CD Master) in Disk Utility, but the resulting CD always mounted as HFS+.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally I googled a nice method:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;hdiutil makehybrid -iso -o MyImage.iso /Volumes/SomeFolder/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;will create an ISO filesystem, which can be burnt with Disk Utility and shows up like that in the Finder. That is - well, I am pretty sure - readable on PCs.&lt;/div&gt;&lt;div&gt;Alternatively I may use&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new', serif; "&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new', serif; "&gt;hdiutil burn MyImage.iso&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;I believe...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In retrospect, some of my burn products may have ended up as PC-readable too, since hybrid filesystems may have been created. I'll test them on a PC tomorrow for sure.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8205858033239821003?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8205858033239821003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8205858033239821003' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8205858033239821003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8205858033239821003'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/06/burning-iso-cds.html' title='Burning ISO CDs'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-186731856491564566</id><published>2010-06-18T12:01:00.000-07:00</published><updated>2010-06-19T17:28:08.345-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='termination'/><category scheme='http://www.blogger.com/atom/ns#' term='types'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Sized types</title><content type='html'>I have always liked the idea of assigning some notion of size to (tree-like) values, and track its changes along pattern matching and construction to be able to reason about termination-unaffecting recursive calls.&lt;div&gt;&lt;br /&gt;&lt;div&gt;Many years ago, when reading the Hughes-Pareto-Sabry paper I did not see the point yet why termination is fundamental in various aspects.&lt;/div&gt;&lt;div&gt;Only when sitting on the park bench on the isle of Margitsziget (Budapest) and discussing with Tim about sound logic in Ωmega, it dawned to me how termination checking with sized types can be exploited.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I developed the intuition of the tree-like data floating heads down in the water and we are reasoning about criteria that it can still float without touching the ground at depth &lt;i&gt;n&lt;/i&gt;. Still, this metaphor was rather hazy.&lt;/div&gt;&lt;div&gt;In the meantime I have tried to digest the relevant papers from Barthe and Abel, brainstormed somewhat &lt;a href="http://code.google.com/p/omega/wiki/Epiphany"&gt;here&lt;/a&gt; and let my brain background.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Yesterday, I found (on reddit) a link to Abel's new &lt;a href="http://www2.tcs.ifi.lmu.de/~abel/par10.pdf"&gt;MiniAgda implementation&lt;/a&gt; and its description. It made clear to me that my early intuition was not bad at all, the water depth is the upper limit of the size, and recursion is to reduce this to obtain a well-founded induction.&lt;/div&gt;&lt;div&gt;Now it is time to rethink my ideas about infinite function types and how they can be reconciled with sized types.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But it looks like Abel has done the hard work and his Haskell implementation of MiniAgda could be married with Ωmega in the following way: Derive a sized variant of every (suitable) Ωmega datatype and try to check which functions on them terminate. These can be used as theorems in Ωmega.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hopefully Tim is paying attention to this when implementing Trellys...&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-186731856491564566?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/186731856491564566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=186731856491564566' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/186731856491564566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/186731856491564566'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/06/sized-types.html' title='Sized types'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-88266675511470107</id><published>2010-06-08T03:23:00.000-07:00</published><updated>2010-06-14T08:35:55.182-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>My grief with out-of-tree code</title><content type='html'>This post is a long-standing &lt;span style="font-style: italic;"&gt;todo &lt;/span&gt;item  in my brain, but this &lt;a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20100607/102274.html"&gt;checkin&lt;/a&gt;  actually prompted me to do it.&lt;br /&gt;&lt;br /&gt;A little bit of history first.  As a software developer currently mostly active in the embedded space, I  like solutions which allow me to save some CPU cycles or bytes of RAM  here and there as long as they still allow me to use the same  interfaces. Exploiting the characteristics of the underlying hardware  and algorithms is often low-hanging fruit when it comes to  optimizations.&lt;br /&gt;So I have this little agenda of about 10 items I wish  to implement in the future to make the LLVM framework a little more  efficient.&lt;br /&gt;&lt;br /&gt;One of these was to reorder the operands inside of the &lt;span style="font-style: italic;"&gt;call&lt;/span&gt; instruction, to obtain faster  access to the callee but mainly to allow fast visitation of all  instructions that have a certain callee. I explained all my motives in a  &lt;a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20100412/099690.html"&gt;separate mail&lt;/a&gt;, so I want to save you from the gory details here. To make a long story short, it took me several  iterations to catch all places in the optimizers where the operand order  was assumed to be in the (callee, arg1, arg2, ...) fashion, instead of  the new (arg1, arg2, ..., callee) one, and some miscompilations were  only revealed by running the nightly tests. It was a work of blood and sweat because there are many intrinsics and transformations on them and they are often manipulating via the low-level interface &lt;span style="font-family:courier new;"&gt;getOperand(n)&lt;/span&gt;. Actually there is a nice helper interface, called &lt;span style="font-family:courier new;"&gt;CallSite&lt;/span&gt;, which makes it easy to access the call instruction's arguments in a high-level fashion and this interface probably the best for LLVM clients, since its also handles the &lt;span style="font-style: italic;"&gt;invoke&lt;/span&gt; instructions. However, I regard it &lt;span style="font-style: italic;"&gt;ok&lt;/span&gt; to use the low-level interface in the LLVM tree directly, since it is possible to consistently change things in one atomic commit.&lt;br /&gt;Finally, the day where all regression and nightly tests succeeded, has dawned. My patch seemingly stuck, with all buildbots green. I left for downtown and returned late at night. Just to discover that all has been backed out, because my change broke havoc in an Apple project that obviously used the low-level interface. This was especially frustrating, since I cannot even submit a correcting patch against that project.&lt;br /&gt;&lt;br /&gt;I did receive  very little encouraging support, not even moral one. Some comments were  even pretty dismissive, like &lt;span style="font-style: italic;"&gt;this patch has already caused many  problems, it is not worth it for such a marginal gain&lt;/span&gt;. I have no  problem with the comment itself, since I would utter such words in  comparable situations too, but this time it was my &lt;span style="font-style: italic;"&gt;investment&lt;/span&gt; that was at stake. I was  pretty determined to keep fighting.&lt;br /&gt;&lt;br /&gt;I wondered whether new measurements with higher arity calls would find a significant  speedup with my patch applied. So I did some &lt;a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20100419/100216.html"&gt;benchmarking&lt;/a&gt; for cases where the change is expected to make a difference, and actually found (roughly) a 3% speedup. Clearly this number is only achieved in specific situations, so the generic case would be well below that, but still it could compensate for many little time eaters that are necessary for an advanced optimization pass or analysis.&lt;br /&gt;&lt;br /&gt;In my conversation with the  involved engineer I enumerated following reasons why resorting to low-level interface in out-of-tree projects is a bad idea:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;they are not  conveying the intent&lt;/li&gt;&lt;li&gt;they are depending on implementation details by reaching  over abstraction barriers&lt;/li&gt;&lt;li&gt;they are an impediment to change&lt;/li&gt;&lt;/ul&gt;(these are mostly the same reasons  which you can find in the above commit message too). He did agree to all this and promised to nudge the OpenGL implementors. I also received a request to submit a patch that guarantees that no silent  breakage can happen. Well, I acknowledged that this is a valid concern, so I did some brainstorming.&lt;br /&gt;&lt;br /&gt;I succeeded to put together a small patch that detected all instances of &lt;span style="font-family:courier new;"&gt;get/setOperand(0)&lt;/span&gt;, the major potential cause of breakage in external projects. Compiling with this patch would pinpoint all places where &lt;span style="font-family:courier new;"&gt;getCalledValue()&lt;/span&gt; should be used.&lt;br /&gt;&lt;br /&gt;But I cannot &lt;span style="font-style: italic;"&gt;promise&lt;/span&gt; more than that!&lt;br /&gt;&lt;br /&gt;Why it is  impossible to guarantee that with my proposed change either everything  keeps working or there is a compilation error with a clear fixing  indication? Because the &lt;span style="font-family:courier new;"&gt;User&lt;/span&gt; baseclass does provide the low-level &lt;span style="font-family:courier new;"&gt;getOperand&lt;/span&gt; interface too and I cannot disallow that. C++ only lets me protect parts of the &lt;span style="font-family:courier new;"&gt;CallInst&lt;/span&gt; class...&lt;br /&gt;Would a patch to make &lt;span style="font-family: courier new;"&gt;getOperand&lt;/span&gt; private in &lt;span style="font-family: courier new;"&gt;CallInst&lt;/span&gt; be accepted? Probably not now, but read on.&lt;br /&gt;&lt;br /&gt;What aggravates the problem with private trees is file ownership. The engineer who detects the breakage is not entitled to fix simple cases, but needs to lobby the project/file owner first. This results in additional inertia. (Disclaimer: I am not sure whether Apple does have a file-ownership model internally.)&lt;br /&gt;&lt;br /&gt;Surprisingly the same thing that happened to me theoretically could  happen to any Apple engineer too. Imagine some checkin to LLVM broke the  &lt;a href="http://dragonegg.llvm.org/"&gt;dragonegg&lt;/a&gt; GCC plugin which is effectively licensed as GPLv3, so no  Apple engineer is allowed to inspect its sources. What would happen if  the dragonegg maintainer backed out the change on grounds of "broke an  important external project"?&lt;br /&gt;&lt;br /&gt;What to do next? Now, whining is not one of the things I like to do, so let's advance in some way. Bill's patch I mentioned in the beginning is a possible first step, as I could rework a large portion of my patch in terms of &lt;span style="font-family:courier new;"&gt;getArgOperand(n-1)&lt;/span&gt; instead of &lt;span style="font-family:courier new;"&gt;getOperand(n-1)&lt;/span&gt;, without actually changing the operand order for now. These kinds of incremental refactorings that do not change functionality are mostly welcome in the LLVM world. Then I am dependent on the goodwill of some Apple engineer to make a similar change in that internal project too. Finally the switch (i.e. the operand order) could be flipped.&lt;br /&gt;&lt;br /&gt;Why I am reluctant to begin? Because it is lots of work, many new intrinsics have been introduced, I definitely will get a bunch of merge conflicts, and finally, who knows, there might be another internal project that chokes and the whole misery enters a new iteration.&lt;br /&gt;&lt;br /&gt;Why do I feel that the change is urgent? Because LLVM is getting popular with an extraordinal speed. As more and more external projects use LLVM as a foundation, more and more code will exhibit bad habits of using low-level interfaces. The few post-v2.7 months are probably the last chance to make the  switch in argument order, before things become de-facto cemented. Maybe it is too late already. That would be a pity, though, LLVM as a compilation infrastructure should be as fast and nimble as possible. Every one of its clients would profit.&lt;br /&gt;&lt;br /&gt;So, dear external tree developers, I hope you get rid of the low-level calls and use the high-level ones instead. It should not cost you more than touching a couple of lines and retesting. I would be happy to assist you.&lt;br /&gt;&lt;br /&gt;Regarding development policy, I would welcome a clear statement about what amount of testing in the LLVM ecosystem is "sufficient" and excludes the risk of a patch being backed out.&lt;br /&gt;&lt;br /&gt;Bottom line, I'd love to get this patch wrapped up, but I am dependent on the support of external tree owners. Are you willing to help me?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-88266675511470107?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/88266675511470107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=88266675511470107' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/88266675511470107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/88266675511470107'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2010/06/my-grief-with-out-of-tree-code.html' title='My grief with out-of-tree code'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5054313480391843688</id><published>2009-11-25T14:45:00.000-08:00</published><updated>2009-11-25T14:55:45.346-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='family'/><title type='text'>Patrícia's New Hobby</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_zTrNxPJ0xW0/Sw21s7pLiXI/AAAAAAAAAC8/5NmphSC6jgY/s1600/LeleWithLala.jpeg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 250px;" src="http://2.bp.blogspot.com/_zTrNxPJ0xW0/Sw21s7pLiXI/AAAAAAAAAC8/5NmphSC6jgY/s320/LeleWithLala.jpeg" alt="" id="BLOGGER_PHOTO_ID_5408178511071119730" border="0" /&gt;&lt;/a&gt;The artistic blood of my lovely wife is flowing again :-)&lt;br /&gt;&lt;br /&gt;Her newest hobby is orchestrating photo-shootings. Predominantly of pregnant friends and everybody who simply wants to feel marvelous...&lt;br /&gt;Like Lelêca!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5054313480391843688?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5054313480391843688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5054313480391843688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5054313480391843688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5054313480391843688'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/11/patricias-new-hobby.html' title='Patrícia&apos;s New Hobby'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_zTrNxPJ0xW0/Sw21s7pLiXI/AAAAAAAAAC8/5NmphSC6jgY/s72-c/LeleWithLala.jpeg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6544572148992997956</id><published>2009-11-02T15:47:00.000-08:00</published><updated>2009-11-03T04:23:35.142-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='family'/><title type='text'>Freude, die man sieht</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zTrNxPJ0xW0/Su9yUqlBIpI/AAAAAAAAAC0/lY_j7QQNS8o/s1600-h/DieDrei.jpeg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_zTrNxPJ0xW0/Su9yUqlBIpI/AAAAAAAAAC0/lY_j7QQNS8o/s320/DieDrei.jpeg" alt="" id="BLOGGER_PHOTO_ID_5399660177593016978" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Dieses Photo zeigt Lelêca (alias MausiMausi, alias SchlausiMausi) in mit einem Kopfschmuck, der eigentlich zur &lt;a href="http://de.wikipedia.org/wiki/Pernambuco"&gt;pernambucanischen&lt;/a&gt; Tracht gehört. Ein Geschenk von Tio Davis – Danke!&lt;br /&gt;Lelê freut sich inzwischen auf den morgentlichen Gang in den Kindergarten (natürlich mit Papa!) und scheut sich auch nicht vor kleineren Wortgefechten ("vai comer não!"). Aber was richtig gut ist heißt dann "muito ótimo" und Akzeptanz wird mit einem klaren "tá certo!" signalisiert. Und wie man sieht, geht es den Jungs auch ganz passabel...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6544572148992997956?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6544572148992997956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6544572148992997956' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6544572148992997956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6544572148992997956'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/11/freude-die-man-sieht.html' title='Freude, die man sieht'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_zTrNxPJ0xW0/Su9yUqlBIpI/AAAAAAAAAC0/lY_j7QQNS8o/s72-c/DieDrei.jpeg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-2899078625239690155</id><published>2009-10-01T14:37:00.000-07:00</published><updated>2009-10-01T14:54:28.549-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><title type='text'>New Thrist Cabbage</title><content type='html'>Yeah, it took more than a year (and dcoutts help on IRC), but finally I've gathered all my &lt;a href="http://hackage.haskell.org/package/thrist"&gt;hackage-foo&lt;/a&gt; to submit a new &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;thrist&lt;/span&gt; package (v1.1.1). Its main purpose is to require &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;base&lt;/span&gt; v4.0 or higher. As an added bonus &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;(Thrist p)&lt;/span&gt; now provides a &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Category&lt;/span&gt; instance. I have also added an &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Arrow (Thrist (-&gt;))&lt;/span&gt; instance, but its &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;first&lt;/span&gt; method is bogus as of now. I plan to correct this with v1.1.2.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My plans for 0.2 are:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;adaptors &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Data.Thrist.Monad&lt;/span&gt;, &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Data.Thrist.List&lt;/span&gt; (aka. R*), &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Data.Thrist.Arrow&lt;/span&gt;, all with their respective sensible class instances,&lt;/li&gt;&lt;li&gt;tests.&lt;/li&gt;&lt;/ul&gt;Then sometime I can start setting up some cool stuff to demonstrate hoare-triples in thrist setting.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We'll see.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-2899078625239690155?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/2899078625239690155/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=2899078625239690155' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2899078625239690155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2899078625239690155'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/10/new-thrist-cabbage.html' title='New Thrist Cabbage'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6684083410428304546</id><published>2009-08-04T15:52:00.000-07:00</published><updated>2009-08-04T16:21:16.448-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Static Constraints</title><content type='html'>In the last months Tim has been adding a new function &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;sameLabel&lt;/span&gt; to Ωmega and this finally allowed me to encode the concept of free variables. In just a couple of days I managed to implement environment construction with statically checked proof that no identifier is shadowed. &lt;a href="http://code.google.com/p/omega/source/browse/trunk/work/StaticFreeEnv.prg?spec=svn233&amp;amp;r=233"&gt;Here&lt;/a&gt; is a little example.&lt;div&gt;Building on this advance I fulfilled a long lasting desire and managed to prototype LLVM basic blocks in Ωmega with thrists. The approach is implemented in 2 steps:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;build up a labelled sequence of preinstructions, and then&lt;/li&gt;&lt;li&gt;construct sufficient evidence about well-formedness, that the strict type constraints in the thrist can be proven.&lt;/li&gt;&lt;/ul&gt;Curiously, the defs propagate to the right and the uses to the right in this thrist. The good thing is, that after all this struggle I am pretty confident that many more properties and constraints can be encoded, such as&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;the LLVM type system (on defs, uses and constants),&lt;/li&gt;&lt;li&gt;that Phi nodes must not go into entry blocks,&lt;/li&gt;&lt;li&gt;that Phi nodes must preceed other instructions in the basic block,&lt;/li&gt;&lt;li&gt;every use must happen in the scope of a corresponding def,&lt;/li&gt;&lt;li&gt;etc.&lt;/li&gt;&lt;/ol&gt;The next days will surely see more progress, I have crawled out of the swamp and have firm ground under my feet...&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6684083410428304546?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6684083410428304546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6684083410428304546' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6684083410428304546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6684083410428304546'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/08/static-constraints.html' title='Static Constraints'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-4200851678957199172</id><published>2009-06-14T14:56:00.000-07:00</published><updated>2009-12-04T11:27:33.184-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='family'/><title type='text'>Daddy's Girl</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zTrNxPJ0xW0/SjVzWvpP8SI/AAAAAAAAAB8/1gESWqgo6Es/s1600-h/Unknown.jpeg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_zTrNxPJ0xW0/SjVzWvpP8SI/AAAAAAAAAB8/1gESWqgo6Es/s320/Unknown.jpeg" alt="" id="BLOGGER_PHOTO_ID_5347306967156125986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Das Bild zeigt die Ruhe vor dem Sturm. Wenige Minuten später ist Leleka in ihren Festanzug geschlüpft und die Party ging los, mit Geschenken und viel Leckerem. Spruch der letzten Woche: &lt;blockquote&gt;"Aniversário de Lelêca no domingo!"&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-4200851678957199172?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/4200851678957199172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=4200851678957199172' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4200851678957199172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4200851678957199172'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/06/daddys-girl.html' title='Daddy&apos;s Girl'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_zTrNxPJ0xW0/SjVzWvpP8SI/AAAAAAAAAB8/1gESWqgo6Es/s72-c/Unknown.jpeg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-9166541890557129000</id><published>2009-05-27T06:43:00.000-07:00</published><updated>2009-05-27T07:08:23.079-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><title type='text'>Ketchup Problem</title><content type='html'>In &lt;a href="http://sneezy.cs.nott.ac.uk/fun/feb-07/jeremy-slides.pdf"&gt;Chapter 6&lt;/a&gt; (page 16) Jeremy Gibbons describes a datatype that models all secure operations that can be applied to a (partially filled) &lt;span style="font-style: italic;"&gt;ketchup bottle&lt;/span&gt;. I believe that this is the example that Jeremy has shown me at ICFP'07 in Freiburg (when I have introduced him to my thrist concept), and I have been unable to find it ever since. Now, I guess I can add it to the bibliography section of my paper. That is, if I ever get around updating the draft again...&lt;br /&gt;&lt;br /&gt;PS: a bibtex-able conference paper is &lt;a href="http://web.comlab.ox.ac.uk/jeremy.gibbons/publications/bib.html#gip"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-9166541890557129000?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/9166541890557129000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=9166541890557129000' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/9166541890557129000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/9166541890557129000'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/05/ketchup-problem.html' title='Ketchup Problem'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5587058973840651685</id><published>2009-03-31T22:15:00.000-07:00</published><updated>2009-03-31T22:23:38.069-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='weather'/><category scheme='http://www.blogger.com/atom/ns#' term='family'/><category scheme='http://www.blogger.com/atom/ns#' term='garden'/><title type='text'>Sieben Tage Regen, Sieben Tage Schnee …</title><content type='html'>… und es tut nicht mehr weh!&lt;br /&gt;&lt;br /&gt;Dieser Winter war der schmerzhafteste den ich bisher in Deutschland erlebt habe. Lang und kalt. Die Natur ist acht Wochen (oder mehr?) hinterher, unser Hunger nach Sonne unvorstellbar.&lt;br /&gt;&lt;br /&gt;Wie gut, daß mein Wetter-Widget jetzt sieben Tage Sonne und angenehme Temperaturen verspricht! Das Haus ist nunmehr tiptop eingerichtet, die Gartensaison kann kommen.&lt;br /&gt;&lt;br /&gt;Auf wiedersehen, Winter, willkommen Frühling!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5587058973840651685?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5587058973840651685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5587058973840651685' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5587058973840651685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5587058973840651685'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/03/sieben-tage-regen-sieben-tage-schnee.html' title='Sieben Tage Regen, Sieben Tage Schnee …'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-664888211055676296</id><published>2009-03-21T15:04:00.000-07:00</published><updated>2009-03-21T15:37:04.625-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='clang'/><category scheme='http://www.blogger.com/atom/ns#' term='work'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Lack of Total Order</title><content type='html'>My new project is starting to bind my mental resources at work. So some of the fringe projects which I casually do for fun will surely suffer.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;LLVM: Two of my recent patches had to be backed out of the tree, because they caused trouble with bootstrapping llvm-gcc. I am pretty sure these are not caused by bugs on my side (geee!), but frustrating nevertheless. The situation is also aggravated by the fact that I am unable to build a stock llvm-gcc on my Tiger machines I have access to, so I have lost my ability to debug these beasts. A third patch is in-progress (CallInst operand reorg - function to the back) but it is dependent on one of the backed-out ones. It is also pretty stubborn, since there are many hidden assumptions in the codebase which expect the callee in front position. I am slowly weeding out the problems.&lt;/li&gt;&lt;li&gt;Omega: Little progress on this front. Tim also seems to have reduced his workload on here - probably caused by the "Cyber Milennium" course - so I do not feel a lot of motivation. Which is sad, because there are some nice papers on GADT decidable type inference appearing. Omega could benefit from those.&lt;/li&gt;&lt;li&gt;Clang: Doug has been working on the template instantiation machinery lately, and I took over a mini-project: instantiation of "?:" expressions. It mostly works, but there is still review feedback to satisfy and the missing middle-expression problem needs a solution. These must be unit-tested as well.&lt;/li&gt;&lt;/ul&gt;Back to my regular work. The job is demanding, I co-develop the implementation, test framework and test-suite simultaneously. Of course I could accept some help, but it is also important that the basics get in right and unwatered. I have a nice plan for stub-libraries that can invoke TCL commands to fill in out parameters and result values. Fun.&lt;br /&gt;&lt;br /&gt;Regarding the headline, it was inspired by thinking about a purely-functional (i.e. immutable) lattice library for use by Clang's (partial) template specialization feature. Yes, and lattices arise as containers of partially-ordered data.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-664888211055676296?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/664888211055676296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=664888211055676296' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/664888211055676296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/664888211055676296'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/03/lack-of-total-order.html' title='Lack of Total Order'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1258604119414291321</id><published>2009-03-11T05:05:00.000-07:00</published><updated>2009-03-11T05:11:35.263-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='work'/><title type='text'>RWH</title><content type='html'>I am happy because my copy of &lt;a href="http://www.realworldhaskell.org"&gt;Real World Haskell&lt;/a&gt; arrived today. I ordered it through my employer, and while waiting for it more than two months, it finally got delivered. Anyway, I plan to put &lt;a href="http://www.cs.chalmers.se/~rjmh/QuickCheck/"&gt;QuickCheck&lt;/a&gt; to good use by generating testcases automatically. Let's see how far this can carry us.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1258604119414291321?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1258604119414291321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1258604119414291321' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1258604119414291321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1258604119414291321'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/03/rwh.html' title='RWH'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-2865583624236127089</id><published>2009-03-03T14:55:00.000-08:00</published><updated>2009-03-03T14:59:28.578-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='good'/><category scheme='http://www.blogger.com/atom/ns#' term='GADT'/><title type='text'>3^2 Day</title><content type='html'>Today is 3^2 day, because 3 squared is 9 and today's date is 03.03.09. Number jokes aside, it was a good day, I am finally beginning the implementation part of my new project at work and the ideas keep sprouting.&lt;br /&gt;&lt;br /&gt;Good.&lt;br /&gt;&lt;br /&gt;PS.: Also I found a nice article about decidable type inference for GADTs. Final version hopefully for ICFP09!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-2865583624236127089?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/2865583624236127089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=2865583624236127089' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2865583624236127089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2865583624236127089'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/03/32-day.html' title='3^2 Day'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5857660606450749431</id><published>2009-01-30T16:27:00.000-08:00</published><updated>2009-01-30T16:36:02.790-08:00</updated><title type='text'>Verhörhämmer</title><content type='html'>Um ein Paar dieser "rohen Diamanten" zu downloaden, habe ich dieses kleine &lt;tt&gt;tcsh&lt;/tt&gt; script geschrieben:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;foreach j ( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 )&lt;br /&gt;  foreach i ( `curl "http://blog.br-online.de/fruehaufdreher/index.php?/categories/2-Verhoerhammer/P"$j".html" | grep .mp3 | grep value= | grep song_title= | awk -F= '{print $4}' | awk -F"&amp;" '{print $1}' | awk -F/ '{print $6}' ` )&lt;br /&gt;    echo $j : $i&lt;br /&gt;    curl http://blog.br-online.de/fruehaufdreher/uploads/$i &amp;gt; $i&lt;br /&gt;  end&lt;br /&gt;end&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Macht Spaß... Danke BR!&lt;br /&gt;&lt;br /&gt;:-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5857660606450749431?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5857660606450749431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5857660606450749431' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5857660606450749431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5857660606450749431'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/01/verhorhammer.html' title='Verhörhämmer'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-4749061610026393008</id><published>2009-01-28T15:27:00.000-08:00</published><updated>2009-01-28T23:27:16.191-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='family'/><title type='text'>Dan's Birthday</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zTrNxPJ0xW0/SYDtLZlJIVI/AAAAAAAAAB0/PqHXpl2QZuY/s1600-h/Helena-cantando.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 237px; height: 320px;" src="http://1.bp.blogspot.com/_zTrNxPJ0xW0/SYDtLZlJIVI/AAAAAAAAAB0/PqHXpl2QZuY/s320/Helena-cantando.jpg" alt="" id="BLOGGER_PHOTO_ID_5296493941888721234" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Yesterday was Daniel's birthday. We made a surprise visit and he loved it! I came a bit late (work, work, new project, yadda), which was no problem because people had lots of fun. They fired up the karaoke machine, and after some beers even I took the mike. But Helena on stage was the cutest thing ever! She grabbed the microphone as if she was a seasoned singer. However she did not sing a single tune, just posed :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-4749061610026393008?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/4749061610026393008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=4749061610026393008' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4749061610026393008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4749061610026393008'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2009/01/dans-birthday.html' title='Dan&apos;s Birthday'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_zTrNxPJ0xW0/SYDtLZlJIVI/AAAAAAAAAB0/PqHXpl2QZuY/s72-c/Helena-cantando.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3737250393175330141</id><published>2008-10-09T09:30:00.000-07:00</published><updated>2008-10-09T09:34:44.415-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='house'/><category scheme='http://www.blogger.com/atom/ns#' term='family'/><title type='text'>Hauskauf</title><content type='html'>Heute war doch ein recht spezieller Tag. Notartermin zwecks Vertragsunterzeichnung. Ich kann nur sagen daß mein Herz doch ziemlich in die Hose geruscht ist...&lt;br /&gt;...noch nie habe ich so eine Menge Geld auf eine Karte gesetzt. Als nächstes nun wird bezahlt und dann beginnt der lange, schweißtreibende Weg zur Tilgung. Darüber später mehr.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3737250393175330141?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3737250393175330141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3737250393175330141' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3737250393175330141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3737250393175330141'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/10/hauskauf.html' title='Hauskauf'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8191747425391497308</id><published>2008-09-10T12:54:00.000-07:00</published><updated>2008-09-10T14:28:42.073-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hoare-triple'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Hoare Triples and Thrists</title><content type='html'>While mousing through the &lt;a href="http://www.galois.com/%7Edons/slides/08-08-sewell.pdf"&gt;L4.verified&lt;/a&gt; presentation that took place at &lt;a href="http://www.galois.com/"&gt;Galois&lt;/a&gt;, I could not help but build an association bridge between &lt;a href="http://en.wikipedia.org/wiki/Hoare_logic"&gt;Hoare triples&lt;/a&gt; and thrists. Especially when you go to p. 52 and thereabout.&lt;br /&gt;Here is my take on the connection:&lt;br /&gt;&lt;br /&gt;We have some &lt;span&gt;&lt;span style="font-style: italic;"&gt;command&lt;/span&gt;s&lt;/span&gt; that belong to a data type &lt;span style="font-family:courier new;"&gt;C&lt;/span&gt;, and &lt;span style="font-family:courier new;"&gt;C&lt;/span&gt; has two type parameters:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;data C :: * -&gt; * -&gt; * where&lt;br /&gt;  C1 :: ... -&gt; C a b&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;The first type parameter can be interpreted as the &lt;span style="font-style: italic;"&gt;precondition&lt;/span&gt; of the command while the second as its &lt;span style="font-style: italic;"&gt;postcondition&lt;/span&gt; ({P} and {Q} in Hoare's notation). This convention employs the &lt;span style="font-style: italic;"&gt;types-as-properties&lt;/span&gt; interpretation.&lt;br /&gt;If commands are sequenced, the postconditions of the former commands must imply the preconditions of the latter. This is referred to as the &lt;span style="font-style: italic;"&gt;composition rule&lt;/span&gt; and corresponds to appending two thrists.&lt;br /&gt;&lt;br /&gt;Now, in Ωmega the situation is even prettier, because &lt;span style="font-family:courier new;"&gt;C&lt;/span&gt; need not be a two-type-parameter entity, but can be parameterized over arbitrary &lt;span style="font-style: italic;"&gt;kind&lt;/span&gt;s. The built-in evaluation mechanism (type functions) allow the most powerful constructs. (Haskell will get something similar at the type level, called &lt;span style="font-style: italic;"&gt;type families&lt;/span&gt;, with GHC v6.10.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8191747425391497308?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8191747425391497308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8191747425391497308' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8191747425391497308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8191747425391497308'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/09/hoare-triples-and-thrists.html' title='Hoare Triples and Thrists'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3269746425215922074</id><published>2008-09-03T12:22:00.000-07:00</published><updated>2008-09-03T13:00:18.324-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='family'/><title type='text'>Saudades</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_zTrNxPJ0xW0/SL7lu_MAI7I/AAAAAAAAABU/Ky9uej058Uo/s1600-h/Familie.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 290px; height: 194px;" src="http://4.bp.blogspot.com/_zTrNxPJ0xW0/SL7lu_MAI7I/AAAAAAAAABU/Ky9uej058Uo/s320/Familie.jpg" alt="" id="BLOGGER_PHOTO_ID_5241879611704353714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;É muito bom ficar sozinho alguns dias, pensando e trabalhando em paz. Mas quando as semanas passam a distância parece que aumenta e a ausência começa de doer.&lt;br /&gt;&lt;br /&gt;Meus amores sinto muito falta de voces, quero que voltam logo.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3269746425215922074?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3269746425215922074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3269746425215922074' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3269746425215922074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3269746425215922074'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/09/saudades.html' title='Saudades'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_zTrNxPJ0xW0/SL7lu_MAI7I/AAAAAAAAABU/Ky9uej058Uo/s72-c/Familie.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1933102275531665032</id><published>2008-09-01T09:38:00.000-07:00</published><updated>2008-09-01T09:48:51.613-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='philosophy'/><category scheme='http://www.blogger.com/atom/ns#' term='evolution'/><title type='text'>Meme evolution</title><content type='html'>While I am missing family induced distraction, I use the opportunity of reading old papers that I always wanted to revisit.&lt;br /&gt;&lt;br /&gt;Yesterday, while reading &lt;a href="http://research.microsoft.com/%7Esimonpj/papers/history-of-haskell/index.htm"&gt;"A History of Haskell"&lt;/a&gt; I was amused by the sentence:&lt;br /&gt;&lt;blockquote&gt;"Wadler misunderstood what Fasel had in mind, and type &lt;a href="http://en.wikipedia.org/wiki/Type_classes"&gt;classes were&lt;/a&gt; born!"&lt;/blockquote&gt;This is a concrete case of "meme evolution" (in &lt;a href="http://richarddawkins.net/"&gt;Dawkins&lt;/a&gt;' sense): a mutation of a &lt;a href="http://en.wikipedia.org/wiki/Meme"&gt;meme&lt;/a&gt; (by transcription error) finds a new habitat where it thrives and blossoms.&lt;br /&gt;&lt;br /&gt;Some preconditions are needed for this to happen:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;communication&lt;/li&gt;&lt;li&gt;loosening of amorphous ideas&lt;/li&gt;&lt;li&gt;an open mind, not shying away from listening to the unknown&lt;/li&gt;&lt;/ul&gt;Many great ideas come to me while reading conference papers of others and where I have no idea what they are talking about :-) While trying to make vague sense of what I have in front of me a fireworks of ideas commence, all building in some way on foundations of things (pet projects) I have done in the past.&lt;br /&gt;&lt;br /&gt;Now, how can I ensure that I periodically can enjoy the state of minimal disturbances?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1933102275531665032?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1933102275531665032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1933102275531665032' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1933102275531665032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1933102275531665032'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/09/meme-evolution.html' title='Meme evolution'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1092249002480955789</id><published>2008-08-30T04:25:00.000-07:00</published><updated>2008-08-30T12:26:46.709-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='monads'/><category scheme='http://www.blogger.com/atom/ns#' term='crazy'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='generalization'/><title type='text'>Generalized Monads --&gt; Gonads :-)</title><content type='html'>Here is the usual (basic) definition of monads:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;class Monad m where&lt;br /&gt;  return :: a -&gt; m a&lt;br /&gt;  (&gt;&gt;=) :: m a -&gt; (a -&gt; m b) -&gt; m b&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;This is very much restricted to ordinary function types!&lt;br /&gt;Let's see how this restriction can be lifted...&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;class Category (~&gt;) =&gt; Geonad (g (~&gt;)) where&lt;br /&gt;  return :: a ~&gt; g (~&gt;) a&lt;br /&gt;  (&gt;&gt;=) :: g (~&gt;) a ~&gt; (a ~&gt; g (~&gt;) b) ~&gt; g (~&gt;) b&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;Since the semantics of gonads are already eminently taken, I settled for the name Geonad.&lt;br /&gt;&lt;br /&gt;No idea whether this can produce something relevant for our lives :-)&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Gabor&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1092249002480955789?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1092249002480955789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1092249002480955789' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1092249002480955789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1092249002480955789'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/08/here-is-usual-basic-definition-of.html' title='Generalized Monads --&gt; Gonads :-)'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8946139812256246487</id><published>2008-08-28T06:26:00.000-07:00</published><updated>2008-08-28T06:45:11.704-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='dylan'/><title type='text'>Category</title><content type='html'>With lots of rejoicing, today I discovered that the base-3.0 library, to be distributed with the upcoming &lt;a href="http://haskell.org/ghc/"&gt;GHC&lt;/a&gt; 6.10, will contain the &lt;a href="http://www.haskell.org/ghc/dist/current/docs/libraries/base/Control-Category.html"&gt;Control.Category&lt;/a&gt; type class. This is exactly what is needed to put &lt;span style="font-family: courier new;font-size:85%;" &gt;Thrist (~&gt;)&lt;/span&gt; into a general context!&lt;br /&gt;&lt;br /&gt;Can't wait till September...&lt;br /&gt;&lt;br /&gt;PS: It is also a nice surprise that &lt;a href="http://ashley.yakeley.org/"&gt;Ashley Yakeley&lt;/a&gt;, the maintainer of this module is an old-time Dylan person :-)&lt;br /&gt;Sometime I have to blog about the lots of developers who share a common Haskell/Dylan heritage.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8946139812256246487?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8946139812256246487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8946139812256246487' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8946139812256246487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8946139812256246487'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/08/category.html' title='Category'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1209739901335781173</id><published>2008-08-26T09:05:00.000-07:00</published><updated>2008-08-26T09:58:25.237-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><title type='text'>I'd like to see, but do you want to Show?</title><content type='html'>So, yesterday I tried to implement&lt;br /&gt;&lt;blockquote  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;instance Show (Thrist (a ~&gt; b)) where ...&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;... and ran against several walls. The short story is: Forget it!&lt;br /&gt;&lt;br /&gt;The long story comes next, if you are interested.&lt;br /&gt;&lt;br /&gt;First of all, what do we want? In my paper I define a nice thrist&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;&lt;blockquote&gt;[('A', 33), (65, 'a')]l :: Thrist (,) Char Char&lt;/blockquote&gt;&lt;/span&gt;and the &lt;a href="http://web.cecs.pdx.edu/%7Esheard/Omega/index.html"&gt;Ωmega&lt;/a&gt; interpreter readily prints it. I wanted to do the same in Haskell too, as a pretty extension of my &lt;a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/thrist"&gt;thrist&lt;/a&gt; package. I started like this:&lt;br /&gt;&lt;blockquote  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;instance Show (a ~&gt; b) =&gt; Show (Thrist (~&gt;) a b)&lt;br /&gt;show Nil = "[]l"&lt;/span&gt;&lt;/blockquote&gt;I even managed to show singleton thrists (which hold just one element).&lt;br /&gt;But the first obstacle was immediate: When the thrist has more than one element the hidden existential type appears, but the compiler does not know that this &lt;span style=";font-family:courier new;font-size:85%;"  &gt;(a ~&gt; x)&lt;/span&gt; has a &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Show&lt;/span&gt;&lt;/span&gt; instance!&lt;br /&gt;&lt;br /&gt;So I hoped to extend the context to require &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Show (forall a b . a ~&gt; b)&lt;/span&gt; that is I want all saturations of the type constructor &lt;span style=";font-family:courier new;font-size:85%;"  &gt;(~&gt;)&lt;/span&gt; to be &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Show&lt;/span&gt;able. But GHC does not like this syntax...&lt;br /&gt;&lt;br /&gt;At his point I started some fundamental thinking...&lt;br /&gt;&lt;br /&gt;Since the type of the thrist only reveals the beginning and the end, there may be arbitrary non-showable types hidden inside, even if the resulting type conveys the illusion of &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Show&lt;/span&gt;ability. To wit:&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;&lt;blockquote&gt;[(5, id), (id, 42)]l :: Thrist (,) Int Int&lt;/blockquote&gt;&lt;/span&gt;We can enter such a thing, but there is no hope to show it :-(&lt;br /&gt;&lt;br /&gt;So what are our remaining options? Ganesh has brought &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Show2&lt;/span&gt;&lt;/span&gt; to my attention, I might look at it soon, but it won't solve the above problem.&lt;br /&gt;&lt;br /&gt;We can say goodbye to &lt;span style=";font-family:courier new;font-size:85%;"  &gt;(,)&lt;/span&gt; and define something like:&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;&lt;blockquote&gt;newtype Pair a b = (Show a, Show b) =&gt; Pair (a, b)&lt;/blockquote&gt;&lt;/span&gt;There is some hope that &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Thrist Pair a b&lt;/span&gt;&lt;/span&gt; can be declared as a &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Show2&lt;/span&gt; instance.&lt;br /&gt;Who knows?&lt;br /&gt;&lt;br /&gt;PS: Ωmega cheats, of course. It frobs the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Show&lt;/span&gt; functionality of the underlying Haskell implementation. It also prints functions as &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;fn&amp;gt;&lt;/span&gt;&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1209739901335781173?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1209739901335781173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1209739901335781173' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1209739901335781173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1209739901335781173'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/08/id-like-to-see-but-do-you-want-to-show.html' title='I&apos;d like to see, but do you want to Show?'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3326536642352366477</id><published>2008-08-23T08:44:00.000-07:00</published><updated>2008-08-23T09:45:00.563-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><title type='text'>Uploaded</title><content type='html'>&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;It's done!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My first &lt;a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/thrist"&gt;contribution&lt;/a&gt; to the Haskell community has just landed in the belly of the &lt;a href="http://hackage.haskell.org/"&gt;beast&lt;/a&gt;...&lt;br /&gt;&lt;br /&gt;Overall it was a very pleasurable experience:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;the website is well organized and makes it easy to find the relevant information,&lt;/li&gt;&lt;li&gt;the account is obtained unbureaucratically by e-mail, and the answer is prompt,&lt;/li&gt;&lt;li&gt;the upload checker provides helpful guidance how to improve the package.&lt;/li&gt;&lt;/ul&gt;The package itself is in very early stage, please do not expect a wealth of functionality :-). Also the (constructor) function names are expected to change (&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Cons&lt;/span&gt;&lt;/span&gt; --&gt; &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;:~&lt;/span&gt;&lt;/span&gt;) to better fit into the language's overall feel.&lt;br /&gt;&lt;br /&gt;I have already included a crucial &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;foldThrist&lt;/span&gt;&lt;/span&gt; function, which is Ganesh's idea (thanks for the feedback, btw.!). What comes now is to figure out how &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;mapThrist&lt;/span&gt;&lt;/span&gt; could be defined. It is somewhat tricky, as there are three type parameters to deal with (let alone all the existential types inside).&lt;br /&gt;&lt;br /&gt;One thing comes to my mind as I think about it. &lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;mapThrist&lt;/span&gt;&lt;/span&gt; could change the first parameter, i.e.:&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Thrist (-&gt;) a b -&gt; Thrist (,) a b&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;an elegant way to record the intermediate values of function composition.&lt;br /&gt;&lt;br /&gt;Fun stuff.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3326536642352366477?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3326536642352366477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3326536642352366477' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3326536642352366477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3326536642352366477'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/08/uploaded.html' title='Uploaded'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5180255065815898890</id><published>2008-08-22T17:03:00.000-07:00</published><updated>2008-08-22T19:34:27.001-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='hackage'/><category scheme='http://www.blogger.com/atom/ns#' term='cabal'/><title type='text'>Ca(ni)balized</title><content type='html'>Today I finally came around reading my way through the &lt;a href="http://en.wikibooks.org/wiki/Haskell/Packaging"&gt;Creating my First Haskell Package&lt;/a&gt; tutorial, and have put together my first &lt;a href="http://www.haskell.org/cabal/"&gt;cabalized&lt;/a&gt; library. And I must confess that I found it really enjoyable. Certainly not more complicated than writing a makefile or adding a &lt;a href="http://www.macports.org/"&gt;macport&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Btw., the said library is thrist-0.0 (what a surprise!) and it is just the embryonal first step. I already have some more stuff in the pipeline...&lt;br /&gt;&lt;br /&gt;Could not upload it to &lt;a href="http://hackage.haskell.org/"&gt;Hackage&lt;/a&gt; yet because I am waiting for my account on the server.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5180255065815898890?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5180255065815898890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5180255065815898890' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5180255065815898890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5180255065815898890'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/08/canibalized.html' title='Ca(ni)balized'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5654437620804716592</id><published>2008-08-04T05:56:00.000-07:00</published><updated>2008-08-04T07:35:15.203-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='quickcheck'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Trotting Forward</title><content type='html'>I am in vacation in Brazil, mostly in an apartment building facing the ocean, but I had little chance to enjoy the water so far. There are several reasons for this, the most important being that Helena was sick the past week and still receives &lt;a href="http://en.wikipedia.org/wiki/Nalidixic_acid"&gt;antibiotics&lt;/a&gt;. It is also raining a lot and is somewhat cold (24 °C) for my taste.&lt;br /&gt;But I have the nights for creative work, so I picked up my &lt;a href="http://heisenbug.blogspot.com/2008/04/absolutely-positively-crazy.html"&gt;recent idea&lt;/a&gt; and started fleshing out the design.&lt;br /&gt;I succeeded in writing a &lt;a href="http://www.cs.chalmers.se/~rjmh/QuickCheck/manual.html"&gt;QuickCheck&lt;/a&gt; generator for randomly creating Insert/Remove sequences steering the lifetime of a Value's def/use chain. I am able to update a given chain according to a history and check that it has still consistently set up waymarks that lead back to the Value.&lt;br /&gt;&lt;br /&gt;I am pretty happy with the &lt;a href="http://svn.berlios.de/viewcvs/al4nin/trunk/purgatory/WayMark.lhs?rev=729&amp;view=markup"&gt;results so far&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now it is time to enter the second phase and proactively optimize worn-off waymarks. As discussed in the other blog post the stretchy/shrinky nature of def/use chains leads to deterioration of the waymarks because Stop marks may be punched into the valid (fixed-length) clusters of Zeros/Ones. This happens at Insert events. On the other hand, Remove events may reduce clusters, thus invalidating them. So it is important to refresh the waymarks when longer islands of invalid marks are encountered. The twist is to retain O(1) complexity, which is not too challenging, but given the volatility of the chain some cleverness is needed.&lt;br /&gt;&lt;br /&gt;I have a smallish plan how to do it: Since I expect that the volatility mostly occurs at the head of the chain (short-lived Use object getting inserted and soon removed), I intend to adjust the waymarks as far to the end as possible. So I have to keep a pointer to the start to invalid cluster immediately preceding a found valid cluster (or FullStop) and refresh the waymarks if there are enough elements present to form a valid cluster. Alternatively I could use the Prev members to walk backwards (in the C++ implementation, since these do not appear in Haskell).&lt;br /&gt;&lt;br /&gt;But I expect that only a nice histogram of a usage statistics will help to find the optimal strategy anyway.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5654437620804716592?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5654437620804716592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5654437620804716592' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5654437620804716592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5654437620804716592'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/08/trotting-forward.html' title='Trotting Forward'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-7577824881369388772</id><published>2008-07-11T12:10:00.000-07:00</published><updated>2008-07-11T12:39:39.649-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Draft Thrist Paper Online</title><content type='html'>I am happy to announce that my thrist paper I've been working on more than a year is now complete, and downloadable from my ad-hoc &lt;a href="http://www.opendylan.org/~gabor/Thrist-draft-2008-07-11.pdf"&gt;web directory&lt;/a&gt;. Completeness does not mean absence of errors or lack of room for improvement. If you like my paper and would like to improve the presentation please contact me. You can find my e-mail address in my profile. I am happy for every comment, though I cannot guarantee that I will pick it up. Please consider that this is still a draft so it should not be passed on and also please do not cite or link to it, as all links will break when the final version comes out.&lt;br /&gt;&lt;br /&gt;It has been quite a fight to get this far. I started out April 2007, and the initial e-mails turned into a paper of several pages. But then life took over. My wife in final days of pregnancy needed my support, my daughter was born. Everybody who has been through such events knows that it is a different mode of living. Sleep deprivation and all that...&lt;br /&gt;&lt;br /&gt;Also, while I have started several papers already, I have never gotten around to finish one. This was quite traumatic, and this time I had sufficient resolve to get through. Hopefully more follow.&lt;br /&gt;&lt;br /&gt;A final word: the formatting of source code sometimes line-breaks in ugly ways. The reason is that the format may change to one column page and then all is right. This depends on the channel how the paper gets published. Updates may happen next week, but July 18 is my absolute deadline.&lt;br /&gt;&lt;br /&gt;Enjoy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-7577824881369388772?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/7577824881369388772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=7577824881369388772' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7577824881369388772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7577824881369388772'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/07/draft-thrist-paper-online.html' title='Draft Thrist Paper Online'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6315574751495143864</id><published>2008-07-07T14:31:00.000-07:00</published><updated>2008-07-08T11:57:20.192-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='clang'/><title type='text'>Clang Server?</title><content type='html'>Sometimes things happen that sound like a miracle. There is this guy, Peter, who signs up for &lt;a href="http://code.google.com/soc/2008"&gt;Google SoC&lt;/a&gt;, with mentor and all. The project plan is to come up with a &lt;a href="http://distcc.org"&gt;distcc&lt;/a&gt;-like parallel/distributed compilation scheme, only with &lt;a href="http://clang.llvm.org"&gt;clang&lt;/a&gt;, the aspiring LLVM C frontend.&lt;br /&gt;He gets the deal, but the weeks run away, and no signs of any progress. Peter is missing in action.&lt;br /&gt;Then, suddenly this weekend: a &lt;a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-July/002169.html"&gt;status report&lt;/a&gt;.&lt;br /&gt;I did not look at the attached patch, but he promises a working compile server, no less!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6315574751495143864?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6315574751495143864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6315574751495143864' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6315574751495143864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6315574751495143864'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/07/clang-server.html' title='Clang Server?'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6481476793028604964</id><published>2008-07-05T08:48:00.000-07:00</published><updated>2008-07-05T09:03:52.343-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>Things I hate</title><content type='html'>Each year the same tragicomedy. Filling out my tax declaration. After procrastinating the first half of the year, and seeing that everybody else already has done it. Being dragged kicking and screaming by my wife (I love her nevertheless). Sometimes I even volunteer to do the stuff.&lt;br /&gt;But every time I read the forms I do not understand how to fill in the right values. The words make so little sense to me. Even if I figured it out last year, it has almost no value, I have already forgotten it. So I can only stare at the last year's form and try to find the corresponding box, which is not so easy since the boxes tend to wander around. I usually give up and opt for another messed-up evening.&lt;br /&gt;&lt;br /&gt;And now there are the tax papers for my wife also to be done, yes, her company is new and the bureaucracy requests 12 reports a year and a final declaration. That is not enough, this all has to be made official and another two exemptions handed in till end of May.&lt;br /&gt;&lt;br /&gt;Welcome to Germany!&lt;br /&gt;&lt;br /&gt;I definitely prefer programming to &lt;span style="font-weight:bold;"&gt;this&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6481476793028604964?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6481476793028604964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6481476793028604964' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6481476793028604964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6481476793028604964'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/07/things-i-hate.html' title='Things I hate'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-781772036995925418</id><published>2008-06-20T02:20:00.000-07:00</published><updated>2008-06-20T16:24:55.722-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='family'/><title type='text'>Birthday season</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_zTrNxPJ0xW0/SFw8JO5EZaI/AAAAAAAAAAM/K_l4kJ-nkjY/s1600-h/IMG_34716.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_zTrNxPJ0xW0/SFw8JO5EZaI/AAAAAAAAAAM/K_l4kJ-nkjY/s320/IMG_34716.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5214108597902140834" /&gt;&lt;/a&gt;&lt;br /&gt;Last Sunday we celebrated my baby daughter Helena's first birthday. She enjoyed it to be in the focal point of the party, but the guests had their fun too. There was another boy, around 16 months old and they played together, hugging each other now and then. Just cute.&lt;br /&gt;&lt;br /&gt;My son turns 12 mid-July and he'll celebrate twice, at home and some days later in Brazil. This event will close the string of birthday dates in my family, commencing with mine on 29. of April and about 10 in between :-)&lt;br /&gt;A kind of frenzy, especially when you are looking back. And people keep telling me that there used to happen a different kind of frenzy in respective years ten months before :-P&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-781772036995925418?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/781772036995925418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=781772036995925418' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/781772036995925418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/781772036995925418'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/06/birthday-season.html' title='Birthday season'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_zTrNxPJ0xW0/SFw8JO5EZaI/AAAAAAAAAAM/K_l4kJ-nkjY/s72-c/IMG_34716.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1432430506165416803</id><published>2008-06-12T15:46:00.000-07:00</published><updated>2008-06-13T15:17:29.082-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OpenCL'/><category scheme='http://www.blogger.com/atom/ns#' term='Apple'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>OpenCL / CLang / CL</title><content type='html'>The most exciting thing that happens under sleep deprivation is a kind of &lt;span style="font-style:italic;"&gt;stream of consciousness&lt;/span&gt;, where the brain goes into a purely associative mode. I am sleepy now and so I can embark on some journey which I tomorrow morning surely will dismiss as utter nonsense.&lt;br /&gt;&lt;br /&gt;So, &lt;a href="http://developer.apple.com/wwdc/"&gt;WWDC&lt;/a&gt; is progressing at the moment, some under-the-hood technologies are being introduced into the OS X system that is running on the Macs out there. Two of these sound interesting: "Grand Central Dispatcher" and OpenCL. There has been some speculation that utilizing GPU power (which is 99,9% idle, unless you are a framerate-wanking gamer) could be one of the directions of the future (besides multi-cores). &lt;a href="http://www.nvidia.com/cuda/"&gt;Nvidia&lt;/a&gt; and &lt;a href="http://forums.amd.com/forum/categories.cfm?catid=328"&gt;ATI&lt;/a&gt; both offer technologies to do this at different levels, but they are incompatible. It is hard to imagine that Apple will provide developers several different and incompatible compilers and tell them to compile their compute intensive kernels with them, bundle them up in some big blob of application and ship it untested (how many developers will buy a bunch of video-cards for testing?).&lt;br /&gt;&lt;br /&gt;Apple likes to provide seamless solutions. They have a proven concept in their OpenGL implementation, namely a machine-independent binary format that can be JITted to a wide variety of processors: LLVM. This would make Joe Developer's life pretty easy: compile your computing kernels to LLVM bitcode, and submit a quadruple to a runtime component (bitcode, characteristics, input data, continuation/consumer of results). The characteristics could state that it is integer- or FP-heavy code etc. After deciding which target will run the code, the LLVM JIT could distill the optimal machine code for the target and invoke it on the input data. When done, the continuation would be called, and would consume the results. Add some speculative execution (start the same job in several computing resources), a good deal of caching (no need to recompile bitcode again), heuristics and profile guided recompilation. This could be some yummy sauce.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.roughlydrafted.com/2008/06/12/wwdc-2008-new-in-mac-os-x-snow-leopard/"&gt;RoughlyDrafted&lt;/a&gt;'s blog so far provides the best intro to the new technology, and helped to start my association chain. What comes next is the fun part.&lt;br /&gt;&lt;br /&gt;When hearing OpenCL the first time, I thought, what a sucky name. It reminds me of OpenGL, but it is not a graphics language. It reminds me of Common Lisp, but that is not an option. &lt;span style="font-weight:bold;"&gt;Open Computing Language&lt;/span&gt;. Hmmm, all programming languages compute stuff...&lt;br /&gt;&lt;br /&gt;There is a little gem, still unpolished, called &lt;a href="http://clang.llvm.org/"&gt;clang&lt;/a&gt;. The light footed successor of &lt;a href="http://gcc.gnu.org/"&gt;gcc&lt;/a&gt; in corporate environments. Compiling "curly brace" languages to LLVM! Wasn't OpenCL C-based? Those letters CL appear everywhere. What is the initials of the principal LLVM engineer, again?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1432430506165416803?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1432430506165416803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1432430506165416803' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1432430506165416803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1432430506165416803'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/06/opencl-clang-cl.html' title='OpenCL / CLang / CL'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-4741405939349257547</id><published>2008-05-16T08:27:00.000-07:00</published><updated>2008-05-20T08:30:11.225-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Merged</title><content type='html'>It did not make it into LLVM release 2.3 (let's be conservative), but it looks like my &lt;span style="font-style:italic;"&gt;use-diet&lt;/span&gt; branch will make it into LLVM 2.4! I have merged the relevant changes on last Saturday (2008-05-10), and so far it has not been reverted :-)&lt;br /&gt;&lt;br /&gt;Owen did some memory statistics and found out that the SPEC benchmark &lt;span style="font-style:italic;"&gt;&lt;a href="http://spec.it.miami.edu/cpu2006/Docs/447.dealII.html"&gt;447.dealII&lt;/a&gt;&lt;/span&gt; had a 13% reduced memory footprint with my patches. This is about what I expected, and a pretty awesome result. Despite of the algorithmic overhead that has been (knowingly) added the compilation did not really get slower, indeed some nightly testers show slightly improved cpu times. Again, this is in line with my observed slight speedup on &lt;span style="font-style:italic;"&gt;kimwitu++&lt;/span&gt; benchmark's compilation time.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;What's next?&lt;/blockquote&gt;&lt;br /&gt;My plans are to do some more API cleanup and then go after even more memory savings which I am already drafting in my fantasies... Whether they are feasible compile-time-wise is still an open question, but I am determined to find out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-4741405939349257547?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/4741405939349257547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=4741405939349257547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4741405939349257547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/4741405939349257547'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/05/merged.html' title='Merged'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5249829951208498454</id><published>2008-04-19T01:49:00.000-07:00</published><updated>2008-08-30T12:23:02.756-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='crazy'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='waymarking'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Absolutely, Positively Crazy</title><content type='html'>My previous two posts revolved around space optimizations in LLVM. The presented technique is a bit unconventional, and paired with the confusing nature of &lt;span style="font-style: italic;"&gt;def-use chains&lt;/span&gt;, it can leave one quite puzzled...&lt;br /&gt;&lt;br /&gt;Today in the LLVM IRC channel, &lt;span style="font-style: italic;"&gt;chandlerc&lt;/span&gt; wondered whether I am eliminating the &lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt; from the &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; struct. I corrected him, that, no, it is all about eliminating &lt;span style="font-family:courier new;"&gt;User*&lt;/span&gt;. But his question drove a nail im my head, making me think. After all, he was thinking of the def-use chain, and I was always dealing with user-use arrays. But deeply inside it is the same problem, a.k.a. the &lt;span style="font-style: italic;"&gt;dual&lt;/span&gt; one:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;for a &lt;span style="font-style: italic;"&gt;user-use&lt;/span&gt; array the &lt;span style="font-family:courier new;"&gt;User*&lt;/span&gt; for all array members is constant, while the &lt;span style="font-style: italic;"&gt;def&lt;/span&gt;s (&lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt;-s) vary,&lt;/li&gt;&lt;li&gt;for a &lt;span style="font-style: italic;"&gt;def-use&lt;/span&gt; chain on the other hand the &lt;span style="font-style: italic;"&gt;def&lt;/span&gt;s (&lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt;-s) are invariant, while the &lt;span style="font-family:courier new;"&gt;User*&lt;/span&gt;-s vary.&lt;/li&gt;&lt;/ul&gt;I wondered whether it is feasible to use the tagging technique to get rid of the &lt;span style="font-family:courier new;"&gt;Use::Val&lt;/span&gt; too? After all, it is just a linked list, and I have already demonstrated something similar in my previous posts.&lt;br /&gt;&lt;br /&gt;It turns out that it is perfectly feasible, and the rest of this post demonstrates how...&lt;br /&gt;...but please do not misunderstand, I &lt;span style="font-style: italic;"&gt;do not&lt;/span&gt; propose this for LLVM (yet?).&lt;br /&gt;&lt;br /&gt;Let's recapitulate what a def-&gt;use chain is:&lt;br /&gt;There is an instruction that generates a value, thus &lt;span style="font-style: italic;"&gt;def&lt;/span&gt;ining it:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;      +-------+&lt;br /&gt;Val = | Instr |&lt;br /&gt;      +-------+&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;Then there are other instructions which consume this value, but the above instruction only sees the &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; objects chained up:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;pre&gt;&lt;br /&gt;   +-------+&lt;br /&gt;   | Instr |&lt;br /&gt;   +----+--+&lt;br /&gt;        |     +---+    +---+    +---+&lt;br /&gt;        +----&gt;|Use|---&gt;|Use|---&gt;|Use|---X&lt;br /&gt;              +---+    +---+    +---+&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;The &lt;span style="font-family:courier new;"&gt;X&lt;/span&gt; above means that &lt;span style="font-family:courier new;"&gt;Use::Next&lt;/span&gt; is filled with NULL. Otherwise &lt;span style="font-family:courier new;"&gt;Use::Next&lt;/span&gt; obviously contains the pointer to the next &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; object.&lt;br /&gt;So to apply &lt;span style="font-style: italic;"&gt;waymarking&lt;/span&gt; we have to get away with two obstacles:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;There is no way to store something around the &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; object (layout-wise), as we did with user-use arrays. We cannot go outside to place the &lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;Def-use chains can be expanded and shrunk dynamically.&lt;/li&gt;&lt;/ol&gt;It turns out that 1) is pretty easy, we do not store NULL in the last &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt;'s &lt;span style="font-family:courier new;"&gt;Next&lt;/span&gt; field, but the &lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt;, with the ‹fullstop› waymark. So when we see ‹fullstop›, the &lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt; can be extracted from the upper bits.&lt;br /&gt;So, let's assume the ‹stop› and ‹0›, ‹1› waymarks are also tucked on the &lt;span style="font-family:courier new;"&gt;Use::Next&lt;/span&gt; fields. Like usual, given any &lt;span style="font-family:courier new;"&gt;Use*&lt;/span&gt; we can pick up the digits, and at the ‹stop› we convert the digits to a &lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt; and we are done. This is nice and dandy, until we remember 2). It appears a bit more tricky. Obviously the insertion/deletion will remove waymarks or add new ones. Our algorithm may begin producing bogus &lt;span style="font-family:courier new;"&gt;Value*&lt;/span&gt;-s. So is there any solution to this problem?&lt;br /&gt;I believe there is. I have no proof but I conjecture that each destructive operation should simply place a ‹stop›, and when the algorithm is changed to only accept 32 digits between two ‹stop›s, then we are on the safe side. The corruption gets detected, an uncorrupted segment can still be found, downstream. The corruption can be repaired later (e.g. when traversing the def-use chain).&lt;br /&gt;&lt;br /&gt;Well this is not a very efficient way of doing things, so it probably only pays off when space is &lt;span style="font-style: italic;"&gt;extremely&lt;/span&gt; limited and compilation/optimization speed is not paramount. But in these applications an 8-byte (down from 16/12 bytes) &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; struct is definitely tempting.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5249829951208498454?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5249829951208498454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5249829951208498454' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5249829951208498454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5249829951208498454'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/04/absolutely-positively-crazy.html' title='Absolutely, Positively Crazy'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-38627132415548889</id><published>2008-04-14T17:47:00.000-07:00</published><updated>2008-04-14T17:56:25.472-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>Use-diet Update</title><content type='html'>As of &lt;a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080414/061092.html"&gt;r49698&lt;/a&gt; the use-diet branch finishes the testsuite (about 2000 tests) without regressions. Actually the &lt;span style="font-family: courier new;"&gt;User*&lt;/span&gt; member of the structure is not eliminated yet, but instead deliberately set to &lt;span style="font-style: italic;"&gt;NULL&lt;/span&gt; in various places, and if present, I assert that it equals the computed value.&lt;br /&gt;&lt;br /&gt;It was quite a fight to get thus far, but it is done! Time to open a good bottle of wine...&lt;br /&gt;&lt;br /&gt;The next days will be devoted to cleaning up the sometimes messy details, doing some statistics and cautiously trying to merge back my work to trunk.&lt;br /&gt;&lt;br /&gt;Wish me luck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-38627132415548889?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/38627132415548889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=38627132415548889' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/38627132415548889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/38627132415548889'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/04/use-diet-update.html' title='Use-diet Update'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3215885897410060325</id><published>2008-04-13T02:17:00.000-07:00</published><updated>2010-07-21T16:15:15.999-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='waymarking'/><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><title type='text'>LLVM Data Structures, and Putting Use on Diet</title><content type='html'>There is a good deal of refactoring going on in the &lt;a href="http://llvm.org/"&gt;LLVM&lt;/a&gt; universe, to wit Dominic's &lt;a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-April/013789.html"&gt;renaming&lt;/a&gt; of &lt;span style="font-family:courier new;"&gt;LLVM*Builder&lt;/span&gt; to &lt;span style="font-family:courier new;"&gt;IRBuilder&lt;/span&gt; with assorted simplifications...&lt;br /&gt;The train is moving fast, getting on board is harder, but rewarding. LLVM does not commit to API (or less even, binary) compatibility, so meaningful changes get in swiftly and without much bureaucracy. A simple mail, warning people of the change in advance, and when accomplished, instructions how to do the conversion, are enough to make folks happy.&lt;br /&gt;&lt;br /&gt;There are reforms going more than skin deep, too. &lt;a href="http://clang.llvm.org/"&gt;Clang&lt;/a&gt; is is getting a datastructure rewrite with &lt;a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080407/005153.html"&gt;nice gains&lt;/a&gt;, and myself is about to reduce the size of the &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; struct by 4 bytes, from 16 to 12 (on a 32bit system). The 25% savings is nothing to sneeze at, considering that this struct is the most frequently allocated one in LLVM. And now that I have the functionality basically implemented on a branch, I can say, the idea is working! Consequently, I have the courage to blog about it :-)&lt;br /&gt;&lt;br /&gt;So what is this &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt;-diet all about? The &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; struct is the home of the pointers to all &lt;span style="font-family:courier new;"&gt;Value&lt;/span&gt;s that an &lt;span style="font-family:courier new;"&gt;Instruction&lt;/span&gt; references. But each &lt;span style="font-family:courier new;"&gt;Value&lt;/span&gt; has to track all of its &lt;span style="font-family:courier new;"&gt;User&lt;/span&gt;s (i.e. the &lt;span style="font-family:courier new;"&gt;Instruction&lt;/span&gt;s), and &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; provides forward and backward pointers to chain those up. These are the essential 3 pointers. But why is &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; 16 bytes? Because in some situations it is important to get back to the &lt;span style="font-family:courier new;"&gt;User&lt;/span&gt; of the referred &lt;span style="font-family:courier new;"&gt;Value&lt;/span&gt;. So it is 4 pointers in total.&lt;br /&gt;&lt;br /&gt;Seemingly this is how it works™ and there is nothing that can be shaved off. But wait! Don't all &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt;s belonging to an &lt;span style="font-family:courier new;"&gt;Instruction&lt;/span&gt; come lined up in a contiguous array? What if we could mark the last &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; specially and put a pointer to the &lt;span style="font-family:courier new;"&gt;Instruction&lt;/span&gt; behind it? Or even allocate the &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt;s immediately in front of &lt;span style="font-family:courier new;"&gt;Instruction&lt;/span&gt; (memory-layout wise)?&lt;br /&gt;&lt;br /&gt;These were the first ideas how my brain-storming with &lt;span style="font-style: italic;"&gt;Sabre&lt;/span&gt; began. After several exchanged emails, we settled on a concept that is IMHO really beautiful. We use 2 bits (the least significant ones, which are always zero, normally) of one of the pointers in &lt;span style="font-family:courier new;"&gt;Use&lt;/span&gt; to implement a &lt;span style="font-style: italic;"&gt;serial line&lt;/span&gt;-like protocol of &lt;span style="font-style: italic;"&gt;waymarks&lt;/span&gt; that guides us to the end of the array in some reasonably few steps. I will not detail the &lt;a href="http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?view=markup&amp;amp;pathrev=49380"&gt;algorithm&lt;/a&gt;, since it is documented elsewhere, I will only say that there are four kinds of waymarks: &lt;fullstop&gt;‹fullstop›, &lt;stop&gt;&lt;/stop&gt;&lt;/fullstop&gt;‹stop›&lt;fullstop&gt;&lt;stop&gt;, &lt;/stop&gt;&lt;/fullstop&gt;‹0›&lt;fullstop&gt;&lt;stop&gt; and &lt;/stop&gt;&lt;/fullstop&gt;‹1›&lt;fullstop&gt;&lt;stop&gt;.&lt;br /&gt;&lt;/stop&gt;&lt;/fullstop&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;Fullstop&lt;/span&gt; means we are at the end already,&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;Stop&lt;/span&gt; means begin gathering digits, or if already done so, convert them to an offset, that brings us to the end,&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;0&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;1&lt;/span&gt; are the binary digits to be picked up.&lt;/li&gt;&lt;/ul&gt;It is clear to see that for small arrays there are only a small number of operations needed to determine the end of the array. The complexity of the algorithm is &lt;span style="font-style: italic;"&gt;O(log N)&lt;/span&gt;. So we do not really have to get concerned with, say, 10000 predecessors to a &lt;a href="http://en.wikipedia.org/wiki/Static_single_assignment_form"&gt;&lt;span style="font-style: italic;"&gt;PHI node&lt;/span&gt;&lt;/a&gt; :-). The description even contains a &lt;a href="http://haskell.org/"&gt;&lt;span style="font-style: italic;"&gt;Haskell&lt;/span&gt;&lt;/a&gt; snippet to encode and decode such offset information.&lt;br /&gt;For reference I shall present it here:&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;blockquote  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&gt; import Test.QuickCheck&lt;br /&gt;&gt;&lt;br /&gt;&gt; digits :: Int -&gt; [Char] -&gt; [Char]&lt;br /&gt;&gt; digits 0 acc = '0' : acc&lt;br /&gt;&gt; digits 1 acc = '1' : acc&lt;br /&gt;&gt; digits n acc = digits (n `div` 2) $ digits (n `mod` 2) acc&lt;br /&gt;&gt;&lt;br /&gt;&gt; dist :: Int -&gt; [Char] -&gt; [Char]&lt;br /&gt;&gt; dist 0 [] = ['S']&lt;br /&gt;&gt; dist 0 acc = acc&lt;br /&gt;&gt; dist 1 acc = let r = dist 0 acc in 's' : digits (length r) r&lt;br /&gt;&gt; dist n acc = dist (n - 1) $ dist 1 acc&lt;br /&gt;&gt;&lt;br /&gt;&gt; takeLast n ss = reverse $ take n $ reverse ss&lt;br /&gt;&gt;&lt;br /&gt;&gt; test = takeLast 40 $ dist 20 []&lt;br /&gt;&gt;&lt;br /&gt;&lt;br /&gt;Printing &lt;test&gt; gives: "1s100000s11010s10100s1111s1010s110s11s1S"&lt;br /&gt;&lt;br /&gt;The reverse algorithm computes the&lt;br /&gt;length of the string just by examining&lt;br /&gt;a certain prefix:&lt;br /&gt;&lt;br /&gt;&gt; pref :: [Char] -&gt; Int&lt;br /&gt;&gt; pref "S" = 1&lt;br /&gt;&gt; pref ('s':'1':rest) = decode 2 1 rest&lt;br /&gt;&gt; pref (_:rest) = 1 + pref rest&lt;br /&gt;&gt;&lt;br /&gt;&gt; decode walk acc ('0':rest) = decode (walk + 1) (acc * 2) rest&lt;br /&gt;&gt; decode walk acc ('1':rest) = decode (walk + 1) (acc * 2 + 1) rest&lt;br /&gt;&gt; decode walk acc _ = walk + acc&lt;br /&gt;&gt;&lt;br /&gt;&lt;br /&gt;Now, as expected, printing &lt;pref&gt; gives 40.&lt;br /&gt;&lt;br /&gt;We can quickCheck this with following property:&lt;br /&gt;&lt;br /&gt;&gt; testcase = dist 2000 []&lt;br /&gt;&gt; testcaseLength = length testcase&lt;br /&gt;&gt;&lt;br /&gt;&gt; identityProp n = n &gt; 0 &amp;amp;&amp;amp; n &lt;= testcaseLength ==&gt; length arr == pref arr&lt;br /&gt;&gt;     where arr = takeLast n testcase&lt;br /&gt;&lt;br /&gt;As expected &lt;quickcheck&gt; gives:&lt;br /&gt;&lt;br /&gt;*Main&gt; quickCheck identityProp&lt;br /&gt;OK, passed 100 tests.&lt;br /&gt;&lt;/quickcheck&gt;&lt;/pref&gt;&lt;/test&gt;&lt;/span&gt;&lt;/blockquote&gt;Btw., &lt;a href="http://en.wikipedia.org/wiki/QuickCheck"&gt;QuickCheck&lt;/a&gt; is awesome!&lt;br /&gt;&lt;br /&gt;So where are the uses of this algorithm outside of LLVM?&lt;br /&gt;There is not much of thinking needed to generalize the array to other data structures, which may permit mutating of the node contents, but disallow insertions. &lt;span style="font-style: italic;"&gt;Linked lists&lt;/span&gt; are an example since one can only cons up stuff to the head. Doubly-ended arrays with fast &lt;span style="font-family:courier new;"&gt;size()&lt;/span&gt; operation (given a pointer to one element) can be implemented if there is another pointer in each node that we can use for storing waymarks to the &lt;span style="font-style: italic;"&gt;start&lt;/span&gt; of the array. &lt;span style="font-family:courier new;"&gt;Deque&lt;/span&gt;s also could work like this, but they too, need to be fully built up before putting in the waymarks.&lt;br /&gt;&lt;br /&gt;This all reminds me of &lt;a href="http://www.pipeline.com/%7Ehbaker1/BoyerB.html"&gt;cons-hashing&lt;/a&gt; but is really a more powerful concept. Let's call it &lt;span style="font-weight: bold;"&gt;waymarking&lt;/span&gt;! And then let the garbage collector put in the waymarks for us...&lt;br /&gt;&lt;blockquote style="font-weight: bold;"&gt;&lt;span style="font-size:130%;"&gt;Down with &lt;span style="font-style: italic; font-weight: normal;"&gt;O(n)&lt;/span&gt; complexity on linked-list's &lt;span style="font-weight: normal;font-family:courier new;"&gt;length&lt;/span&gt; operation!&lt;/span&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3215885897410060325?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3215885897410060325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3215885897410060325' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3215885897410060325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3215885897410060325'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/04/llvm-data-structures-and-putting-use-on.html' title='LLVM Data Structures, and Putting Use on Diet'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6016365514472127757</id><published>2008-03-31T12:15:00.000-07:00</published><updated>2008-04-01T05:59:18.535-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Budapest'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>ETAPS Budapest</title><content type='html'>I am in Budapest since Saturday, and I love it. The weather is excellent, I am in the middle of some very nice people and I can do what I like most: brainstorming cool concepts.&lt;br /&gt;At a satellite event yesterday (&lt;a href="http://www.cs.um.edu.mt/DCC08/schedule.html"&gt;DCC - Designing Correct Circuits&lt;/a&gt;) I met Tim and after the workshop we actually came to chat a plenty on Omega. I very much felt like a satellite, because I did not participate at the conference itself, just hanging around the lobby and the workshop rooms, using the "free" WLAN and thinking about what to do next.&lt;br /&gt;Today then was our first Omega hacking day. Building on the &lt;a href="http://omega.googlecode.com/"&gt;googlecode repository&lt;/a&gt;'s trunk version Tim checked in everything he had on his laptop, and now we can do concurrent development. Both the documentation and the release management toolchain have been overhauled and checked in, along with a testsuite.&lt;br /&gt;&lt;br /&gt;This is &lt;em&gt;already &lt;/em&gt;much more than what I dreamed of...&lt;br /&gt;&lt;br /&gt;Tomorrow we'll go thru the issue list, squashing as many bugs as possible and I might get back to the LLVM generation branch. Another interested student will join us, an Hungarian guy called Tamás.&lt;br /&gt;&lt;br /&gt;This is finally the place to thank &lt;a href="http://aszt.inf.elte.hu/%7Ehz/index_eng.html"&gt;Dr. Horváth Zoltán&lt;/a&gt;, who has very kindly offered us rooms in the university to have our hacking sessions in complete peace.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6016365514472127757?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6016365514472127757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6016365514472127757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6016365514472127757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6016365514472127757'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/03/etaps-budapest.html' title='ETAPS Budapest'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6399623478462602395</id><published>2008-02-05T16:27:00.000-08:00</published><updated>2008-02-05T17:19:55.753-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='monads'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><title type='text'>Embeddings, Part Two: Monad --&gt; Thrist</title><content type='html'>Here comes the second part of my promised embeddings, this time I'll embed any monadic chain (corresponding to the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;do&lt;/span&gt;-syntax in Haskell) into a thrist and provide a semantics. Later I'll try to discuss some convenience features and try my luck with &lt;span style=";font-family:courier new;font-size:85%;"  &gt;mfix&lt;/span&gt; (and the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;mdo&lt;/span&gt;-notation).&lt;br /&gt;&lt;br /&gt;As in my post dealing with arrows, we have to define an adapter &lt;span style="font-style: italic;"&gt;GADT&lt;/span&gt;:&lt;br /&gt;&lt;blockquote&gt;data Monad' :: (* -&gt; *) -&gt; * -&gt; * -&gt; * where&lt;br /&gt; Feed :: Monad m =&gt; m b -&gt; Monad' m a b&lt;br /&gt; Digest :: Monad m =&gt; (a -&gt; m b) -&gt; Monad' m a b&lt;br /&gt;&lt;/blockquote&gt;The semantics is a bit trickier as in the arrow case, but let's find out the type signature first...&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;Feed&lt;/span&gt; sounds like an introduction of a new monadic value, we would like to interpret it as the (&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;) connective. &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Digest&lt;/span&gt; on the other hand transforms, and thus corresponds to (&lt;span style=";font-family:courier new;font-size:85%;"  &gt;&gt;&gt;=&lt;/span&gt;). Both expect an already formed monadic value, so we can state:&lt;br /&gt;&lt;blockquote&gt;recoverM :: Monad m =&gt; m a -&gt; Thrist (Monad' m) a b -&gt; m b&lt;/blockquote&gt;The effect of an empty thrist is trivial:&lt;br /&gt;&lt;blockquote&gt;recoverM mon Nil = mon&lt;/blockquote&gt;And the other two connectives turn out to be the only sensible way to do it:&lt;br /&gt;&lt;blockquote&gt;recoverM mon (Cons (Feed m) rest) = recoverM (mon &gt;&gt; m) rest&lt;br /&gt;recoverM mon (Cons (Digest f) rest) = recoverM (mon &gt;&gt;= f) rest&lt;/blockquote&gt;Now, we can build up chains:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;*Embeddings&gt; :t Cons (Feed getChar) $ Cons (Digest (return . ord)) Nil&lt;br /&gt;Cons (Feed getChar) $ Cons (Digest $ (return . ord)) Nil :: forall a. Thrist (Monad' IO) a Int&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;and execute them too:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;*Embeddings&gt; recoverM getChar (Cons (Feed getChar) $ Cons (Digest (return . ord)) Nil)&lt;br /&gt;Loading package haskell98 ... linking ... done.&lt;br /&gt;GG71&lt;/span&gt;&lt;/blockquote&gt;The first 'G' is consumed by the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;getChar&lt;/span&gt; invocation that is given to &lt;span style=";font-family:courier new;font-size:85%;"  &gt;recoverM&lt;/span&gt;, but its result is ignored. The second is having an effect too, and its result is used to obtain the ASCII value. The overall monadic action is then run by &lt;span style=";font-family:courier new;font-size:85%;"  &gt;ghci&lt;/span&gt;, printing the 71.&lt;br /&gt;&lt;br /&gt;We have converted  &lt;span style=";font-family:courier new;font-size:85%;"  &gt;&gt;&gt; &lt;/span&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;getChar &gt;&gt;= (return . ord)&lt;/span&gt; into a  thrist and got it back by means of &lt;span style=";font-family:courier new;font-size:85%;"  &gt;recoverM&lt;/span&gt;! And this works for any monad.&lt;br /&gt;&lt;br /&gt;Two shortcuts come to my mind, they can be modelled by adding two simpler variants to the GADT:&lt;br /&gt;&lt;blockquote&gt;Feed' :: Monad m =&gt; b -&gt; Monad' m a b&lt;br /&gt;Digest' :: Monad m =&gt; (a -&gt; b) -&gt; Monad' m a b&lt;/blockquote&gt;The semantics should be clear, I leave the extension of &lt;span style=";font-family:courier new;font-size:85%;"  &gt;recoverM&lt;/span&gt; to the reader.&lt;br /&gt;&lt;br /&gt;Now what about the value fixpoint &lt;span style=";font-family:courier new;font-size:85%;"  &gt;mfix&lt;/span&gt;? Can we dress it in thristy clothes? Frankly, I have no idea, but I would be happy to hear from you. It is late, I need sleep now. Bye.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6399623478462602395?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6399623478462602395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6399623478462602395' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6399623478462602395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6399623478462602395'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/02/embeddings-part-two-monad-thrist.html' title='Embeddings, Part Two: Monad --&gt; Thrist'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5706672842806974784</id><published>2008-01-31T13:06:00.000-08:00</published><updated>2008-01-31T14:02:02.767-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='GADT'/><title type='text'>Embeddings, Part One: Arrow --&gt; Thrist</title><content type='html'>&lt;a href="http://article.gmane.org/gmane.comp.lang.haskell.cafe/35957"&gt;Dan Weston&lt;/a&gt; asked me how the embeddings of &lt;a href="http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html"&gt;arrows&lt;/a&gt; and &lt;a href="http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html"&gt;monads&lt;/a&gt; into &lt;a href="http://heisenbug.blogspot.com/2007/11/trendy-topics.html"&gt;thrists&lt;/a&gt; would look like.&lt;br /&gt;Took me some effort, but I think I have found something that appears to be satisfactory.&lt;br /&gt;&lt;br /&gt;This time I shall prove my claim that in Haskell any &lt;a href="http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html"&gt;Control.Arrow&lt;/a&gt; instance can be rewritten as a Thrist data structure. I shall also provide a semantics for the resulting data that shall recover the original arrow. Let me recapitulate the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;Thrist&lt;/span&gt;&lt;/span&gt; definition before diving in:&lt;br /&gt;&lt;blockquote&gt;data Thrist :: (* -&gt; * -&gt; *) -&gt; * -&gt; * -&gt; * where&lt;br /&gt; Nil :: Thrist p a a&lt;br /&gt; Cons :: p a b -&gt; Thrist p b c -&gt; Thrist p a c&lt;/blockquote&gt;Let's begin with the embedding part. Since the members of thrists are constructors of a two-parameter GADT, we have to construct the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Arrow'&lt;/span&gt;&lt;/span&gt; GADT first. Here is the adapter:&lt;br /&gt;&lt;blockquote&gt;data Arrow' :: (* -&gt; * -&gt; *) -&gt; * -&gt; * -&gt; * where&lt;br /&gt; Arr :: Arrow a =&gt; a b c -&gt; Arrow' a b c&lt;br /&gt; First :: Arrow a =&gt; Arrow' a b c -&gt; Arrow' a (b, d) (c, d)&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Arr&lt;/span&gt;&lt;/span&gt; takes any arrow and wraps it. This constructor is responsible for the actual embedding and it is easy to see that it is completely general.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;First&lt;/span&gt;&lt;/span&gt; is responsible for defining a transformation on a pair's first component. Clearly this corresponds to the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Arrow&lt;/span&gt;&lt;/span&gt; type class's &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;first&lt;/span&gt;&lt;/span&gt; member. I refrain from doing the same to the other functions in the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Arrow&lt;/span&gt;&lt;/span&gt; type class. You may scratch your head now, asking whether I have forgotten to handle the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;&gt;&gt;&gt;&lt;/span&gt; member... The answer is &lt;span style="font-style: italic;"&gt;no&lt;/span&gt;, I'll come back to this later.&lt;br /&gt;&lt;br /&gt;Let's see how this works out in the practice...&lt;br /&gt;&lt;blockquote&gt;t1 :: Thrist (-&gt;) Char Char&lt;br /&gt;t1 = Cons ord (Cons chr Nil)&lt;br /&gt;&lt;/blockquote&gt;This is just the plain chaining of functions as a thrist. Here is the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Arrow'&lt;/span&gt;&lt;/span&gt; embedding:&lt;br /&gt;&lt;blockquote&gt;t2 :: Arrow' (-&gt;) Char Int&lt;br /&gt;t2 = Arr ord&lt;br /&gt;&lt;/blockquote&gt;We make a thrist of length 1:&lt;br /&gt;&lt;blockquote&gt;t3 :: Thrist (Arrow' (-&gt;)) Char Int&lt;br /&gt;t3 = Cons t2 Nil&lt;br /&gt;&lt;/blockquote&gt;This is  bit more involved, adding a constant second pair component:&lt;br /&gt;&lt;blockquote&gt;t4 :: Arrow' (-&gt;) a (a, Int)&lt;br /&gt;t4 = Arr (\a -&gt; (a, 42))&lt;br /&gt;&lt;/blockquote&gt;Now it is time to form a longer thrist:&lt;br /&gt;&lt;blockquote&gt;t5 :: Thrist (Arrow' (-&gt;)) Int (Int, Int)&lt;br /&gt;t5 = Cons (Arr chr) (Cons t4 (Cons (First t2) Nil))&lt;br /&gt;&lt;/blockquote&gt;So, this corresponds to what? Intuitively, it could mean&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;chr &gt;&gt;&gt; (\a -&gt; (a, 42)) &gt;&gt;&gt; first ord&lt;/span&gt;.&lt;br /&gt;The &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Cons&lt;/span&gt; data constructor assumes the rôle of &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;To obtain a meaning at all, we have to define a semantics for it! Here it comes, and allows us to recover the embedded arrow:&lt;br /&gt;&lt;blockquote&gt;recover :: Arrow a =&gt; Thrist (Arrow' a) b c -&gt; a b c&lt;br /&gt;recover Nil = arr id&lt;br /&gt;recover (Cons (Arr f) r) = f &gt;&gt;&gt; recover r&lt;br /&gt;recover (Cons (First a) r) = first (recover $ Cons a Nil) &gt;&gt;&gt; recover r&lt;br /&gt;&lt;/blockquote&gt;Some people call this an (operational) interpreter.&lt;br /&gt;&lt;br /&gt;Finally, a little test:&lt;br /&gt;&lt;blockquote&gt;*Embeddings&gt; (recover t5) 55&lt;br /&gt;Loading package haskell98 ... linking ... done.&lt;br /&gt;(55,42)&lt;br /&gt;&lt;/blockquote&gt;Cute, isn't it?&lt;br /&gt;&lt;br /&gt;PS: To embed monads, you can try embedding them via &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Kleisli&lt;/span&gt;&lt;/span&gt; to obtain an arrow and then via &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Arrow'&lt;/span&gt;&lt;/span&gt; to construct a thrist. Alternatively wait for a future post here :-)&lt;br /&gt;&lt;br /&gt;PPS: For running the above you will need these preliminaries:&lt;br /&gt;&lt;blockquote&gt;module Embeddings where&lt;br /&gt;import Prelude&lt;br /&gt;import Control.Arrow&lt;br /&gt;import Char&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5706672842806974784?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5706672842806974784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5706672842806974784' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5706672842806974784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5706672842806974784'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2008/01/embeddings-part-one-arrow-thrist.html' title='Embeddings, Part One: Arrow --&gt; Thrist'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5770288954864368780</id><published>2007-12-11T19:21:00.000-08:00</published><updated>2007-12-11T20:18:31.489-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>What Ωmega has joined, no one can take apart</title><content type='html'>Some days ago I became enthusiastic about creating data structures with some pretty strong &lt;a href="http://en.wikipedia.org/wiki/Invariant_%28mathematics%29"&gt;invariants&lt;/a&gt;. What I did not expect were the difficulties actually providing the evidence that the preconditions hold, and that taking apart the the data into pieces without losing the constraints can become a challenge. In fact, when embarking on programming with &lt;span style=";font-family:courier new;font-size:85%;"  &gt;SingleLabel&lt;/span&gt;, a bunch of &lt;span style="font-style: italic;"&gt;proof obligations&lt;/span&gt; arise.&lt;br /&gt;&lt;br /&gt;So the title is actually misleading (sounds cool nevertheless!) and should read "... no one can take apart &lt;span style="font-style: italic;"&gt;losslessly&lt;/span&gt;". Of course a non-empty &lt;span style=";font-family:courier new;font-size:85%;"  &gt;SingleLabel&lt;/span&gt; can be taken apart by pattern matching! This article is about propositional facts, and their propagation.&lt;br /&gt;&lt;br /&gt;The &lt;span style=";font-family:courier new;font-size:85%;"  &gt;More&lt;/span&gt; data constructor is only accessible if the constraint &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Equal rest {drop l rest}&lt;/span&gt; is given. Last time no evidence was needed, because &lt;span style=";font-family:courier new;font-size:85%;"  &gt;rest&lt;/span&gt; was explicitly known, so the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;drop&lt;/span&gt; type function could be evaluated and the equality checked. But when we just want to join a new &lt;span style="font-style: italic;"&gt;head&lt;/span&gt; with an unknown &lt;span style="font-style: italic;"&gt;tail&lt;/span&gt;?&lt;br /&gt;This should still be possible in case that a &lt;span style="font-style: italic;"&gt;witness&lt;/span&gt; is provided, that testifies that the tail does not contain the label occurring in the new head. Simple enough,&lt;br /&gt;&lt;blockquote  style="font-family:lucida grande;"&gt;&lt;span style="font-size:85%;"&gt;join :: Label a -&gt; v -&gt; SingleLabel tail -&gt; Equal {drop a tail} tail -&gt; SingleLabel {a=v; tail}r&lt;br /&gt;join a v t Eq = {a=v; t}s&lt;/span&gt;&lt;/blockquote&gt;should do it. Unfortunately I am running against the wall again. The &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Eq&lt;/span&gt; witness is not accepted by Ω&lt;span style="font-style: italic;"&gt;mega&lt;/span&gt;, on the grounds that no &lt;span style="font-style: italic;"&gt;refinement&lt;/span&gt; can be established. The debugging session tomorrow promises to become an adventure!&lt;br /&gt;&lt;br /&gt;When this problem is fixed, I'll come back and tell you the story of the lossless decomposition (so that calling &lt;span style=";font-family:courier new;font-size:85%;"  &gt;join&lt;/span&gt; with the results gives us the original back).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5770288954864368780?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5770288954864368780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5770288954864368780' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5770288954864368780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5770288954864368780'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/12/what-mega-has-joined-no-one-can-take.html' title='What Ωmega has joined, no one can take apart'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3670402765301078488</id><published>2007-12-07T12:40:00.000-08:00</published><updated>2007-12-08T07:42:45.598-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><category scheme='http://www.blogger.com/atom/ns#' term='shiraz'/><title type='text'>Only one of each, please!</title><content type='html'>Must be all those sleepless nights (no, I do not want to blame my 6 month old daughter) that light the fire of creativity sometimes...&lt;div&gt;&lt;br /&gt;&lt;div&gt;Two nights ago I had this marvelous idea: how to say that a list is indeed a set. Dear reader, if you do not like maths, please go home now. I am in the happy state of a half bottle of &lt;a href="http://en.wikipedia.org/wiki/Shiraz_grape#Australian_Shiraz"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Shiraz&lt;/span&gt;&lt;/a&gt; and only want people around who share my interests!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Okay let's come to the point. As you probably know, Ω&lt;span class="Apple-style-span" style="font-style: italic;"&gt;mega&lt;/span&gt; provides a &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Row&lt;/span&gt;&lt;/span&gt; kind, it is a classifier for associations at the type level.&lt;/div&gt;&lt;div&gt;The shorthand notation &lt;span class="Apple-style-span" style=";font-family:'courier new';font-size:85%;"  &gt;&lt;span class="Apple-style-span"&gt;{`a=Int, `b=Char}r&lt;/span&gt;&lt;/span&gt; can express a record where a component labelled with &lt;span class="Apple-style-span" style=";font-family:'courier new';font-size:85%;"  &gt;&lt;span class="Apple-style-span"&gt;`a&lt;/span&gt;&lt;/span&gt; contains values of type &lt;span class="Apple-style-span" style=";font-family:'courier new';font-size:85%;"  &gt;&lt;span class="Apple-style-span"&gt;Int&lt;/span&gt;&lt;/span&gt; while under the key &lt;span class="Apple-style-span" style=";font-family:'courier new';font-size:85%;"  &gt;&lt;span class="Apple-style-span"&gt;`b&lt;/span&gt;&lt;/span&gt; we can store &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Char&lt;/span&gt;&lt;/span&gt;s. This is probably boring stuff if you already understand extensible records.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now let's descend to the value plane. A value can have a type &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;SingleLabel {`a=Int, `b=Char}r&lt;/span&gt;&lt;/span&gt; when we define following datatype:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);font-family:'Trebuchet MS';font-size:85%;"  &gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span style="font-weight: bold;"&gt;data&lt;/span&gt; SingleLabel :: Row Tag * ~&gt; * &lt;span style="font-weight: bold;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;  None &lt;span style="font-weight: bold;"&gt;::&lt;/span&gt; SingleLabel RNil&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;  More &lt;span style="font-weight: bold;"&gt;::&lt;/span&gt; Label l -&gt; t -&gt; SingleLabel rest -&gt; SingleLabel {l=t;rest}r&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt; &lt;span style="font-weight: bold;"&gt;deriving&lt;/span&gt; Record(s)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;As usual we have two data constructors, one for the empty record and one for augmenting an existing one. The "deriving" clause just tells Ω&lt;span class="Apple-style-span" style="font-style: italic;"&gt;mega&lt;/span&gt; to enable the following syntactic sugar for &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;None&lt;/span&gt;&lt;/span&gt; and &lt;span style=";font-family:courier new;font-size:85%;" class="Apple-style-span"  &gt;&lt;span class="Apple-style-span"&gt;More&lt;/span&gt;&lt;/span&gt;: &lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style=";font-family:'courier new';font-size:85%;"  &gt;More `lab 42 None&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=";font-family:Georgia;font-size:16;"  &gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=";font-family:Georgia;font-size:16;"  &gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=";font-family:Georgia;font-size:16;"  &gt;&lt;span style="font-size:100%;"&gt;=== &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;{`lab=42}s&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;, nothing exciting.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;But no one can hinder us to define a record value with repeated identical keys: &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;{`a=25, `a="42"}s&lt;/span&gt;&lt;/span&gt; is a perfectly legal value of type &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;{`a=Int, `a=[Char]}s&lt;/span&gt;&lt;/span&gt; but it really is incompatible with our aim of defining a one-to-one correspondence between labels and values.&lt;/div&gt;&lt;div&gt;Now enters my cunning idea: using a &lt;span class="Apple-style-span" style="font-style: italic;"&gt;constraint&lt;/span&gt;, we can restrict the &lt;span class="Apple-style-span" style="font-style: italic;"&gt;tail&lt;/span&gt; of the list to not contain a key we are &lt;span class="Apple-style-span" style="font-style: italic;"&gt;about to add&lt;/span&gt;. Constraints are much like &lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Haskell_%28programming_language%29"&gt;Haskell&lt;/a&gt;&lt;/span&gt;'s type classes, but they are less ad-hoc and mirror propositional facts (properties). The new definition could look  like this:&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);font-family:'Trebuchet MS';font-size:13;"  &gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);font-size:85%;" &gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span style="font-weight: bold;"&gt;data&lt;/span&gt; SingleLabel :: Row Tag * ~&gt; * &lt;span style="font-weight: bold;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);font-size:85%;" &gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;  None &lt;span style="font-weight: bold;"&gt;::&lt;/span&gt; SingleLabel RNil&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;  More &lt;span style="font-weight: bold;"&gt;::&lt;/span&gt; Equal rest {drop l rest} &lt;span style="font-weight: bold;"&gt;=&gt;&lt;/span&gt; Label l -&gt; t -&gt; SingleLabel rest -&gt;&lt;br /&gt;       SingleLabel {l=t;rest}r&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt; &lt;span style="font-weight: bold;"&gt;deriving&lt;/span&gt; Record(s)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;We have defined following semantics: Under the restriction that dropping the tag &lt;span class="Apple-style-span" style="font-style: italic;"&gt;l&lt;/span&gt; from the tail does not change it at all (a &lt;a href="http://en.wikipedia.org/wiki/Fixpoint"&gt;fixpoint&lt;/a&gt;!), we can construct an augmented list. We have almost reached our self imposed objective: it only remains to provide a suitable definition for &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;drop&lt;/span&gt;&lt;/span&gt;!&lt;/div&gt;&lt;div&gt;Now, Ω&lt;span class="Apple-style-span" style="font-style: italic;"&gt;mega&lt;/span&gt; helps us in this respect too (but not entirely so for &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Tag&lt;/span&gt;&lt;/span&gt;s), as we can define &lt;span class="Apple-style-span" style="font-style: italic;"&gt;functions on types&lt;/span&gt; (or kinds for that matter). We can do it this way:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;drop :: Tag ~&gt; Row Tag * ~&gt; Row Tag *&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;{drop o RNil} = RNil&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;{drop `a (RCons `a v r)} = {drop `a r} &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;{drop `b (RCons `b v r)} = {drop `b r}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;{drop `b (RCons `a v r)} = RCons `a v {drop `b r}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span style="font-size:85%;"&gt;{drop `a (RCons `b v r)} = RCons `b v {drop `a r}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;This should be enough for demonstration purposes. (We get a quadratic blowup with increasing number of desired labels, since we have to write our definition in an inductively sequential fashion).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With all of this in place we can give a whirl to our &lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;SingleLabel&lt;/span&gt;&lt;/span&gt; datatype:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prompt&gt; {`a=42}s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;--&gt; {`a=42}s :: SingleLabel {`a=Int}r&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prompt&gt; {`a=42,`b='K'}s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;--&gt; {`a=42,`b='K'}s :: SingleLabel {`a=Int,`b=Char}r&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;prompt&gt; {`a=42,`a='K'}s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt; --- Type error: cannot find a solution for equation {`a=Char}r == {}r&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can now go to bed with the feeling of having accomplished a thing...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;PS:&lt;/span&gt; Ω&lt;span class="Apple-style-span" style="font-style: italic;"&gt;mega&lt;/span&gt; in its last released &lt;a href="http://web.cecs.pdx.edu/%7Esheard/Omega/index.html"&gt;form&lt;/a&gt; cannot compile the code presented here. You will need some patches to get various bugs ironed out. With some luck this all will work out of the box in the next release!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3670402765301078488?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3670402765301078488/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3670402765301078488' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3670402765301078488'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3670402765301078488'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/12/only-one-of-each-please.html' title='Only one of each, please!'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5141678732787593609</id><published>2007-11-08T13:23:00.000-08:00</published><updated>2007-12-13T16:45:54.771-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='monads'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='thrist'/><category scheme='http://www.blogger.com/atom/ns#' term='category theory'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Trendy Topics</title><content type='html'>There seem to be two important trends in the Haskell universe and I must admit, that I do not want to stay away from them either...&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The first one is the exploration of category-theoretic concepts and their showing-off in the blogosphere. &lt;a href="http://blog.unsafeperformio.com/?p=3"&gt;Generalizations of &lt;span style="font-style: italic;"&gt;monads&lt;/span&gt;&lt;/a&gt; or the &lt;a style="font-style: italic;" href="http://twan.home.fmf.nl/blog/haskell/References-Arrows-and-Categories.details"&gt;category type class&lt;/a&gt; are just two recent picks from the bottomless &lt;a href="http://programming.reddit.com/"&gt;supply of ideas&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;The second trend is more subtle and one has to dive into the recent &lt;a href="http://icfpconference.org/"&gt;ICFP&lt;/a&gt; papers to perceive it. I have already mentioned the &lt;a style="font-style: italic;" href="http://web.cecs.pdx.edu/%7Ecklin/papers/unimo-143.pdf"&gt;Unimo&lt;/a&gt; framework, which guarantees the monad laws and allows to represent the monadic computation as a pure data structure which is then &lt;span style="font-style: italic;"&gt;run&lt;/span&gt; by recursive analysis. &lt;a href="http://www.cs.nott.ac.uk/%7Ewss/Publications/BeautyInTheBeast.pdf"&gt;&lt;span style="font-style: italic;"&gt;Wouter Swierstra et al.&lt;/span&gt;&lt;/a&gt; introduced another concept to capture monads (also strongly resembling the &lt;span style="font-style: italic;"&gt;free monad&lt;/span&gt;) and they have improved testing ability on their minds when doing this. The third &lt;a href="http://www.cs.nott.ac.uk/%7Enhn/Publications/icfp2005.pdf"&gt;paper&lt;/a&gt; that comes to my mind is about speeding up arrow computations by analysis and optimization of a data structure closely resembling &lt;a href="http://en.wikipedia.org/wiki/Arrows_in_functional_programming"&gt;arrows&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;So I am not in bad company announcing that I am preparing a paper about &lt;span style="font-style: italic;"&gt;thrists&lt;/span&gt; which are the moral equivalents of &lt;span style="font-style: italic;"&gt;free categories&lt;/span&gt;. The rest of this article gives an appetizer about thrists.&lt;br /&gt;&lt;blockquote  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;data Thrist :: (* -&gt; * -&gt; *) -&gt; *&lt;/span&gt;&lt;span style="font-size:85%;"&gt; -&gt; *&lt;/span&gt;&lt;span style="font-size:85%;"&gt; -&gt; *&lt;/span&gt;&lt;span style="font-size:85%;"&gt; where&lt;br /&gt; Nil :: Thrist p a a&lt;br /&gt; Cons :: p a b -&gt; Thrist p b c -&gt; Thrist p a c&lt;/span&gt;&lt;/blockquote&gt;The definition makes it clear that Thrist is a GADT &lt;span style="font-size:78%;"&gt;(I use the Haskell way of defining a GADT here, the paper will use the slightly different &lt;a href="http://web.cecs.pdx.edu/%7Esheard/Omega/index.html"&gt;Ωmega&lt;/a&gt; syntax)&lt;/span&gt; and it is a curious mixture of listness and threadedness (this is the reason for its name). The types of the thrist elements must match up in a certain way, resembling function composition.&lt;br /&gt;Indeed, instead of composing functions, we can put them into a thrist:&lt;br /&gt;&lt;blockquote  style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;Cons ord $ Cons chr Nil&lt;/span&gt;&lt;/blockquote&gt;gives us an arrow thrist (&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Thrist (-&gt;) Char Char&lt;/span&gt;&lt;/span&gt;) only showing the start and end types, with the internal types abstracted away existentially.&lt;br /&gt;Of course we have to supply an interpreter for this data structure to get the functionality (the &lt;span style="font-style: italic;"&gt;semantics&lt;/span&gt;) of function composition, but this easy exercise is left to you.&lt;br /&gt;&lt;br /&gt;But... &lt;span style="font-weight: bold;"&gt;What do thrists buy us?&lt;/span&gt;&lt;br /&gt;Two very important things:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Unlike function composition, we can take the thrist apart, analyse and transform it, and&lt;br /&gt;&lt;/li&gt;&lt;li&gt;a vast field opens up with the first (&lt;span style=";font-family:courier new;font-size:85%;"  &gt;p&lt;/span&gt;) parameter to the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;Thrist&lt;/span&gt;. It can be the pair constructor &lt;span style=";font-family:courier new;font-size:85%;"  &gt;(,)&lt;/span&gt; or the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;LE&lt;/span&gt;&lt;/span&gt; (less-or-equal) proposition, there are many sensible instantiations -- especially with two-parameter user-defined GADTs.&lt;/li&gt;&lt;/ul&gt;Finally, the category-theoretic twist: think of the parameter &lt;span style="font-style: italic;"&gt;p&lt;/span&gt; as the morphisms of a category &lt;span style="font-style: italic;"&gt;C&lt;/span&gt; (with &lt;span style="font-style: italic;"&gt;C&lt;/span&gt;'s objects being the morphisms' domains and ranges) then &lt;span style="font-style: italic;"&gt;Thrist p&lt;/span&gt; is essentially the free category of &lt;span style="font-style: italic;"&gt;C&lt;/span&gt;, often written as &lt;span style="font-style: italic;"&gt;C*&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;I hope you enjoyed reading this in the same way as me writing it!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5141678732787593609?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5141678732787593609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5141678732787593609' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5141678732787593609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5141678732787593609'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/11/trendy-topics.html' title='Trendy Topics'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-2346520023984415795</id><published>2007-10-29T07:27:00.000-07:00</published><updated>2007-10-29T07:40:56.885-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>Traumzimmer</title><content type='html'>Some people know, but many more don't, that my wife Patricia is an artist specializing in designing babies' or children's rooms. Back in Brazil she even made a living out of this.&lt;br /&gt;After some creative pause and the arrival of our baby (she has also decorated her space) it is time to get back to work. I am very proud of what she is accomplishing, so I'd love to show you some pieces at &lt;a href="http://www.traumzimmer.info/"&gt;Traumzimmer&lt;/a&gt;. The website is pretty new, but taking shape slowly, and documents the progress of the firm she opened with another brazilian girl.&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-2346520023984415795?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/2346520023984415795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=2346520023984415795' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2346520023984415795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/2346520023984415795'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/10/traumzimmer.html' title='Traumzimmer'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1247505072147724378</id><published>2007-09-12T16:50:00.000-07:00</published><updated>2007-09-12T17:04:34.579-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='types'/><category scheme='http://www.blogger.com/atom/ns#' term='category theory'/><title type='text'>Comonads</title><content type='html'>Slowly recovering from vacation-induced ignorance, today I printed out some interesting papers about &lt;a href="http://www.iro.umontreal.ca/%7Emonnier/tpch.pdf"&gt;type-preserving compilation&lt;/a&gt;, plans for &lt;a href="http://www.cse.unsw.edu.au/%7Echak/papers/tyfuns.pdf"&gt;type-level functions in GHC&lt;/a&gt; and &lt;a href="http://cs.ioc.ee/%7Etarmo/papers/aplas05.pdf"&gt;dataflow implementations using comonads&lt;/a&gt;. Another one about &lt;a href="http://www.eecs.harvard.edu/%7Ealeks/papers/hoarelogic/jfpsep07.pdf"&gt;Hoare Type Systems&lt;/a&gt; remained on my screen, too heavy for me, a.t.m.&lt;br /&gt;So I am wrapping my head around category theory again. Somehow all these topics seems to interact, and I continuously am trying to fit them into my &lt;span style="font-style: italic;"&gt;Thrist&lt;/span&gt; framework. Today I tried to implement a Comonad to Thrist adapter (in my mind at least, no code written yet).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1247505072147724378?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1247505072147724378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1247505072147724378' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1247505072147724378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1247505072147724378'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/09/comonads.html' title='Comonads'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-7561324921675289143</id><published>2007-08-30T04:17:00.000-07:00</published><updated>2007-08-30T04:48:24.575-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><category scheme='http://www.blogger.com/atom/ns#' term='vacation'/><title type='text'>Vacation</title><content type='html'>I am in jetlag mode. People keep telling that travelling from west to east worsens it. Maybe this is the reason that I am not very motivated to do my day-work. But possibly it is just the memories of the last four weeks.&lt;br /&gt;&lt;blockquote&gt;Brazil.&lt;/blockquote&gt;My wife comes from the north-eastern part of the country, namely Recife-Pernambuco, so we had the best possible guide for our travelling explorations.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.xalesdemaracaipe.com.br/"&gt;Maracaipe&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://pipa.com.br/"&gt;Pipa&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://natal.com.br/"&gt;Natal&lt;/a&gt;, &lt;a href="http://www.moon.com/planner/brazil/mustsees/natal_fortaleza/genipabu.html"&gt;Genipabu&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.tambaba.com.br/"&gt;Tambaba&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;just to name a few. Sleeping deep and long, very good food (beef, excellent fish and astonishingly, cheap and tasty sushi) the most important ingredients for a relaxing time away from home. Countless hours with members of an immensely great family and long evenings with friends, guitars, caipirinha.&lt;br /&gt;Should last for some months from now. Thanks to all who made it sweet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-7561324921675289143?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/7561324921675289143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=7561324921675289143' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7561324921675289143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7561324921675289143'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/08/vacation.html' title='Vacation'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5863547898937739368</id><published>2007-07-28T10:20:00.000-07:00</published><updated>2007-08-30T05:19:54.435-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><title type='text'>Taming PSNormalizer</title><content type='html'>For distilling a PDF on the Mac I had to unlearn almost everything. Or at least I have to use some more tools, while ignoring others. What I shall write down now is the product of one night of intensive research by googling with lots of trial-and-error.&lt;br /&gt;&lt;br /&gt;So, producing the &lt;span style="font-style: italic;"&gt;.ps&lt;/span&gt; with lout was easy and just like on Solaris. But there is no Distiller in my setup, instead I normally use &lt;a href="http://www.apple.com/macosx/features/pdf/"&gt;Preview.app&lt;/a&gt;. Double-clicking on the &lt;span style="font-style: italic;"&gt;.ps&lt;/span&gt; file in the Finder usually is sufficient. Not this time, though, because the &lt;span style="font-style: italic;"&gt;Latin Modern&lt;/span&gt; fonts were missing, and Preview.app substitutes Courier for them. Clearly a suboptimal solution.&lt;br /&gt;Dropping the &lt;span style="font-style: italic;"&gt;.pfb&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;.afm&lt;/span&gt; files into the Fonts folder (personal or system Libraries/Fonts) only had the effect of locking up Preview.app with every job. This is what other people also report in support forums. I removed the font files again.&lt;br /&gt;The solution must be including the font into the &lt;span style="font-style: italic;"&gt;.ps&lt;/span&gt; file. There is a small utility called &lt;span style="font-style: italic;"&gt;includeres&lt;/span&gt; in the &lt;a href="http://macports.org/"&gt;MacPorts&lt;/a&gt; &lt;span style="font-style: italic;"&gt;psutils&lt;/span&gt; package. Unfortunately the script did not run out of the box, I had to edit it to invoke perl by full pathname (#!/opt/local/bin/perl). But then I had to symlink  &lt;span style="font-style: italic;"&gt;LMRoman9-Regular&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;lmr9.pfb&lt;/span&gt; for this approach to work. Opening the resultant pimped up &lt;span style="font-style: italic;"&gt;.ps&lt;/span&gt; file with Preview.app resulted in the well-known hangup. Hmmm, &lt;span style="font-style: italic;"&gt;.pfb&lt;/span&gt; is apparently not palatable for Preview.app.&lt;br /&gt;&lt;br /&gt;So I began digging deeper. It looked like there is a PSNormalizer entry in the &lt;span style="font-style: italic;"&gt;/tmp/&lt;/span&gt; directory. It seems to be the bastard child of Distiller, licensed to Apple from Adobe. I figured it also has a command-line interface &lt;span style="font-style: italic;"&gt;pstopdf&lt;/span&gt; too. PSNormalizer seems to be a private system framework, with a certain directory structure. After finding it on my HD, I could examine its contents. There is a Resource/ directory with fonts/ in it. I dropped my &lt;span style="font-style: italic;"&gt;.pfb&lt;/span&gt; there. Hangup. At least I knew now that I am on the right path. PSNormalizer looks for fonts in Resource/fonts/ and after that in ~/Library/Fonts and the global /Library/Fonts.&lt;br /&gt;Resource/fonts/ has two files in it, one of them being Courier. Looking at the dump, it seemed very close to &lt;span style="font-style: italic;"&gt;.pfb&lt;/span&gt; files, but all ascii. It must be a &lt;span style="font-style: italic;"&gt;.pfa&lt;/span&gt; file! From here it was easier to proceed:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;grabbing a pfb2pfa converter from CTAN (part of &lt;a href="http://www.ctan.org/tex-archive/fonts/utilities/ps2mf/"&gt;ps2mf&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;with a small script converting all &lt;span style="font-style: italic;"&gt;.pfb&lt;/span&gt;s to &lt;span style="font-style: italic;"&gt;.pfa&lt;/span&gt;s&lt;/li&gt;&lt;li&gt;dropping these into Resource/fonts/&lt;/li&gt;&lt;li&gt;redistilling&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;This time it worked! But it is tiresome to invoke Preview.app all the time using the mouse, so I am using &lt;span style="font-style: italic;"&gt;pstopdf&lt;/span&gt; now, which is a perfect substitute for &lt;span style="font-style: italic;"&gt;Distiller&lt;/span&gt;. Also I have my &lt;span style="font-style: italic;"&gt;.pfa&lt;/span&gt;s in /Library/Fonts/, so everybody on that Mac has access to them.&lt;br /&gt;&lt;br /&gt;Nevertheless I could relax at this point, and do some experimentation. Here are some things I stumbled upon:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;PSNormalizer/Startup/ can contain arbitrary &lt;span style="font-style: italic;"&gt;.ps&lt;/span&gt; files that are run before each distillation job starts. This can be useful for customization.&lt;/li&gt;&lt;li&gt;Resource/startupNORM.ps contains some interesting code and can probably also be modified.&lt;/li&gt;&lt;li&gt;Using &lt;span style="font-style: italic;"&gt;includeres&lt;/span&gt; with &lt;span style="font-style: italic;"&gt;.pfa&lt;/span&gt; fonts also works.&lt;/li&gt;&lt;li&gt;The PSRESOURCEPATH environment variable does not seen to affect &lt;span style="font-style: italic;"&gt;pstopdf&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;pstopdf&lt;/span&gt; has two brothers, &lt;span style="font-style: italic;"&gt;pstopnm&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;pstops&lt;/span&gt;. I still have to find out what they are good for.&lt;/li&gt;&lt;li&gt;And there is more: &lt;span style="font-style: italic;"&gt;ps2epsi&lt;/span&gt; and many other commands starting with "ps" come from the &lt;span style="font-style: italic;"&gt;Ghostscript&lt;/span&gt; MacPorts package.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;All in all, I feel much better about the PDF-workflow on the Mac now :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5863547898937739368?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5863547898937739368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5863547898937739368' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5863547898937739368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5863547898937739368'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/taming-psnormalizer.html' title='Taming PSNormalizer'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-3289081723613247859</id><published>2007-07-27T18:36:00.000-07:00</published><updated>2007-07-27T20:41:19.709-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='lout'/><category scheme='http://www.blogger.com/atom/ns#' term='PostScript'/><title type='text'>Taming Distiller</title><content type='html'>I happen to use a Mac. This makes me pretty comfortable with viewing and creating PDF files. My favourite typesetting program, &lt;a href="http://lout.sf.net/"&gt;lout&lt;/a&gt;, can also output PDF, but it is rather limited, especially when it comes to graphics. This is why I normally go the longer (but recommended) route via PostScript files.&lt;br /&gt;&lt;br /&gt;Today lout v3.36 arrived, and I gave it a try:&lt;br /&gt;Building on Solaris was a breeze, as always. Thirsting for a challenge, I downloaded some &lt;a href="http://www.ctan.org/tex-archive/fonts/lm/doc/fonts/lm/lm-info.pdf"&gt;&lt;span style="font-style: italic;"&gt;Latin Modern&lt;/span&gt;&lt;/a&gt; fonts (refined versions of Knuth's original &lt;span style="font-style: italic;"&gt;Computer Modern&lt;/span&gt; fonts) and tried to get them running under lout.&lt;br /&gt;&lt;blockquote&gt;It was not easy.&lt;/blockquote&gt;Not being a font expert, first I was overwhelmed by the &lt;span style="font-style: italic;"&gt;.afm&lt;/span&gt; &lt;span style="font-style: italic;"&gt;.pfb&lt;/span&gt; files from the CTAN site. I did not know where to put them, so that I simply dropped them beside my &lt;span style="font-style: italic;"&gt;.lout&lt;/span&gt; file. It did not work, &lt;span style="font-style: italic;"&gt;of course&lt;/span&gt;. I had to pass "-F ." to lout to find them. (Lout is only interested in &lt;span style="font-style: italic;"&gt;.afm&lt;/span&gt;, font metrics, files.)&lt;br /&gt;I also had to prepare a @FontDef database, but there were enough examples in the web.&lt;br /&gt;After a lot of googling I figured out the PSRESOURCEPATH environment variable. It must have this format: "path1:path2::" and is used for searching diverse PostScript resources. Using it, I could stash my fonts away in a different location.&lt;br /&gt;&lt;br /&gt;There is a handy utility I stumbled upon, &lt;a href="http://www.delorie.com/gnu/docs/dgs/makepsres.man.html"&gt;makepsres&lt;/a&gt;, which built up the font inventory inside my newly created /home/ggreif/psres folder. I desisted to fill in the mandatory &lt;span style="font-style: italic;"&gt;PSres.upr&lt;/span&gt; file inside it after three trials in vain.&lt;br /&gt;&lt;br /&gt;So, lout was happy with &lt;span style="font-style: italic;"&gt;lm.ld&lt;/span&gt; and "-F /home/ggreif/psres" and produced a pretty &lt;span style="font-style: italic;"&gt;.ps&lt;/span&gt; for me.&lt;br /&gt;Distiller, on the other hand followed PSRESOURCEPATH and &lt;span style="font-style: italic;"&gt;PSres.upr&lt;/span&gt;, converting the &lt;span style="font-style: italic;"&gt;.ps&lt;/span&gt; into a &lt;span style="font-style: italic;"&gt;.pdf&lt;/span&gt;. So far, so good. (There was still this pesky "unsetenv XUSERFILESEARCHPATH" to do, but I shall spare the details.)&lt;br /&gt;&lt;br /&gt;After understanding the Solaris workflow, I had some hope to successfully repeat this experiment on my Mac too. But that is a story for another day...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-3289081723613247859?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/3289081723613247859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=3289081723613247859' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3289081723613247859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/3289081723613247859'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/taming-distiller.html' title='Taming Distiller'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1549248334331132557</id><published>2007-07-23T05:57:00.000-07:00</published><updated>2007-07-23T06:19:34.651-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><category scheme='http://www.blogger.com/atom/ns#' term='ICFP'/><title type='text'>Endo at end?</title><content type='html'>The &lt;a href="http://www.icfpcontest.org"&gt;ICFP contest&lt;/a&gt; has ended three hours ago. In his blog, &lt;a href="http://johanjeuring.blogspot.com/"&gt;Johan&lt;/a&gt; is optimistic that Endo can be saved. Looking at the &lt;a href="http://www.icfpcontest.org/submits/scoreboard"&gt;scoreboard's&lt;/a&gt; 16+ rankings, this seems unlikely :-/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DylanHackers&lt;/span&gt; (the team I contributed to in some previous contests) did not do so well this time. I dropped off in the first night, reaching a stack overflow error when parsing the supplied DNA's first pattern:&lt;br /&gt;&lt;blockquote&gt;13351PCCPFFP&lt;br /&gt;13361PIIPICP&lt;br /&gt;13371PIIPIIP&lt;br /&gt;Stack space overflow: current size 8388608 bytes.&lt;br /&gt;Use `+RTS -Ksize' to increase it.&lt;br /&gt;13381PFFPCCP&lt;br /&gt;13391PIIPICP&lt;br /&gt;13401PIPIIPF&lt;br /&gt;13411PIIPIIP&lt;br /&gt;13421PIIPICP &lt;/blockquote&gt;Well, at least I managed to parse 1% of the DNA! (The number in front of the RNA fragment signifies the byte position where it comes from the DNA.) Ωmega, being an interpreter on top of Haskell has no efficient means of controlling stack usage, which is consumed quickly, even if my parser was written in tail-recursive style. Hmmm. I did not even bother to submit the low hanging prefix that was published in the task itself. I am really curious if any team reached a 50%+ survival probability.&lt;br /&gt;&lt;br /&gt;In any case the task was really hard this year. On the positive side I saved myself from some frustration and had a wonderful weekend with my family. We celebrated my son's 11th birthday in a &lt;a href="http://tucherland.dfau.de/"&gt;game factory&lt;/a&gt; and my brother visited us with wife and his two children. Sometimes you win by losing...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1549248334331132557?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1549248334331132557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1549248334331132557' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1549248334331132557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1549248334331132557'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/endo-at-end.html' title='Endo at end?'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-932692402836886447</id><published>2007-07-17T13:54:00.000-07:00</published><updated>2007-07-17T14:41:23.895-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Ωmega Tutorial Posted</title><content type='html'>Finally there is a 67 page &lt;a href="http://web.cecs.pdx.edu/%7Esheard/papers/SumSchNotes.ps"&gt;Ωmega introductory text&lt;/a&gt;. Well, actually it is a delta to Haskell, so the audience is Haskell (and perhaps OCaml) savvy folk, but at least one does not need to collect all the information from the &lt;a href="http://web.cecs.pdx.edu/%7Esheard/papers/?M=D"&gt;scattered papers&lt;/a&gt;.&lt;br /&gt;From the first glance I had at it, it describes all the new features neatly, although sometimes the old "#n" notation sneaks in (the new notation is 1v and 1t, for values resp. types).&lt;br /&gt;&lt;br /&gt;I guess this is a live document and Tim together with Nathan will keep it current, cleaning up the few anachronisms as they go.&lt;br /&gt;&lt;br /&gt;I am using &lt;a href="http://web.cecs.pdx.edu/%7Esheard/Omega/index.html"&gt;Ωmega&lt;/a&gt; more than a year now, and can only say that it is a remarkably powerful system. (I shall come back with a more detailed and subjective analysis some other day.)&lt;br /&gt;The thing that fascinates me most, however, is the astonishing stability of this product. Being essentially a one-man show, Tim corrected dozens of errors, that I mailed him, or filed in the new issue tracker at &lt;a href="http://code.google.com/p/omega/issues/list"&gt;googlecode&lt;/a&gt;. It is really hard to find any more serious bugs in the core system. This is also a consequence of Ωmega being written in Haskell, so it inherits all of Haskell's blessings. I wish I were a good Haskell hacker, then I would fix the bugs myself :-/&lt;br /&gt;&lt;br /&gt;The only drawback at the moment is that it is an interpreter, and this fact makes it a bit slow. So a performant version is needed. Then one can think of &lt;a href="http://en.wikipedia.org/wiki/Bootstrapping_%28compilers%29"&gt;bootstrapping&lt;/a&gt; the interpreter/compiler. Ωmega written in itself would definitely be the dream of formal methods coming true!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-932692402836886447?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/932692402836886447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=932692402836886447' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/932692402836886447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/932692402836886447'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/mega-tutorial-posted.html' title='Ωmega Tutorial Posted'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-5439472939931103702</id><published>2007-07-16T02:59:00.000-07:00</published><updated>2007-07-16T03:34:12.189-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><category scheme='http://www.blogger.com/atom/ns#' term='language'/><title type='text'>A Compiler with a Good Clang</title><content type='html'>You probably already know, Apple has &lt;a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2007-July/000000.html"&gt;open-sourced&lt;/a&gt; its new front-end for C-like languages, that has been in development internally for months. Its name is "clang" which is probably a contraction of &lt;span style="font-style: italic;"&gt;C LANGuage&lt;/span&gt;. This name might be related to the email handle of one of its creators Chris Lattner, who is clattner at apple. Its other father is Steve Naroff, who introduced it at the LLVM-developers' meeting back in &lt;a href="http://llvm.org/devmtg/2007-05/index.html"&gt;May&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Of course, nobody writes a C compiler in six months, so this product is not mature yet, its main omission being structure handling, and there are many loose ends to wrap up. Being open source now, with a &lt;a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/LICENSE.TXT?revision=39812&amp;pathrev=39812"&gt;developer-friendly BSD license&lt;/a&gt;, I offered to fill in a bit-sized hole in the implementation, and chose &lt;span style="font-style: italic;"&gt;_Complex&lt;/span&gt; multiplication and comparison operators. The parsing part was already done, AST handling too, only code generation to LLVM IR remaining to be done. I used the analogy principle (addition was already there) and came up with a patch in 30 minutes. After some IRC conversation with Chris and another round of tweaks, I got green light and checked in my changes accompanied with a test. That's it. This is open source at work. Trust, ease of implementation (I barely wrote 30 lines, because of the support for assembling fragments of LLVM is pretty good) plus rigorous code review and finally testcases. There is not much room for bugs and malicious code to hide out.&lt;br /&gt;&lt;br /&gt;It has been a pleasurable experience. I know C++ code that is a nightmare in comparison. If the fathers of &lt;span style="font-style: italic;"&gt;clang&lt;/span&gt; continue as they started and let the many external contributors fill in the missing pieces, this compiler will definitely be one with a good "Klang" (sound, in German).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-5439472939931103702?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/5439472939931103702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=5439472939931103702' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5439472939931103702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/5439472939931103702'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/compiler-with-good-clang.html' title='A Compiler with a Good Clang'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6806763032199553793</id><published>2007-07-15T17:06:00.000-07:00</published><updated>2007-07-15T17:33:28.332-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='research'/><title type='text'>Writing Papers is Hard</title><content type='html'>It is some months ago that I started with my paper &lt;blockquote&gt;"Thrists: Dominoes of Data",&lt;/blockquote&gt; which aims at generalizing function composition and in my opinion is a nice vehicle for other programming tasks too.&lt;br /&gt;It has only nine pages, and the really troublesome areas are still in front:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;writing the references&lt;/li&gt;&lt;li&gt;fine-tuning the text flow&lt;/li&gt;&lt;li&gt;stylistic enhancements&lt;/li&gt;&lt;/ul&gt;I would like to publish it for some serious conference or journal of course, ASAP. This means I have to respect their style guide, which can be non-trivial, as they only provide LaTeX stationery, and I am using &lt;a href="http://lout.sourceforge.net/"&gt;lout&lt;/a&gt; for my typesetting. Looks like I have to transcribe them :-(&lt;br /&gt;&lt;br /&gt;Anyway, today finally I arrived at a point that I can offer an &lt;a href="http://www.opendylan.org/%7Egabor/Thrist-draft-2007-07-16.pdf"&gt;early draft&lt;/a&gt; to the interested public.&lt;br /&gt;The feedback so far appears positive, which makes me spin. Thanks to all who took the trouble of reading through a very rough draft.&lt;br /&gt;&lt;br /&gt;Overall, one can put an infinite amount of work and time into such a short paper, which makes me marvelling at people who seem to produce high-quality papers at a seemingly monthly rate. They must have some secret trick I do not know -- yet!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6806763032199553793?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6806763032199553793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6806763032199553793' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6806763032199553793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6806763032199553793'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/writing-papers-is-hard.html' title='Writing Papers is Hard'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-7948813323217916611</id><published>2007-07-13T10:43:00.000-07:00</published><updated>2007-07-13T19:26:29.351-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ICFP'/><category scheme='http://www.blogger.com/atom/ns#' term='contest'/><title type='text'>Heating up for ICFP Contest</title><content type='html'>Today I started to analyze the &lt;a href="http://johanjeuring.blogspot.com/"&gt;ICFP Contest organizers' blog&lt;/a&gt; in detail. The pictures remind me of &lt;a href="http://www.imdb.com/title/tt0119654/"&gt;MiB&lt;/a&gt;, the commentaries suggest that some fictive language must be decoded.&lt;br /&gt;Fortunately I speak some and learned even more when young, so maybe this is a advantage, we will see.&lt;br /&gt;Anyway, I shall register as a team captain again, maybe I can organize a team here locally. Last year's experience has shown that the contest does not need a geographically concentrated team, but it surely helps.&lt;br /&gt;&lt;blockquote&gt;After last year's pretty good result (&lt;a href="http://www.boundvariable.org/teams.shtml#1439"&gt;place #101&lt;/a&gt;) we have a record to break!&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-7948813323217916611?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/7948813323217916611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=7948813323217916611' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7948813323217916611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7948813323217916611'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/heating-up-for-icfp-contest.html' title='Heating up for ICFP Contest'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6253056871914722420</id><published>2007-07-11T08:38:00.000-07:00</published><updated>2007-07-11T09:11:08.650-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='leipzig'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='research'/><title type='text'>The HaL2 Harvest</title><content type='html'>Yesterday's &lt;a href="http://www.iba-cg.de/haskell.html"&gt;Haskell in Leipzig&lt;/a&gt; was an interesting and entertaining mix of demonstrations of Haskell programming in real life. It was definitely worth my long travel.&lt;br /&gt;The organization of the meeting was excellent, the &lt;a href="http://www.victor-jara-le.de/"&gt;venue&lt;/a&gt; somewhat esoteric for a conference, but could not have been selected better.&lt;br /&gt;Of course I preferred some talks over the others, all in all I returned with some new clues.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The best thing is that the talks and subsequent discussions have been videotaped and should show up on &lt;a href="http://youtube.com/"&gt;Youtube&lt;/a&gt; soon. This way everybody can participate.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Personally I managed to seed some attendants with an early draft of my paper on thrists, I am really curious and anxious about the feedback I get. Already in the car I established a connection between categories and thrists, objects being Ωmega's type level entities and morphisms being the values that populate the first parameter to the thrist. It was very helpful to have a student in my car whom I could abuse as an idea-sink :-). On the return (me being &lt;span style="font-style: italic;"&gt;really&lt;/span&gt; sleepy) he payed it back.&lt;br /&gt;At the meeting this idea got consolidated in my discussion to Mr. Zirnstein, who suggested free categories. I am already in the process of integrating this feedback into the paper.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6253056871914722420?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6253056871914722420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6253056871914722420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6253056871914722420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6253056871914722420'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/hal2-harvest.html' title='The HaL2 Harvest'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-618289719222899528</id><published>2007-07-09T15:01:00.000-07:00</published><updated>2007-07-09T15:44:47.780-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='optimization'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>More on Tail Merging</title><content type='html'>In an earlier post I speculated that factoring out &lt;span style="font-style: italic;"&gt;Cat combinators&lt;/span&gt; other than &lt;span style="font-family:courier new;"&gt;Dup&lt;/span&gt; would just be a matter of &lt;span style="font-style: italic;"&gt;copy-and-paste&lt;/span&gt; (I used the euphemism &lt;span style="font-style: italic;"&gt;boilerplate&lt;/span&gt; back then). It came to me as a shocking revelation that the Ωmega interpreter did not agree. It asserted that&lt;br /&gt;&lt;blockquote style="font-style: italic;"&gt;type _d is equated to type _e&lt;/blockquote&gt;which is inacceptable. The error message was not exactly like this, but very similar. It took me some time to understand it. First I wrote an even shorter function than the one-liner that caused the error. It only happened when I recombined the two shortened &lt;span style="font-family:courier new;"&gt;If&lt;/span&gt; legs (that is, after removing a &lt;span style="font-family:courier new;"&gt;Print&lt;/span&gt; from each).&lt;br /&gt;This piqued my curiosity and I made an excursion into Ωmega's &lt;span style="font-style: italic;"&gt;interactive typecheck mode&lt;/span&gt;, just to discover that the two &lt;span style="font-family:courier new;"&gt;If&lt;/span&gt; legs ended with different stack configurations!&lt;br /&gt;&lt;br /&gt;This put me over the top, and I could come up with an example immediately:&lt;br /&gt;&lt;blockquote style="font-family: courier new;"&gt;If [Push 42, Print] [Push True, Print]&lt;/blockquote&gt;is a case where the &lt;span style="font-family:courier new;"&gt;Print&lt;/span&gt; cannot be removed without violating the invariant that the exit stack configurations at both &lt;span style="font-family:courier new;"&gt;If&lt;/span&gt; legs must be the same. In this case the yes-leg would have an &lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;Int&lt;/span&gt; at &lt;span style="font-style: italic;"&gt;TOS&lt;/span&gt; and the no-leg a &lt;span style="font-family:courier new;"&gt;Bool&lt;/span&gt;. Since I have to cater for the general case, the removal of a &lt;span style="font-family:courier new;"&gt;Print&lt;/span&gt; is unsound. Ωmega discovered this.&lt;br /&gt;&lt;br /&gt;There are two lessons to be learned from this incident, namely:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;If you see a mysterious error (message), simply provoke the same with a smaller program, and&lt;/li&gt;&lt;li&gt;Ωmega's error messages need to be improved in a way that somehow the piece of code is indicated that gives rise to the erroneous types.&lt;/li&gt;&lt;/ol&gt;In the meantime I have an idea how to find a way to remove that &lt;span style="font-family:courier new;"&gt;Print&lt;/span&gt; anyway. The key is abstract interpretation of the two &lt;span style="font-family:courier new;"&gt;If&lt;/span&gt; legs, to construct a &lt;span style="font-style: italic;"&gt;proof&lt;/span&gt; that the stacks have the same shape immediately before the &lt;span style="font-family:courier new;"&gt;Print&lt;/span&gt;. Given this proof the typechecker can be persuaded to allow the recombination of the shortened legs. But to implement this idea there are many more hours to be spent hacking. It will surely be worth blogging about.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-618289719222899528?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/618289719222899528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=618289719222899528' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/618289719222899528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/618289719222899528'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/more-on-tail-merging.html' title='More on Tail Merging'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-8506192433757875368</id><published>2007-07-08T15:45:00.000-07:00</published><updated>2007-07-08T16:20:36.405-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><category scheme='http://www.blogger.com/atom/ns#' term='language'/><title type='text'>The Grief with "Greif"</title><content type='html'>Are you American? So do you see a difference in the two words of the title beginning with G?&lt;br /&gt;If not, you are in good company. Let me explain...&lt;br /&gt;&lt;br /&gt;My family name (last name) is Gr&lt;span style="font-weight: bold;"&gt;ei&lt;/span&gt;f, it is pronounced with a vowel like in Fr&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;i&lt;/span&gt;&lt;/span&gt;day. It is German, and means &lt;a href="http://en.wikipedia.org/wiki/Griffin"&gt;griffin&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I first noted that the spelling of my name is causing difficulties for Americans, after my colleagues returned from a &lt;a href="http://en.wikipedia.org/wiki/WWDC"&gt;WWDC&lt;/a&gt; in the late '90es. When they mentioned their affiliation while talking to a &lt;a href="http://en.wikipedia.org/wiki/Metrowerks"&gt;Metrowerks&lt;/a&gt; compiler engineer, he responded something like &lt;blockquote&gt;"we know a guy from the same shop, his name is Gabor Gr&lt;span style="font-weight: bold;"&gt;ie&lt;/span&gt;f."&lt;/blockquote&gt;They surely remembered my name because back then I bombarded them with many obscure C++ template compilation bug reports, actually causing them a considerable amount of &lt;span style="font-style: italic;"&gt;grief&lt;/span&gt;. (They were really good in fixing them.)&lt;br /&gt;&lt;br /&gt;Since then this is happening regularly. And I always explain patiently. Now, thanks to this blog, it will suffice to provide an URL :-)&lt;br /&gt;&lt;br /&gt;As an aside, after spending my vacation at &lt;a href="http://en.wikipedia.org/wiki/Fuerteventura"&gt;Fuerteventura&lt;/a&gt; in 2001, back on the airport I bought a bottle of Lanzarote wine with the name &lt;a href="http://www.lanzarote.com/lugares/museovino-en.html"&gt;&lt;span style="font-style: italic;"&gt;El Grifo&lt;/span&gt;&lt;/a&gt;. I have sworn to myself to only open it when I get a son. It took 6 years, and &lt;span style="font-style: italic;"&gt;Helena&lt;/span&gt; came. The wine still tasted good, we enjoyed it with the family.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-8506192433757875368?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/8506192433757875368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=8506192433757875368' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8506192433757875368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/8506192433757875368'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/grief-with-greif.html' title='The Grief with &quot;Greif&quot;'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-7555653532420926758</id><published>2007-07-07T16:18:00.000-07:00</published><updated>2007-07-09T15:47:56.082-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='types'/><category scheme='http://www.blogger.com/atom/ns#' term='optimization'/><category scheme='http://www.blogger.com/atom/ns#' term='omega'/><title type='text'>Tail Merging in Ωmega</title><content type='html'>Today finally I got around improving my &lt;a href="http://cat-language.com/"&gt;Cat-like language&lt;/a&gt; optimizer with a new twist:&lt;br /&gt;I can finally factor out common instructions from the end of the two &lt;span style="font-style: italic;"&gt;If&lt;/span&gt; legs and prepend them to the &lt;span style="font-style: italic;"&gt;If&lt;/span&gt;'s continuation. This wouldn't be an interesting achievement if it wouldn't be written in &lt;a href="http://web.cecs.pdx.edu/%7Esheard/Omega/index.html"&gt;Ωmega&lt;/a&gt;'s type-pedantic fragment. To wit:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;tailMerge False [If [Dup]l [Dup]l, Print]l (revThrist' [Dup]l) (revThrist' [Dup]l) [Print]l&lt;/span&gt;&lt;/li&gt;&lt;li&gt;becomes: &lt;span style="font-size:85%;"&gt;[(PopN 1v),Dup,Print]l : forall a (b:Prod *0).Thrist Cat [Bool,a; b]sh [a; b]sh&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;If you think the above lines are in Chinese, you can stop now. If you discover that the &lt;span style="font-style: italic;"&gt;If&lt;/span&gt; has completely been eliminated and replaced by popping a boolean and duplicating the &lt;span style="font-style: italic;"&gt;TOS&lt;/span&gt;, then you are pretty good in reading obscure code.&lt;br /&gt;The funny thing is that all the types of values that are on the stack are painstakingly tracked, and the transformation is automatically type correct in Cat because it is type checked in the &lt;span style="font-style: italic;"&gt;metalanguage&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;I am sure that similar transformations have been proven type correct (and thus &lt;span style="font-style: italic;"&gt;pretty&lt;/span&gt; correct) before, however I would like to know whether this particular optimization has been already formalized using expressive types.&lt;br /&gt;&lt;br /&gt;The big surprise for me was the fact that writing down the transformation only needed a dozen lines of code, support functions included. Of course, my proof of concept only matches on &lt;span style="font-style: italic;"&gt;Dup&lt;/span&gt; instructions, but the rest is basically boilerplate.&lt;br /&gt;&lt;br /&gt;The second surprise is, that so far I did not need a single &lt;span style="font-style: italic;"&gt;theorem&lt;/span&gt; declaration, an indication that either I am still in very shallow waters regarding the power of Ωmega's typechecker, or my &lt;span style="font-style: italic;"&gt;Thrist&lt;/span&gt; construction is so clever that it provides enough type hints to the &lt;span style="font-style: italic;"&gt;narrowing&lt;/span&gt; engine to deduce all types.&lt;br /&gt;&lt;br /&gt;I am in the process of writing a paper on all this, and - &lt;span style="font-style: italic;"&gt;as always&lt;/span&gt; - need some encouragement. Tail merging will definitely belong to the beef part of it.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-7555653532420926758?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/7555653532420926758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=7555653532420926758' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7555653532420926758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7555653532420926758'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/tail-merging-in-mega.html' title='Tail Merging in Ωmega'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-6826650193770249789</id><published>2007-07-06T15:38:00.000-07:00</published><updated>2007-07-11T09:10:35.421-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='leipzig'/><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='jobs'/><title type='text'>Haskell in Leipzig</title><content type='html'>Next Tuesday I shall visit &lt;a href="http://leipzig.de/int/en/"&gt;HaL2&lt;/a&gt; in the beautiful city of &lt;a href="http://leipzig.de/"&gt;Leipzig&lt;/a&gt;, again. Back in December I already attended, and it has proven to be an excellent platform for encountering members of the functional programming community. Living in a &lt;a href="http://www.erlangen.de/en/"&gt;university city&lt;/a&gt; myself, I sent a mail to a local Haskell tutor and offered to give a lift to interested people.&lt;br /&gt;&lt;br /&gt;To my amazement a student did answer my message and so I won't drive the three hours alone (plus another three backward). It will be a long day, and the last time when I attended with a colleague it has proven very good to have somebody to talk to.&lt;br /&gt;&lt;br /&gt;And I expect there will be plenty to talk about. &lt;a href="http://johanjeuring.blogspot.com/"&gt;Johan Jeuring&lt;/a&gt; will give a short talk, and though I do not expect him to chat about the ICFP contest's secrets, he well may give hints :-)&lt;br /&gt;&lt;br /&gt;The functional programming community is sadly very weak in Germany. All the good people fled the country and are doing research in anglophile countries (UK, US, even Singapore) only few universities are actively supporting FP, such as Aachen and Bonn. In any case some serious networking is needed to spread the acceptance of Haskell in this part of the World. Many professionals would love to do a Haskell job, but there is simply no possibility. Small companies are the most likely ones to venture in the Haskell experiment, the big ones are extremely cautious and full of fear. Security relevant applications could be covered first, and when the productivity and maintainability gains are becoming obvious FP could expand into the classical areas of &lt;span style="font-style: italic;"&gt;machine steering&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;automotive&lt;/span&gt; software. Germany has a lot of these.&lt;br /&gt;&lt;br /&gt;I often use the metaphor of "building pyramids with toothpicks" when some gigantic project is started in Java or (horror!) C++. Who has never written a line of Haskell or Dylan code will never understand this metaphor. Pity.&lt;br /&gt;&lt;br /&gt;So what can we do? I am trying to help others who bring people together. We badly need self-confidence and some pioneering folks who stand up and say: "let's do this task in FP for half the cost and 1/10th of the bugs of the conventional approach, even if it takes the same time in the beginning". Who shoots first?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-6826650193770249789?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/6826650193770249789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=6826650193770249789' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6826650193770249789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/6826650193770249789'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/haskell-in-leipzig.html' title='Haskell in Leipzig'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-1023669533348922198</id><published>2007-07-05T04:38:00.000-07:00</published><updated>2007-07-05T05:08:17.464-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='llvm'/><category scheme='http://www.blogger.com/atom/ns#' term='dylan'/><title type='text'>Committed to LLVM</title><content type='html'>Yesterday I got accepted to the inner circle of &lt;a href="http://llvm.org/"&gt;LLVM&lt;/a&gt; developers by becoming a &lt;span style="font-style: italic;"&gt;committer&lt;/span&gt;. For now I have very humble plans, such as periodically plowing through the sources and sanitizing a bit here and there. This may change to a more active role, but probably not in the form of contributing to llvm-core.&lt;br /&gt;&lt;br /&gt;At least version 2.0 already does contain some stuff from me (improved memory efficiency).&lt;br /&gt;&lt;br /&gt;My first contact to LLVM happened when I &lt;a href="http://www.opendylan.org/cgi-bin/bugzilla/show_bug.cgi?id=7241"&gt;started&lt;/a&gt; a new &lt;a href="http://www.opendylan.org/cgi-bin/viewcvs.cgi/trunk/gwydion/d2c/compiler/cback/"&gt;backend&lt;/a&gt; for the &lt;a href="http://www.gwydiondylan.org/"&gt;d2c&lt;/a&gt; compiler. I found out that the Dylan language and LLVM would be a good match, and that d2c was modular enough to nicely marry these two worlds. I did produce some llvm output, but got distracted soon and the project never became functional. Ah well...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-1023669533348922198?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/1023669533348922198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=1023669533348922198' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1023669533348922198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/1023669533348922198'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/committed-to-llvm.html' title='Committed to LLVM'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8072464059979174136.post-7854851932005960207</id><published>2007-07-04T09:58:00.000-07:00</published><updated>2007-07-04T10:17:43.900-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>How to start?</title><content type='html'>There has been quite a lot movement in my life in the last 2 years, which culminated almost 3 weeks ago with the birth of my daughter &lt;span style="font-style: italic;"&gt;Helena&lt;/span&gt;. (Needless to say that I am the proudest father in the world :-)&lt;br /&gt;So where I am standing now? I have a pretty happy family life, I am feeling the rewards of my professional career and my hobbies give me the self esteem that the researcher is still alive deep inside.&lt;br /&gt;&lt;br /&gt;And what is missing? I miss the time to do more of all this. I also missed a way of articulating my thoughts, sketching my dreams.&lt;br /&gt;&lt;br /&gt;This blog could fill in the latter gap (at the cost of losing even more time ?!?).&lt;br /&gt;Sometimes I need external impulse to drive me in a certain direction. What I put on these pages may motivate others to &lt;span style="font-weight: bold;"&gt;demand&lt;/span&gt; that I implement a cool idea or think harder about some problem.&lt;br /&gt;&lt;br /&gt;Even if it just remains a reminder to self, it may be worth it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8072464059979174136-7854851932005960207?l=heisenbug.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://heisenbug.blogspot.com/feeds/7854851932005960207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8072464059979174136&amp;postID=7854851932005960207' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7854851932005960207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8072464059979174136/posts/default/7854851932005960207'/><link rel='alternate' type='text/html' href='http://heisenbug.blogspot.com/2007/07/how-to-start.html' title='How to start?'/><author><name>heisenbug</name><uri>http://www.blogger.com/profile/11328338875953258337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
