<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   
   xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
    
    <title>nomeata’s mind shares - English</title>
    <link>http://www.joachim-breitner.de/blog/</link>
    <description>Joachim Breitners Denkblogade</description>
    <dc:language>en</dc:language>
    <admin:errorReportsTo rdf:resource="mailto:mail@joachim-breitner.de" />
    <generator>Serendipity 1.7 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://joachim-breitner.de/avatars/avatar_128.png</url>
        <title>RSS: nomeata’s mind shares - English - Joachim Breitners Denkblogade</title>
        <link>http://www.joachim-breitner.de/blog/</link>
        <width>128</width>
        <height>128</height>
    </image>

<item>
    <title>How to play Rock-Paper-Scissors online?</title>
    <link>http://www.joachim-breitner.de/blog/archives/596-How-to-play-Rock-Paper-Scissors-online.html</link>
            <category>Digital World</category>
            <category>English</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/596-How-to-play-Rock-Paper-Scissors-online.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=596</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=596</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;There was an interesting question by ‘Fool’ recently on the StackExchange site for Boardgames: &lt;a href=&quot;http://boardgames.stackexchange.com/questions/11821/abstract-move-holding-service-for-simultaneous-move-board-games&quot;&gt;How do you play a game like Rock-Paper-Scissors with friends online?&lt;/a&gt; Or any other game where players have to simultaneously submit their moves (e.g. Diplomacy, or &lt;a href=&quot;http://en.wikipedia.org/wiki/Rock-paper-scissors-lizard-Spock&quot;&gt;Rock-Paper-Scissors-Lizzard-Spock&lt;/a&gt;), which, as I just learned, are &lt;a href=&quot;http://en.wikipedia.org/wiki/Simultaneous_action_selection&quot;&gt;simultaneous action selection&lt;/a&gt; games. While there are websites dedicated to playing specific games, such as &lt;a href=&quot;http://www.webdiplomacy.net/&quot;&gt;webdiplomacy.net&lt;/a&gt;, we could not find a generic one that you can use if you, for example, invent your own variants of a game.&lt;br /&gt;&lt;/p&gt; 
&lt;p&gt;So I created one: At &lt;a href=&quot;http://you-say-first.nomeata.de&quot;&gt;you-say-first.nomeata.de&lt;/a&gt; you can enter rooms and share the URL with your friends. On the one hand, you have a regular chat room there. But there is also the possibility to enter moves (whatever a move may be to you) and only when all players have done that and marked the move as final, it is shown to everyone. If you want to try it out: There is an integrated, not very fancy Rock-Paper-Scissors-playing bot. Just enter a room, join and say „I want to play!“&lt;br /&gt;&lt;/p&gt; 
&lt;p&gt;Note that this site can be used for more than just for games. Have you ever observed that persons would often want other to express their preference (e.g. where to dine) first to not reveal their own preference, so that they can (or pretend to) change their mind if they would contradict? In such situations simultaneous action selection can be a fairer method.&lt;/p&gt; 
&lt;p&gt;A technical note: I created this web app using &lt;a href=&quot;http://www.meteor.com/&quot;&gt;meteor&lt;/a&gt; (a JavaScript framework building on &lt;a href=&quot;http://nodejs.org/&quot;&gt;node.js&lt;/a&gt; and &lt;a href=&quot;http://www.mongodb.org/&quot;&gt;MongoDB&lt;/a&gt; that allows for reactive programming), and it is also hosted on meteor.com. I chose Meteor after someone mentioned &lt;a href=&quot;https://www.firebase.com/&quot;&gt;Firebase&lt;/a&gt; to me, which looked very slick, but was not Free Software, so I looked for alternatives. I did not do any cross-browser-testing, and the UI design could be improved, so if you want to help out (or just complain), please use the &lt;a href=&quot;https://github.com/nomeata/you-say-first&quot;&gt;GitHub code repository&lt;/a&gt; and &lt;a href=&quot;https://github.com/nomeata/you-say-first/issues&quot;&gt;issue tracker&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sat, 11 May 2013 12:26:57 +0200</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/596-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F596-How-to-play-Rock-Paper-Scissors-online.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>The carbondioxide footprint of Debian's Haskell packages</title>
    <link>http://www.joachim-breitner.de/blog/archives/593-The-carbondioxide-footprint-of-Debians-Haskell-packages.html</link>
            <category>Debian</category>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/593-The-carbondioxide-footprint-of-Debians-Haskell-packages.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=593</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=593</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;
By now, Debian ships quite &lt;a href=&quot;http://qa.debian.org/developer.php?login=pkg-haskell-maintainers@lists.alioth.debian.org&quot;&gt;a lot of Haskell packages&lt;/a&gt; (~600). Because of GHC&#039;s ABI volatility, whenever we upload a new version of a library, we have to rebuild all libraries that depend on that. In particular, if we upload a new version of the compiler itself, we have to rebuild all Haskell library packages. So we have to rebuild stuff a lot. Luckily, Debian has a &lt;a href=&quot;https://buildd.debian.org/&quot;&gt;decent autobuilding setup&lt;/a&gt; so that I just need to tell it what to rebuild, and the rest happens automatically (including &lt;a href=&quot;http://upsilon.cc/~zack/blog/posts/2009/07/wanna-build_gains_detection_of_uninstallable_build-deps/&quot;&gt;figuring out the actual order to build things&lt;/a&gt;). &lt;br /&gt;&lt;/p&gt; 
&lt;p&gt;I was curious how much we use the buildd system compared to other packages, and also how long the builders are busy building Haskell packages. All the data is in a postgresql database on buildd.debian.org, so with some python and javascript code, I can visualize this. &lt;a href=&quot;https://buildd.debian.org/~nomeata/graphs.cgi&quot;&gt;The graphs&lt;/a&gt; show the number of all uploads by autobuilder on the amd64 architecture, with haskell uploads specially marked, and the second graph does the same for the build time. You can select time ranges and get aggregate statistics for that time span.&lt;/p&gt; 
&lt;p&gt;During the last four days a complete rebuild was happening, due to the upload of GHC 7.6.3. During these 2 days and 18 hours building 537 packages took 48 hours of build time and produced 15kg of CO&lt;sub&gt;2&lt;/sub&gt;. That is 94% of all uploads and 91% the total build time&lt;sub&gt;&lt;/sub&gt;. The numbers are lower for the whole of last year: 52% of uploads, 31% of build time and 57kg of CO&lt;sub&gt;2&lt;/sub&gt;. (The CO&lt;sub&gt;2&lt;/sub&gt; numbers are very rough estimates.)&lt;br /&gt;&lt;/p&gt; 
&lt;p&gt;Note that amd64 is a bit special, as most packages are uploaded on this architecture by the developers, so no automatic builds are happening. On other architectures have, every upload of a (arch:any) package is built, so the share of Haskell packages will be lower. Unfortunately, at the moment the database does not provide me with a table across all architectures (and I was too lazy to make it configurable yet).&lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Wed, 24 Apr 2013 13:36:02 +0200</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/593-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F593-The-carbondioxide-footprint-of-Debians-Haskell-packages.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Evaluation-State Assertions in Haskell</title>
    <link>http://www.joachim-breitner.de/blog/archives/590-Evaluation-State-Assertions-in-Haskell.html</link>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/590-Evaluation-State-Assertions-in-Haskell.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=590</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=590</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;I have just uploaded a new version of &lt;a href=&quot;http://hackage.haskell.org/package/ghc-heap-view&quot;&gt;ghc-heap-view&lt;/a&gt; to Hackage that provides “Evaluation state assertions” in the module &lt;a href=&quot;http://hackage.haskell.org/packages/archive/ghc-heap-view/0.4.2.0/doc/html/GHC-AssertNF.html&quot;&gt;&lt;tt&gt;GHC.AssertNF&lt;/tt&gt;&lt;/a&gt;.&lt;/p&gt; 
&lt;p&gt;Imagine you are writing a web application in Haskell that sports a global number-of-visitors counter in an &lt;tt&gt;&lt;a href=&quot;http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-IORef.html#t:IORef&quot;&gt;IORef&lt;/a&gt; Int&lt;/tt&gt;. For every request, you call &lt;tt&gt;&lt;a href=&quot;http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-IORef.html#v:modifyIORef&quot;&gt;modifyIORef&lt;/a&gt; (+1)&lt;/tt&gt;. Eventually, you notice your very popular web site to hog more and more memory. So you browse to the internal page that shows the counter, and you have to wait for a long time until you eventually see the result (or get a stack overflow). The reason: The applications of&amp;#160; &lt;tt&gt;(+1)&lt;/tt&gt; were not performed until you looked at the number; instead, a long chain of such computation first filled your heap and then your stack.&lt;/p&gt; 
&lt;p&gt;So you have learned the hard way that you might want to avoid space leaks, and want calculations to be done during the request that caused them, and want the &lt;tt&gt;IORef&lt;/tt&gt; to always contain fully evaluated data. So you stumble about &lt;a href=&quot;http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-IORef.html#v:modifyIORef-39-&quot;&gt;&lt;tt&gt;modifyIORef&#039;&lt;/tt&gt;&lt;/a&gt; in &lt;tt&gt;Data.IORef&lt;/tt&gt; and indeed, this fixes your problem.&lt;/p&gt; 
&lt;p&gt; Later, you notice that you want to count &lt;tt&gt;POST&lt;/tt&gt; and &lt;tt&gt;GET&lt;/tt&gt; requests separately. You change the type to &lt;tt&gt;IORef (Int, Int)&lt;/tt&gt; and call &lt;tt&gt;modifyIORef&#039; (&lt;a href=&quot;http://www.haskell.org/ghc/docs/latest/html/libraries/base//Control-Arrow.html#v:first&quot;&gt;first&lt;/a&gt; (+1))&lt;/tt&gt; or &lt;tt&gt;modifyIORef&#039; (&lt;a href=&quot;http://www.haskell.org/ghc/docs/latest/html/libraries/base//Control-Arrow.html#v:second&quot;&gt;second&lt;/a&gt; (+1))&lt;/tt&gt;. And suddenly, the space leak is back (which you only notice after the next push to the real site, because your local tests never caused enough requests to make it noticeable). So you not only want to fix it, you also want to ensure that it does not break again.&lt;/p&gt; 
&lt;p&gt;In other words, you want to ensure the policy that values stored in an &lt;tt&gt;IORef&lt;/tt&gt; are always in normal form. You achieve this with the following alternative to &lt;tt&gt;modifyIORef&#039;&lt;/tt&gt;:&lt;/p&gt; 
&lt;pre&gt;modifyIORef&#039;Assert :: IORef a -&amp;gt; (a -&amp;gt; a) -&amp;gt; IO ()
modifyIORef&#039;Assert ref f = do
    x &amp;lt;- readIORef ref
    let x&#039; = f x
    x&#039; `seq` return ()
    &lt;a title=&quot;&quot; target=&quot;&quot; href=&quot;http://hackage.haskell.org/packages/archive/ghc-heap-view/0.4.2.0/doc/html/GHC-AssertNF.html#v:assertNF&quot;&gt;assertNF&lt;/a&gt; x&#039;
    writeIORef ref x&#039;&lt;/pre&gt; 
&lt;p&gt;Using this instead of &lt;tt&gt;modifyIORef&#039;&lt;/tt&gt; will print this warning to standard error output right the first time you call &lt;tt&gt;modifyIORef&#039;Assert (first (+1))&lt;/tt&gt;:&lt;/p&gt; 
&lt;pre&gt;Parameter not in normal form: 2 thunks found:
let x1 = (S# 1,S# 1)
in _bh (_thunk x1 (_bco (S# 1)),_sel x1)
&lt;/pre&gt; 
&lt;p&gt;(Otherwise, the program runs as usual.) So obviously, you need to use a strict variant of &lt;tt&gt;first&lt;/tt&gt; (or &lt;a href=&quot;http://hackage.haskell.org/packages/archive/strict/0.3.2/doc/html/Data-Strict-Tuple.html&quot;&gt;strict pairs&lt;/a&gt;):&lt;/p&gt; 
&lt;pre&gt;first&#039; :: (a -&amp;gt; b) -&amp;gt; (a, c) -&amp;gt; (b, c)
first&#039; f (x,y) = let { x&#039; = f x; r = (x&#039;, y) } in x&#039; `seq` r `seq` r
&lt;/pre&gt; 
&lt;p&gt;With this, the warning goes away. Whenever you now change the type of the &lt;tt&gt;IORef&lt;/tt&gt; or modify it in a too-lazy-way, you can be sure that you’ll be warned about it, before the space leak itself becomes noticeable.&lt;/p&gt; 
&lt;p&gt;In the production code, you might want to disable the check. For that, simply put &lt;a href=&quot;http://hackage.haskell.org/packages/archive/ghc-heap-view/0.4.2.0/doc/html/GHC-AssertNF.html#v:disableAssertNF&quot;&gt;&lt;tt&gt;disableAssertNF&lt;/tt&gt;&lt;/a&gt; somewhere in your main function.&lt;/p&gt; 
&lt;p&gt;Why is this better than just calling &lt;a href=&quot;http://hackage.haskell.org/packages/archive/deepseq/1.3.0.1/doc/html/Control-DeepSeq.html#v:deepseq&quot;&gt;&lt;tt&gt;deepseq&lt;/tt&gt;&lt;/a&gt; in &lt;tt&gt;modifyIORef&#039;Assert&lt;/tt&gt;? Because this way, the code still creates unwanted thunks that are then evaluated before storing them in the &lt;tt&gt;IORef&lt;/tt&gt;, whereas with &lt;tt&gt;assertNF&lt;/tt&gt; you are told about the thunks and can prevent them from being created in the first place. Also, &lt;tt&gt;assertNF&lt;/tt&gt; does not add a type class constraint.&lt;/p&gt; 
&lt;p&gt;This is just one example application for &lt;tt&gt;assertNF&lt;/tt&gt; (and its variants &lt;a href=&quot;http://hackage.haskell.org/packages/archive/ghc-heap-view/0.4.2.0/doc/html/GHC-AssertNF.html#v:assertNFNamed&quot;&gt;&lt;tt&gt;assertNFNamed&lt;/tt&gt;&lt;/a&gt;, which includes a name in the warning to better spot the cause, and &lt;tt&gt;$&lt;a href=&quot;http://hackage.haskell.org/packages/archive/ghc-heap-view/0.4.2.0/doc/html/GHC-AssertNF.html#v:assertNFHere&quot;&gt;assertNFHere&lt;/a&gt;&lt;/tt&gt;, which uses Template Haskell to include the current source code position in the warning), and I hope that there are more. If you happen to make use of it, I’d like to hear your story.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Wed, 06 Feb 2013 10:33:03 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/590-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F590-Evaluation-State-Assertions-in-Haskell.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Going to FOSDEM after all</title>
    <link>http://www.joachim-breitner.de/blog/archives/586-Going-to-FOSDEM-after-all.html</link>
            <category>Debian</category>
            <category>English</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/586-Going-to-FOSDEM-after-all.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=586</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=586</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;Earlier this week, things were looking different, and I did have to cancel a Haskell talk in Freiburg on Monday due to illness. But I’m back on track and will be travelling to Brussels tomorrow.&lt;/p&gt;
&lt;p&gt;I’ll be holding a talk on how we package &lt;a href=&quot;https://fosdem.org/2013/schedule/event/debian_haskell/&quot;&gt;Haskell in Debian&lt;/a&gt;, on Suday at 15:30. I hope it will be useful to Debian users (who will better understand the packaging), other Debian Developers (who’ll learn about the peculiarities of Haskell and the implications for the Debian infrastructure), other distro’s maintainers (to compare best practices) and Haskell developers (to learn about the needs and worries of downstream packages). The talk will be based on &lt;a href=&quot;http://penta.debconf.org/dc11_schedule/events/791.en.html&quot;&gt;my DebConf 11 talk&lt;/a&gt; on the same topic. I’m also happy to answer questions about Haskell, Haskell in Debian or any other topic that you want to hear my opinion about, so just talk to me during FOSDEM.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;In related news: GHC 7.6.2 was uploaded to Debian experimental the day it was released; the rebuilding of all libraries is still in progress (~370 of ~570 done).&lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 31 Jan 2013 21:03:50 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/586-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F586-Going-to-FOSDEM-after-all.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>“Haskell Bytes” again</title>
    <link>http://www.joachim-breitner.de/blog/archives/584-Haskell-Bytes-again.html</link>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/584-Haskell-Bytes-again.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=584</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=584</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;&lt;a href=&quot;http://www.iai.uni-bonn.de/~jv/&quot;&gt;Janis Voigtländer&lt;/a&gt; has invited me again to give a lecture in his &lt;a href=&quot;http://www.iai.uni-bonn.de/~jv/teaching/ffp12/&quot;&gt;Advanced Functional Programming&lt;/a&gt; course at the University of Bonn. Like last time, when I talked about &lt;a href=&quot;http://www.joachim-breitner.de/blog/archives/539-Guest-lecture-on-Haskell-performance.html&quot;&gt;performance analysis in Haskell&lt;/a&gt;, I chose a topic that is more on implementationishy side to contrast the theoretic content of the rest of the course. I recycled &lt;a href=&quot;http://www.joachim-breitner.de/blog/archives/558-Haskell-Bytes.html&quot;&gt;my talk on the memory representation of GHC&lt;/a&gt; that I have held at last year’s &lt;a href=&quot;http://mrmcd.net/&quot;&gt;Meta Main-Rhein Chaos Days&lt;/a&gt;. As usual I provide a &lt;a href=&quot;http://www.joachim-breitner.de/publications/haskell_bytes_bonn_2013-01-10.pdf&quot;&gt;transcript of the talk&lt;/a&gt; as intended (not as held). It is slightly revised over the old version and I have added a section on unboxed values in constructors, which I have nevertheless skipped today.&lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 10 Jan 2013 23:24:26 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/584-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F584-Haskell-Bytes-again.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>GHCi integration for GHC.HeapView</title>
    <link>http://www.joachim-breitner.de/blog/archives/580-GHCi-integration-for-GHC.HeapView.html</link>
            <category>Digital World</category>
            <category>English</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/580-GHCi-integration-for-GHC.HeapView.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=580</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=580</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;Given the very positive feedback for Dennis Felsing’s tool &lt;a href=&quot;http://felsin9.de/nnis/ghc-vis/&quot;&gt;ghc-vis&lt;/a&gt;, which visualizes the heap representation of a Haskell value, including all the gory details such as thunks, values retained by thunks indirections, sharing etc, I saw the need to provide this information also directly in GHCi, without having to load a graphics library or opening extra libraries. So I added the required features (traversing the heap and pretty-printing the results) to my &lt;a href=&quot;http://hackage.haskell.org/package/ghc-heap-view&quot;&gt;ghc-heap-view&lt;/a&gt; package and, also following ghc-vis’s lead, added a ghci file that, when loaded, provides you with a &lt;tt&gt;:printHeap&lt;/tt&gt; command. Here you can see it in action:&lt;/p&gt; 
&lt;h3&gt;A plain value&lt;/h3&gt; 
&lt;pre&gt;Prelude&amp;gt; :script /home/jojo/.cabal/share/ghc-heap-view-0.4.0.0/ghci
Prelude&amp;gt; let x = [1..10]
Prelude&amp;gt; x
[1,2,3,4,5,6,7,8,9,10]
Prelude&amp;gt; :printHeap x
_bh [S# 1,S# 2,S# 3,S# 4,S# 5,S# 6,S# 7,S# 8,S# 9,S# 10]
&lt;/pre&gt; 
&lt;p&gt;Note that the tools shows us that the list is a list of &lt;a href=&quot;http://www.haskell.org/ghc/docs/7.6.1/html/libraries/integer-gmp-0.5.0.0/GHC-Integer-GMP-Internals.html&quot;&gt;&lt;tt&gt;S#&lt;/tt&gt;&lt;/a&gt; constructors, and also that it is still hidden behind a blackhole. After running &lt;a href=&quot;http://hackage.haskell.org/packages/archive/base/latest/doc/html/System-Mem.html#v:performGC&quot;&gt;&lt;tt&gt;System.Mem.performGC&lt;/tt&gt;&lt;/a&gt;, this disappears.
&lt;/p&gt; 
&lt;h3&gt;A thunk&lt;/h3&gt; 
&lt;pre&gt;Prelude&amp;gt; let x = Just (1 + 1)
Prelude&amp;gt; :printHeap x
Just _bco
Prelude&amp;gt; x
Just 2
Prelude&amp;gt; System.Mem.performGC
Prelude&amp;gt; :printHeap x
Just (S# 2)&lt;/pre&gt; 
&lt;p&gt;Here, we see how the calculation was deferred until forced by showing the value of &lt;tt&gt;x&lt;/tt&gt;. The name &lt;tt&gt;_bco&lt;/tt&gt; stands for a bytecode object as used by the interpreter. Getting useful information from them is a bit harder than for compiled thunks, so for more accurate results put the code in a Haskell source file, compile it and use the &lt;a href=&quot;http://hackage.haskell.org/packages/archive/ghc-heap-view/latest/doc/html/GHC-HeapView.html&quot;&gt;GHC.HeapView&lt;/a&gt; API to print the interesting parts. &lt;/p&gt; 
&lt;h3&gt;A partial application&lt;/h3&gt; 
&lt;pre&gt;Prelude&amp;gt; let a = &quot;hi&quot;
Prelude&amp;gt; let partial = (a ++)
Prelude&amp;gt; partial &quot;&quot;
&quot;hi&quot;
Prelude&amp;gt; System.Mem.performGC
Prelude&amp;gt; let x = (a, partial)
Prelude&amp;gt; :printHeap x
let x1 = &quot;hi&quot;
in (x1,_fun x1)&lt;/pre&gt; 
&lt;p&gt;The information &lt;emph&gt;which&lt;/emph&gt; function is called there (&lt;tt&gt;++&lt;/tt&gt; in this case) is lost at runtime, but we still see that the second element of the tuple is a partial application of &lt;emph&gt;some&lt;/emph&gt; value to the first element.&lt;/p&gt; 
&lt;h3&gt;A cyclic structure&lt;/h3&gt; 
&lt;pre&gt;Prelude&amp;gt; let s = &quot;ho&quot;
Prelude&amp;gt; let x = cycle s
Prelude&amp;gt; length (take 100 (show x))
100
Prelude&amp;gt; System.Mem.performGC
Prelude&amp;gt; :printHeap x
let x0 = C# &#039;h&#039; : C# &#039;o&#039; : x0
in x0
Prelude&amp;gt; let y = map Data.Char.toUpper x
Prelude&amp;gt; length (take 100 (show y))
100
Prelude&amp;gt; :printHeap y
C# &#039;H&#039; : C# &#039;O&#039; : C# &#039;H&#039; : C# &#039;O&#039; : C# &#039;H&#039; : C# &#039;O&#039; : C# &#039;H&#039; : C# &#039;O&#039; : C# &#039;H&#039; : C# &#039;O&#039; : _bh (C# &#039;H&#039; : C# &#039;O&#039; : C# &#039;H&#039; : C# &#039;O&#039; : C# &#039;H&#039; : C# &#039;O&#039; : C# &#039;H&#039; : C# &#039;O&#039; : ... : ...)
&lt;/pre&gt; 
&lt;p&gt;The cyclic, tying-the-knot structure of &lt;a href=&quot;http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:cycle&quot;&gt;&lt;tt&gt;cycle&lt;/tt&gt;&lt;/a&gt; is very visible. But can also see how easily it is broken, in this case by mapping a function over the list.&lt;/p&gt; 
&lt;h3&gt;Mutual recursion&lt;/h3&gt;
&lt;pre&gt;Prelude&gt; let {x = &#039;H&#039; : y ; y = &#039;o&#039; : x }
Prelude&gt; length (show (take 10 x, take 10 y)) `seq` return ()
Prelude&gt; System.Mem.performGC
Prelude&gt; :printHeap (x,y)
let x1 = C# &#039;H&#039; : x3
    x3 = C# &#039;o&#039; : x1
in (x1,x3)&lt;/pre&gt;
&lt;p&gt;If you want to look at multiple variables at once, just pass a tuple to &lt;tt&gt;printHeap&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;In the hope that this will be a useful tool for you, I uploaded version 0.4.0.0 of ghc-heap-view to hackage.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 20 Dec 2012 14:09:20 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/580-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F580-GHCi-integration-for-GHC.HeapView.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Circle Packing</title>
    <link>http://www.joachim-breitner.de/blog/archives/578-Circle-Packing.html</link>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/578-Circle-Packing.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=578</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=578</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;For an &lt;a href=&quot;http://www.meetup.com/The-Karlsruhe-Functional-Programmers-Meetup-Group/events/93934702/&quot;&gt;upcoming introductory Haskell talk&lt;/a&gt; of mine (next Tuesday in Karlsruhe – please come and join if you will) I was looking into data visualization as a example application. With libraries like &lt;a href=&quot;http://gloss.ouroborus.net/&quot;&gt;gloss&lt;/a&gt;, getting some nice vector graphics up and running within one talk is quite possible.&lt;/p&gt; 
&lt;p&gt;For some reason, I want to arrange multiple circles of varying size so that they do not overlap and use as little space as possible. My first approach was to use general purpose optimizers such as &lt;a href=&quot;http://hackage.haskell.org/package/cmaes&quot;&gt;cmaes&lt;/a&gt;, &lt;a href=&quot;http://hackage.haskell.org/packages/archive/hmatrix/latest/doc/html/Numeric-GSL-Minimization.html&quot;&gt;Numeric.GSL.Minimization&lt;/a&gt; from the &lt;a href=&quot;http://hackage.haskell.org/package/hmatrix&quot;&gt;hmatrix&lt;/a&gt; package and &lt;a href=&quot;http://hackage.haskell.org/package/force-layout&quot;&gt;force-layout&lt;/a&gt;. I especially liked the interface of cmaes, which is able to minimize a function of, say, type &lt;tt&gt;[(String, Double, Double)] -&amp;gt; Double&lt;/tt&gt; by automatically finding the values of type &lt;tt&gt;Double&lt;/tt&gt; in the input, as described by &lt;a href=&quot;http://www.haskell.org/pipermail/haskell-cafe/2012-October/103733.html&quot;&gt;Takayuki Muranushi&lt;/a&gt;. That would have looked great in the talk. Unfortunately, none of these libraries gave sufficient good results in a reasonable amount of time for this problem.&lt;/p&gt; 
&lt;p&gt;I then reviewed some of the academic literature on the circle packing problem and there were some algorithms proposed, but no simple one and none of the papers had a concise pseudo-code description that I could transfer to Haskell.&lt;/p&gt; 
&lt;p&gt;So eventually I set out to implement a relatively dump and slow greedy algorithm myself: I place one circle after another, starting with the largest, and among the valid positions where a new circle touches two already placed circles, I choose the positions closest to the center of mass. The result, available in &lt;a href=&quot;http://hackage.haskell.org/package/circle-packing&quot;&gt;the circle-packing package&lt;/a&gt;, looks surprisingly well, here visualized using the diagrams library (See the documentation of &lt;a href=&quot;http://hackage.haskell.org/packages/archive/circle-packing/latest/doc/html/Optimisation-CirclePacking.html&quot;&gt;Optimisation.CirclePacking&lt;/a&gt; for the code used to generate that image):&lt;/p&gt; 
&lt;div align=&quot;center&quot;&gt;&lt;img width=&quot;400&quot; height=&quot;400&quot; src=&quot;http://darcs.nomeata.de/circle-packing/example.svg&quot; /&gt;&lt;/div&gt; 
&lt;p&gt;Now showing just this image is not a very good way to demonstrate my code. A few years ago, I might have created a CGI script that would dynamically generate images based on your input. But not in 2012: Since &lt;a href=&quot;http://darcs.nomeata.de/circle-packing/Optimisation/CirclePacking.hs&quot;&gt;my code&lt;/a&gt; is pure Haskell without &lt;a href=&quot;https://github.com/faylang/fay/issues/98&quot;&gt;fancy features&lt;/a&gt; like type classes, I can use the &lt;a href=&quot;http://fay-lang.org/&quot;&gt;fay compiler&lt;/a&gt; to generate JavaScript code from it. Add a little &lt;a href=&quot;http://darcs.nomeata.de/circle-packing/fay/fay-demo.hs&quot;&gt;Haskell code to interact with the HTML5 canvas&lt;/a&gt; and now you can &lt;a href=&quot;http://darcs.nomeata.de/circle-packing/fay/fay-demo.html&quot;&gt;interactively try out circle-packing in your browser&lt;/a&gt;.&lt;/p&gt; 
&lt;p&gt;Oh, and while I am talking about neat tricks: You can put vector graphics in your haddock documentation, as I have done for Optimisation.CirclePacking, using the syntax &lt;tt&gt;&amp;lt;&amp;lt;&amp;lt;data:image/svg+xml;base64,PD94bWwgdmV...c3ZnPg==&amp;gt;&amp;gt;.&lt;/tt&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 16 Dec 2012 19:04:17 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/578-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F578-Circle-Packing.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Plätzchentetris</title>
    <link>http://www.joachim-breitner.de/blog/archives/575-Plaetzchentetris.html</link>
            <category>Digital World</category>
            <category>English</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/575-Plaetzchentetris.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=575</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=575</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;What happens if the same person (in this case, my girlfriend) is both a bit geeky &lt;em&gt;and&lt;/em&gt; likes to bake? She has ideas leading to this:&lt;/p&gt; 
&lt;div align=&quot;center&quot;&gt;&lt;a href=&quot;http://www.joachim-breitner.de/bilder/pages/201214_1.html&quot;&gt;&lt;img width=&quot;700&quot; height=&quot;525&quot; src=&quot;http://www.joachim-breitner.de/bilder/previews/20121212221845_preview.jpg&quot; alt=&quot;Tetris Biscuits&quot; /&gt;&lt;/a&gt;&lt;/div&gt; 
&lt;p&gt;And what is the obvious thing to do with such biscuit (or are they cookies?). Play tetris:&lt;/p&gt; 
&lt;div align=&quot;center&quot;&gt; &lt;video width=&quot;960&quot; height=&quot;720&quot; tabindex=&quot;0&quot; poster=&quot;http://www.joachim-breitner.de/various/Plaetzchentetris-poster.jpg&quot; controls=&quot;true&quot;&gt; &lt;source src=&quot;http://www.joachim-breitner.de/various/Plaetzchentetris.webm&quot; type=&quot;video/webm&quot; /&gt; &lt;source src=&quot;http://www.joachim-breitner.de/various/Plaetzchentetris.avi&quot; type=&quot;video/x-msvideo&quot; /&gt;
        Your browser does not support the video tag. Try youtube instead!
&lt;/video&gt; &lt;/div&gt; 
&lt;p&gt;(Also &lt;a href=&quot;https://www.youtube.com/watch?v=0USmmPXVrr4&quot;&gt;on YouTube&lt;/a&gt; if your browser does not play the video above.)&lt;/p&gt; 
&lt;p&gt;Oh, and to refute common stereotypes about me: The baking was done by me, but she helped me glazing the biscuits.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Fri, 14 Dec 2012 19:07:00 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/575-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F575-Plaetzchentetris.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Calculating the internal rate of return with hledger</title>
    <link>http://www.joachim-breitner.de/blog/archives/573-Calculating-the-internal-rate-of-return-with-hledger.html</link>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/573-Calculating-the-internal-rate-of-return-with-hledger.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=573</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=573</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;For more than ten years now, I am a regular and happy user of &lt;a href=&quot;http://www.gnucash.org/&quot;&gt;GnuCash&lt;/a&gt;, the free accountancy program. Especially the integrated online banking support for &lt;a href=&quot;http://en.wikipedia.org/wiki/HBCI&quot;&gt;HBCI&lt;/a&gt; that allows me not only to fetch my transactions, but also to transfer money using a cryptographic makes it a great tool. Nevertheless, it has shortcomings, especially when it comes to reports. And for some reason I never felt the urge to hack on that C/Guile code (although I recently &lt;a href=&quot;https://bugzilla.gnome.org/show_bug.cgi?id=120854&quot;&gt;hacked a bit on the UI&lt;/a&gt;).&lt;br /&gt;&lt;/p&gt; 
&lt;p&gt;&lt;a href=&quot;http://joeyh.name/blog/entry/hledger/&quot;&gt;Joey Hess’ blog post&lt;/a&gt; about Simon
Michael’s &lt;a href=&quot;http://hledger.org/&quot;&gt;hledger&lt;/a&gt; made me look at that command line based accountancy tool. It certainly won’t replace Gnucash for me, but luckily &lt;a href=&quot;http://ledger-cli.org/&quot;&gt;ledger&lt;/a&gt;, of which hledger is a re-implementation, can read GnuCash’s file format and convert it to a ledger file that hledger can read as well. So now I can do analysis on my financial data in Haskell – what would you want more?&lt;/p&gt; 
&lt;p&gt;One report that I was missing was the &lt;a href=&quot;http://en.wikipedia.org/wiki/Internal_rate_of_return&quot;&gt;&lt;em&gt;internal rate of investment&lt;/em&gt;&lt;/a&gt; of some account. This is the annual rate of a hypothetical fixed interest-bearing savings account that would, given the same deposits and payouts, result in the same final value. I now implemented this as the &lt;a href=&quot;http://hackage.haskell.org/package/hledger-irr&quot;&gt;hledger-irr&lt;/a&gt; command and – as you would expect – you can find it on hackage. See the package description for documentation and example output.&lt;/p&gt; 
&lt;p&gt;It is very fresh, hardly tested code, so don’t base important decisions on it yet. Also, it needs work to work correctly with multiple currencies or things with varying prices, and I am not yet sure what to do there.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Simon asked me to elaborate the difference to &lt;a href=&quot;http://hackage.haskell.org/package/hledger-interest&quot;&gt;hledger-interest&lt;/a&gt; by Peter Simons (on which my code was initial based, but eventually I rewrote everything but the option parsing code). The difference is that hledger-interest answers the question „I have this investment with this yearly interest rate (which may even change), how large are the interest payments going to be.“ I imagine a usecase is that you have borrowed some money to a friend at a certain (surely amicable) rate and need to figure out what he owes you, even when you gave him the money mid year and he payed you some back shortly after easter. hledger-irr serves a different purpose: Here you already know your investment payments, gains and losses and you want to have a number describing “how good” your investment was. One usecase might be that, at the end of a live of paying into a pension fund, you ask yourself: “Given all the feeds and commissions, was this a good idea or should I just have invested the money myself?” Then the internal rate of investment tells you how lucrative an alternative fixed-rate investment would have had to been to match your pension fund investment. (Or course this is not the only aspect that you should look at when comparing investments, as it totally ignores risk and possible insurance elements of the investment.)&lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Fri, 07 Dec 2012 23:22:41 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/573-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F573-Calculating-the-internal-rate-of-return-with-hledger.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>screen-message is now scriptable more easily</title>
    <link>http://www.joachim-breitner.de/blog/archives/571-screen-message-is-now-scriptable-more-easily.html</link>
            <category>Digital World</category>
            <category>English</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/571-screen-message-is-now-scriptable-more-easily.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=571</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=571</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;Motivated by a user’s mail, I worked a little bit on &lt;a href=&quot;http://www.joachim-breitner.de/projects#screen-message&quot;&gt;screen-message&lt;/a&gt; aka sm.This tool, which I wrote &lt;a href=&quot;http://www.joachim-breitner.de/blog/archives/142-Vorlesungskommunikation.html&quot;&gt;6 years ago&lt;/a&gt; and is &lt;a href=&quot;http://www.joachim-breitner.de/blog/archives/249-screen-message-uploaded-to-Debian.html&quot;&gt;in Debian since 2007&lt;/a&gt;, displays a (possibly multi-line) text as large as possible on your screen and can be used in many, mostly spontaneous ways.&lt;/p&gt; 
&lt;p&gt;It has always been used in a scripted setting as well, e.g. as make-shift slides for a &lt;a href=&quot;http://meetings-archive.debian.net/pub/debian-meetings/2011/debconf11/low/783_Lightning_Talks.ogv&quot;&gt;lightning talk&lt;/a&gt;. This is now possible without having to quit sm (and hence flickering): Since version 0.20, you can continuously feed text to &amp;quot;&lt;tt&gt;sm -&lt;/tt&gt;&amp;quot; and it will display everything until the next form feed character (or the end of the file). So this command produces a make-shift digital wall clock, if you happen to need one:&lt;/p&gt; 
&lt;pre&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (while sleep 1; do date +%T; echo -e &#039;\f&#039;; done) | sm -&lt;/pre&gt; 
&lt;p&gt;Since Debian is currently in a freeze to eventually release wheezy (and this feature is hardly release critical) you will have to fetch the new version from experimental.&lt;/p&gt;
&lt;p&gt;By the way, screen message is also available as a web version on &lt;a href=&quot;http://sm.nomeata.de&quot;&gt;http://sm.nomeata.de/&lt;/a&gt;&amp;#160; and as a &lt;a href=&quot;https://marketplace.firefox.com/app/screen-message/&quot;&gt;Mozilla WebApp&lt;/a&gt; (although the usability on smart phone can still be improved, considering that I do not own such a device). &lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sat, 24 Nov 2012 20:35:46 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/571-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F571-screen-message-is-now-scriptable-more-easily.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Somewhere in Israel, someone printed 50 copies</title>
    <link>http://www.joachim-breitner.de/blog/archives/569-Somewhere-in-Israel,-someone-printed-50-copies.html</link>
            <category>English</category>
            <category>Mathe</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/569-Somewhere-in-Israel,-someone-printed-50-copies.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=569</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=569</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;Today, a small 
package was waiting for me at my door step, containing 52 printed and 
stapled copies of &lt;a href=&quot;http://link.springer.com/article/10.1007/s11856-011-0213-3&quot;&gt;a paper&lt;/a&gt; that I wrote a while ago. To be more precise, two years ago, when I submitted the main results of my &lt;a href=&quot;http://www.joachim-breitner.de/blog/archives/376-Diploma-Thesis-Finished.html&quot;&gt;math Diploma Thesis&lt;/a&gt; to the &lt;a href=&quot;http://www.ma.huji.ac.il/~ijmath/&quot;&gt;Israel Journal of Mathematics&lt;/a&gt;. Next year at christmas eve, &lt;a href=&quot;http://www.joachim-breitner.de/blog/archives/542-First-academic-publication.html&quot;&gt;it was accepted&lt;/a&gt; and published online. And now, it seems, it finally went into print. So my paper now has page numbers and I have this pile of printouts that outnumbers the set of possibly interested readers by four dozens or more, and they would probably just download the online version instead of asking for this print out. This seems all very anachronistic to me.&lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Mon, 05 Nov 2012 19:39:52 +0100</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/569-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F569-Somewhere-in-Israel%2C-someone-printed-50-copies.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>c't features Haskell</title>
    <link>http://www.joachim-breitner.de/blog/archives/566-ct-features-Haskell.html</link>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/566-ct-features-Haskell.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=566</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=566</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;
This week’s issue of &lt;a href=&quot;http://www.heise.de/ct/&quot;&gt;c&#039;t&lt;/a&gt;, one of Germany’s largest and most influential computer magazine, has a six page introductory &lt;a href=&quot;http://www.heise.de/ct/inhalt/2012/23/182/&quot;&gt;article about Haskell&lt;/a&gt; (c&#039;t 2012, Issue 23, pages 182-187). The author Harad Bögeholz demonstrates its features and strength by implementing a &lt;a href=&quot;http://en.wikipedia.org/wiki/Slitherlink&quot;&gt;Slitherlink&lt;/a&gt; puzzle solver. As I have helped him a bit by checking the code and article for untypical Haskell code and general advice, I happen to be named at the end of the article – nice. &lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Wed, 24 Oct 2012 20:49:20 +0200</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/566-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F566-ct-features-Haskell.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Creating a Debian source package without unpacking the source</title>
    <link>http://www.joachim-breitner.de/blog/archives/564-Creating-a-Debian-source-package-without-unpacking-the-source.html</link>
            <category>Debian</category>
            <category>English</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/564-Creating-a-Debian-source-package-without-unpacking-the-source.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=564</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=564</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;There may be a situation where you want to create a Debian source package without having to unpack the upstream source. One case is where you store your &lt;tt&gt;debian/&lt;/tt&gt; directory in a version control system of its own and to build your package, you pass the &lt;tt&gt;.dsc&lt;/tt&gt; file to a tool like pbuilder or some remote builder. Now a modern debian source package is just a text file (the &lt;tt&gt;.dsc&lt;/tt&gt; file) that references two tarballs, one being the upstream source and the other being the Debian directory. Thanks to Niels Thykier on #debian, I found the magic invocation of &lt;tt&gt;dpkg-source&lt;/tt&gt; that allows you to create the &lt;tt&gt;.dsc&lt;/tt&gt; directly from the two tarballs, the control file and the changelog:&lt;/p&gt; 
&lt;pre&gt;&amp;gt; apt-get source --download-only -t experimental haskell-mtl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
NOTICE: &#039;haskell-mtl&#039; packaging is maintained in the &#039;Darcs&#039; version control system at:
http://darcs.debian.org/darcs/pkg-haskell/haskell-mtl
Need to get 18.8 kB of source archives.
Get:1 http://http.debian.net/debian/ experimental/main haskell-mtl 2.1.2-1 (dsc) [1616 B]
Get:2 http://http.debian.net/debian/ experimental/main haskell-mtl 2.1.2-1 (tar) [13.7 kB]
Get:3 http://http.debian.net/debian/ experimental/main haskell-mtl 2.1.2-1 (diff) [3509 B]
Fetched 18.8 kB in 0s (22.3 kB/s)    
Download complete and in download only mode
&amp;gt; cp ./haskell-mtl_2.1.2-1.dsc ./haskell-mtl_2.1.2-1.dsc-orig
&amp;gt; tar xzf haskell-mtl_2.1.2-1.debian.tar.gz
&amp;gt; dpkg-source -cdebian/control -ldebian/changelog --format=&quot;3.0 (custom)&quot; --target-format=&quot;3.0 (quilt)&quot; -b / haskell-mtl_2.1.2.orig.tar.gz haskell-mtl_2.1.2-1.debian.tar.gz
dpkg-source: info: using source format `3.0 (custom)&#039;
dpkg-source: info: building haskell-mtl in haskell-mtl_2.1.2-1.dsc
&amp;gt; diff  -u haskell-mtl_2.1.2-1.dsc haskell-mtl_2.1.2-1.dsc-orig
--- haskell-mtl_2.1.2-1.dsc	2012-10-13 15:09:00.031695856 +0200
+++ haskell-mtl_2.1.2-1.dsc-orig	2012-10-13 15:08:47.267696329 +0200
@@ -1,3 +1,6 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
 Format: 3.0 (quilt)
 Source: haskell-mtl
 Binary: libghc-mtl-dev, libghc-mtl-prof, libghc-mtl-doc
@@ -23,3 +26,11 @@
 Files: 
  943c110524d96126bfa0e61f7df1ebcd 13723 haskell-mtl_2.1.2.orig.tar.gz
  dda5ded58a8d009ecddeed68058ca787 3509 haskell-mtl_2.1.2-1.debian.tar.gz
+
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.12 (GNU/Linux)
+
+iEYEARECAAYFAlBzRQIACgkQ9ijrk0dDIGwymwCfW87jwCv5ZvAXPBwh0LbvYLP9
+n+wAn3TCJwPRuBDEWRYmcv3Opn1Kb9+F
+=/Llc
+-----END PGP SIGNATURE-----&lt;/pre&gt; 
&lt;p&gt;As you can see, the resulting &lt;tt&gt;.dsc&lt;/tt&gt; file is identical to the original one, so this approach works. The parameter to &lt;tt&gt;-b&lt;/tt&gt; does not matter as long as it is some existing directory. Of course you can easily shoot yourself and others in the foot, almost as easily as hand-editing the &lt;tt&gt;.dsc&lt;/tt&gt; file... but if you know what you are doing, then this can be quite handy.&lt;/p&gt; 
&lt;p&gt;Next to do: Write a tool that takes an unpacked Debian directory as an argument, packs it, finds the original tarball using uscan and creates the &lt;tt&gt;.dsc&lt;/tt&gt; file. Would this be something that people would want in the devscripts package?&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sat, 13 Oct 2012 15:03:46 +0200</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/564-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F564-Creating-a-Debian-source-package-without-unpacking-the-source.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>Dennis Felsing’s thesis on ghc-vis submitted</title>
    <link>http://www.joachim-breitner.de/blog/archives/562-Dennis-Felsings-thesis-on-ghc-vis-submitted.html</link>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/562-Dennis-Felsings-thesis-on-ghc-vis-submitted.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=562</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=562</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;Last week, my first student ever submitted his bachelor thesis „&lt;a href=&quot;http://felsin9.de/nnis/ghc-vis/thesis/&quot;&gt;Visualization of Lazy Evaluation and Sharing&lt;/a&gt;“ about a tool he created that allows you to investigate the heap of a running Haskell program, including unevaluated values and their sharing properties, in a visual and interactive manner. You can see it in action at the end of the&amp;#160; &lt;a href=&quot;http://www.youtube.com/watch?v=DGsVX7Qqv-0&quot;&gt;video of my lightning talk&lt;/a&gt; about &lt;a href=&quot;http://arxiv.org/abs/1207.2017&quot;&gt;ghc-dup&lt;/a&gt; at the &lt;a href=&quot;http://www.haskell.org/haskellwiki/HaskellImplementorsWorkshop/2012&quot;&gt;Haskell Implementors Workshop&lt;/a&gt; this year, and read more about it on Dennis’ &lt;a href=&quot;http://felsin9.de/nnis/ghc-vis/&quot;&gt;ghc-vis&lt;/a&gt; web page. I’m quite happy about the result and I think I can get used to have other people implement my ideas and needs :-)&lt;/p&gt;
&lt;p&gt;Dennis said he is willing to continue the maintenance of the tool, so give it a shot and bombard him with bug reports and feature requests!&lt;br /&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 02 Oct 2012 09:39:01 +0200</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/562-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F562-Dennis-Felsings-thesis-on-ghc-vis-submitted.html&amp;user_id=nomeata" type="text/html" />
</item>
<item>
    <title>The might applicative left fold</title>
    <link>http://www.joachim-breitner.de/blog/archives/560-The-might-applicative-left-fold.html</link>
            <category>English</category>
            <category>Haskell</category>
    
    <comments>http://www.joachim-breitner.de/blog/archives/560-The-might-applicative-left-fold.html#comments</comments>
    <wfw:comment>http://www.joachim-breitner.de/blog/wfwcomment.php?cid=560</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://www.joachim-breitner.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=560</wfw:commentRss>
    

    <author>mail@joachim-breitner.de (nomeata)</author>
    <content:encoded>
    &lt;p&gt;Just about three years ago, I created the “&lt;a href=&quot;http://darcs.nomeata.de/arbtt/doc/users_guide/&quot;&gt;automatic rule-based time 
tracker&lt;/a&gt;” (arbtt), a tool that quietly runs in the background, records 
your current windows and their titles, and allows you to later process 
this data using, well, rules. By now, I have almost half a million 
records, spanning 317 days of me working at the computer. Processing 
this amount of data has become very memory-hungry: It takes 1G of RAM to
 process my data. Other users, with a presumably higher sampling rate, 
report even worse performance, which finally made me approach the problem again.&lt;/p&gt; 
&lt;p&gt;Naturally, one wonders why it is such a memory hog, after all it 
takes just one run over the data to produce a report. The data itself is
 a lazy list so the garbage collector should the be able to drop the 
seen elements immediately.&lt;/p&gt; 
&lt;p&gt;But arbtt is able to print several reports in one run; there is even 
an option (&lt;a href=&quot;http://darcs.nomeata.de/arbtt/doc/users_guide/arbtt-stats.html#id3116568&quot;&gt;&lt;tt&gt;--each-category&lt;/tt&gt;&lt;/a&gt;) that creates a number of reports based on 
the data itself. The code was structured that first a number of values 
that are possibly used by several reports are first created one and then
 re-used by the reports. And then there is the issue of the filters: The
 user specifies a what predicates are interesting (e.g., those where he 
was active) and some reports need to know not only which samples were 
matched, but also distinguish the consecutive runs of selected samples.&lt;/p&gt; 
&lt;p&gt;Lots of reasons that made it hard to not use the list of of samples 
several times, which causes it to be completely retained in memory. The 
idea of completely rewriting everything in a much more imperative way 
was not appealing. But luckily Haskell’s good abstraction possibilities can help here.&lt;/p&gt; 
&lt;p&gt;What is the “correct” way to traverse a lazy list and calculate some information about it? It is a strict left fold, i.e. an algorithm that can be represented as arguments to&lt;/p&gt; 
&lt;pre&gt;&lt;a title=&quot;&quot; target=&quot;&quot; href=&quot;http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-List.html#v:foldl-39-&quot;&gt;foldl&#039;&lt;/a&gt; :: (s -&amp;gt; x -&amp;gt; s) -&amp;gt; s -&amp;gt; [x] -&amp;gt; s&lt;/pre&gt; 
&lt;p&gt; For those who are new to folds: The first argument is a function that processes one element from the list, returning the new state of the processing. The second argument is the initial state. And &lt;tt&gt;foldl&#039;&lt;/tt&gt; can apply such an algorithm to a list to return a final state.&lt;/p&gt; 
&lt;p&gt;So obviously I had to express my reports as left folds. To think clearer about it, I gave them a name. I also added a finishing step to the mix, which is handy:&lt;/p&gt; 
&lt;pre&gt;data LeftFold x a = forall s. LeftFold {
&amp;#160;&amp;#160;&amp;#160; start :: s,
&amp;#160;&amp;#160;&amp;#160; process :: s -&amp;gt; x -&amp;gt; s,
&amp;#160;&amp;#160;&amp;#160; finish :: s -&amp;gt; a
&amp;#160;&amp;#160;&amp;#160; }
&lt;/pre&gt; 
&lt;p&gt;A value of type &lt;tt&gt;LeftFold x a&lt;/tt&gt; is then an algorithm that traverses a list of &lt;tt&gt;x&lt;/tt&gt;es and returns something of type &lt;tt&gt;a&lt;/tt&gt;. The &lt;tt&gt;forall s.&lt;/tt&gt; means that the user of such a processor must not make any assumptions about the type of the state. I also have a function that runs such a list processor, simply by invoking &lt;tt&gt;foldl&#039;&lt;/tt&gt; with the arguments stored in the &lt;tt&gt;LeftFold&lt;/tt&gt; constructor:&lt;/p&gt; 
&lt;pre&gt;runLeftFold :: LeftFold x a -&amp;gt; [x] -&amp;gt; a&lt;br /&gt;runLeftFold (LeftFold st1 p1 f1) xs = f1 (foldl&#039; p1 st1 xs)&lt;/pre&gt; 
&lt;p&gt;Now, as a Haskell programmer, I am searching for monads everywhere, and it really would have been nice if this were a monad, as they are very easy to compose. But unfortunately, they do not form a monad. If they did then I could decide after running one processor and looking at the result how I would want to process the list now, but this obviously contradicts with the desire to traverse the list only once.&lt;/p&gt; 
&lt;p&gt;But there is the monad’s smaller ugly sibling, the applicative functor. One can still somewhat nicely compose them to form more complex algorithms, just with more restrictions. Here is my instance:&lt;/p&gt; 
&lt;pre&gt;instance Functor (LeftFold x) where
&amp;#160;&amp;#160;&amp;#160; fmap f (LeftFold st1 p1 f2) = LeftFold st1 p1 (f . f2)

instance Applicative (LeftFold x) where
&amp;#160;&amp;#160;&amp;#160; pure x = LeftFold () const (const x)
&amp;#160;&amp;#160;&amp;#160; LeftFold st1 p1 f1 &amp;lt;*&amp;gt; LeftFold st2 p2 f2 = LeftFold {
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; start&amp;#160;&amp;#160; =&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; st1 :!: st2,
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; process = \(s1 :!: s2) x -&amp;gt; p1 s1 x :!: p2 s2 x,
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; finish&amp;#160; = \(s1 :!: s2)&amp;#160;&amp;#160; -&amp;gt; f1 s1 (f2 s2)
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/pre&gt; 
&lt;p&gt;The &lt;tt&gt;:!:&lt;/tt&gt; operator is a &lt;a href=&quot;http://hackage.haskell.org/packages/archive/strict/latest/doc/html/Data-Strict-Tuple.html#v::-33-:&quot;&gt;strict tuple constructor&lt;/a&gt;. This is important, as otherwise the fold would be come a lazy one, I would be building up huge numbers of thunks and performance would be very bad. For the same reason every list processor should make sure that its state does not build thunks once it is in weak head normal form.&lt;/p&gt; 
&lt;p&gt;Now I am at a abstraction level that I feel comfortable working in, by writing functions that combine the list processors in various ways. Probably the most important one for me is already present in the libraries (here with a specialized type):&lt;br /&gt;&lt;/p&gt; 
&lt;pre&gt;&lt;a title=&quot;&quot; target=&quot;&quot; href=&quot;http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Traversable.html#v:sequenceA&quot;&gt;sequenceA&lt;/a&gt; :: [LeftFold x a] -&amp;gt; LeftFold x [a]&lt;/pre&gt; 
&lt;p&gt;This is the whole trick: Now I can, based on the user input, run any number and selection of reports in one single list traversal. I find it very elegant that “under the hood”, the strict tuples are nested at precisely the right depth depending on the length of the list.&lt;/p&gt; 
&lt;p&gt;As hinted at before, I do some interesting stuff that was previously represented as lists of lists of values. Expressing these as left folds was a bit tricky, but again, the complexity is contained in the combinators that I wrote (although it still gets confusing, check out &lt;a href=&quot;http://darcs.nomeata.de/arbtt/src/Stats.hs&quot;&gt;&lt;tt&gt;processIntervalReport&lt;/tt&gt; in &lt;tt&gt;Stats.hs&lt;/tt&gt;&lt;/a&gt;):&lt;/p&gt; 
&lt;pre&gt;monoidFold :: Monoid m =&amp;gt; LeftFold m m
mapElems :: LeftFold y a -&amp;gt; (x -&amp;gt; y) -&amp;gt; LeftFold x a 
filterWith :: (x -&amp;gt; Bool) -&amp;gt; LeftFold (Bool :!: x) a -&amp;gt; LeftFold x a
onSelected :: LeftFold x a -&amp;gt; LeftFold (Bool :!: x) a
onJusts :: LeftFold x a -&amp;gt; LeftFold (Maybe x) a
onAll :: LeftFold x a -&amp;gt; LeftFold (Bool :!: x) a
runOnGroups :: (x -&amp;gt; x -&amp;gt; Bool) -&amp;gt; LeftFold x y -&amp;gt; LeftFold y z -&amp;gt; LeftFold x z
runOnIntervals :: LeftFold x y -&amp;gt; LeftFold y z -&amp;gt; LeftFold (Bool :!: x) z
lfLength :: LeftFold x Int
lfFirst :: LeftFold x (Maybe x)
lfLast :: LeftFold x (Maybe x)
toList :: LeftFold x [x]
concatFold :: LeftFold [x] [x]&lt;/pre&gt; 
&lt;p&gt;As a result, the program now only requires 10MB and runs 18% faster.&lt;/p&gt; 
&lt;p&gt;If you wonder why, in the definition of &lt;tt&gt;runLeftFold&lt;/tt&gt;, I do not apply the finish function strictly: That is intentional; I am actually passing the result of a processor that calculates some often required data (e.g. total time recorded) as an argument to all the list processors. (Near the end of the main function in &lt;a href=&quot;http://darcs.nomeata.de/arbtt/src/stats-main.hs&quot;&gt;&lt;tt&gt;stats-main.hs&lt;/tt&gt;&lt;/a&gt;) This “loop” works fine as long as I am using these only in the &lt;tt&gt;finish&lt;/tt&gt; functions.&lt;br /&gt;&lt;/p&gt; 
&lt;p&gt;There is one downside to this approach: I cannot easily calculate stuff on demand &lt;em&gt;and&lt;/em&gt; share it between two reports. Previously, I could just bind this to a variable, pass it to all reports, only if at least one is interested it would be evaluated and if several are interested, the result would be shared. I do not have a good solution for this yet.&lt;/p&gt; 
&lt;p&gt;The code above is in the self-contained module &lt;a href=&quot;http://darcs.nomeata.de/arbtt/src/LeftFold.hs&quot;&gt;&lt;tt&gt;LeftFold.hs&lt;/tt&gt;&lt;/a&gt; in the arbtt sources.&lt;br /&gt;&lt;/p&gt; 
&lt;p&gt;Several People have had this idea before, here is &lt;a href=&quot;http://squing.blogspot.de/2008/11/beautiful-folding.html&quot;&gt;one blog post by Max Rabkin&lt;/a&gt;.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Fri, 28 Sep 2012 18:40:00 +0200</pubDate>
    <guid isPermaLink="false">http://www.joachim-breitner.de/blog/archives/560-guid.html</guid>
    
    <atom:link rel="payment" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F560-The-might-applicative-left-fold.html&amp;user_id=nomeata" type="text/html" />
</item>

</channel>
</rss>
