Have 5 minutes of fun and watch this presentation: https://www.destroyallsoftware.com/talks/wat

Posted in General | Leave a comment

Homemorphic Endofunctors ;-)

Just epic

Posted in Rants, Using Technology | Tagged , , | Leave a comment

STM — Why mainstraims languages don’t profit from STM

It’s Sunday morning and I’m reading old blog posts about programming languages. While doing that I’ve come across a great summary of the reasons why STM requires a functional programming style in order to pay off.

The problem with STM: your languages still suck

Posted in Programming, Rants | 1 Comment

Motivating the Use of Purely Functional Programming Techniques

Over time I’ve seen, and read, and presented quite a lot of motivations for the use of purely functional programming — sometimes for Haskell, Lisp, or ML. Today I’ve seen the first motivation/introduction which did not come from a mathematical/categorical perspective. That was quite refreshing. You can find it here.

Although, there is nothing really new in it — at least not for someone who has been following Haskell for 10 years now — this is a nicely presented new angle on the topic. So, have a look at that talk and see for yourself.

Posted in General, Programming | Tagged , , , , , , | 1 Comment

Mixing monadic and non-monadic parameters with Applicative

Today, I’ve wondered how to call when with a monadic expression as first parameter.

Usually, I write something similar to the following code:

main :: IO ()
main = do
    ex <- doesFileExist "/etc/passwd"
    when ex $ do
        print "Hi, there"

But, I’ve always wondered how to avoid binding the result of doesFileExist. Today, my colleague Patrick Michel and I came up with a solution which is general and nice. Although, it’s quite possible that it is not new. It simply wasn’t known to us.

main :: IO ()
main = do
    when <$> doesFileExist "/etc/passwd" <#> do
       print "Hi, there"

<#> is somehow the dual to <$>. The latter lifts its left argument into a Functor, Monad, Applicative, whereas the former — <#> — ‘unlifts’ its left argument. Because unlifting is not possible — at least not in general, <#> lifts its right argument, applies the right argument to the left argument with <*>, and joins the result.

import Control.Applicative
import Control.Monad

(<#>) :: (Monad m, Applicative m) => m (m a -> m b) -> m a -> m b
a <#> b = join $ a <*> pure b
infixl 3 <#>

Using that new operator <#> it is now possible to replace the following:

    x_0 <- m_0
    x_n <- m_n
    m x_0 .. x_n m_(n+1) .. m_(n+k)


    m <$> m_0 <*> .. <*> m_n <#> m_(n+1) .. m_(n+k)

<$> starts the sequence of arguments, which are of a pure type, but are computed by a monadic action, and <#> ends the sequence of those arguments.

I’d be very interested to hear, which alternatives to <#> exist or whether it is already hidden in the libraries under a different name.

Posted in Haskell | Tagged , , | Leave a comment

Mac OS X, the Terminal, Unicode and ls

Years ago I’ve figured out how to configure Mac OS X’s Terminal.app and the .inputrc to support umlauts encoded in UTF-8 in terminal windows. But there was still one essential piece missing. I was able to enter umlauts, vim was able to display umlauts, “ls | cat” showed correct umlauts in filenames, even bash completion was able to complete umlauts properly, but executing simply ls failed to display correct UTF-8 encoded umlauts. Today — after probably five years — I’ve found the first workaround: ls -w.

   -w    Force raw printing of non-printable characters.  This is the default
         when output is not to a terminal.

Though, this workarond is ugly, it works. It indicates that ls fails to determine umlauts as printable characters although the locale is set to a german UTF-8 locale. By forcing ls to ignore the fact that a character is supposedly non-printable, one might indeed get trouble as soon as a file name contains really non-printable characters. Until this happens I’ll be happy with this workaround. At long last, it seems feasible to use proper file names in german. This was the last missing piece for me to start using german file names.

In the end it turns out there seems to be one more programmer (the author of ls of OS X) who should have read Joel Spolsky’s blog entry: “The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)” I wish there was a law forcing everyone to read that before he is allowed to program one line of code. It would have saved me — probably — hundreds of hours of my life.

Posted in OS X | Tagged , , , , , | 1 Comment

Server-side IMAP filtering done right

Several weeks ago, my colleague Paddy told me about a new software find of him: imapfilter. After several configuration sessions, we finally arrived at a configuration which promises to solve all mail filtering requirements of us, once and for all. Even better: almost without server support.

But what’s the problem in the first place? Today every decent mail program is able to apply filter rules — well mutt isn’t able, but delegates that task to other programs. Those of us, who don’t want to read their email through more or less capable web interfaces, tend to have multiple computers, smartphones, or other devices they use to access emails on their IMAP servers. At the same time we all face the dreaded problem of too many emails per today. In order to stay sane, I try to filter as much as possible. To do that, I have two choices, either to mantain a growing set of filtering rules on four different computers, using three different operating systems and three different mail programs. I’ll never do that. I am simply to lazy. The other alternative would be to rely on server-side filtering. Well yes, that seems to be ideal. I would have to maintain only one set of filter rules. So far the theory. In practice, every single implementation of server-side mail filtering — I have used so far — was either unreliable or simply not capable of expressing my filtering needs.

On the other side, I don’t want to maintain my own mail server. I did that years ago and it was quite some work to achieve the level of availability I expected.

Here, imapfilter enters the scene. It’s a simple Lua-based mail filtering engine, which connects to an IMAP server and does its work. Since it has idle support, it is able to handle emails almost instantanious. As if it were a filtering engine integrated into the mail server itself. The configuration of imapfilter is a simple piece of Lua code.

The last missing piece of this approach to fake server-side filtering, was drawn from the wish to have a clean interaction with programs like Apple’s Mail.app and Mozilla Thunderbird. A program which simply waits for new mails to arrive in the inbox and then move them, will not prohibit Mail.app or Thunderbird to pick up the new mail play and play some sound or show some popup. Just to notify only a split second later that the emails has already vanished. Being notified about every mail which is to be filtered away would destroy large parts of the benefit of true server-side filtering. To avoid this, we separate the inbox, which is watched by imapfilter from the inbox watched by your mail reader.

If your imap server has at least some mail filtering capabilities you can use that to deliver new mails into some folder, e.g. PreInbox, which is not shown by your mail reader. imapfilter will pick up mails here, filter them and move the rest to real inbox, which triggers your mail reader to bring it to your attention.


  • some IMAP server with poor mail filtering support
  • some other server capable of running imapfilter 24/7
  • imapfilter version 2.2.3
  1. Installs imapfilter. There is a package in Ubuntu, but I installed from source, because the version in Ubuntu was much older. I had to change the Makefile a bit, but I don’t remember the details at the moment. If you have problems installing contact me or ask the author of imapfilter to improve it’s build system.
  2. Create the configuration file in your home dir at “~/.imapfilter/config.lua”. See my example configuration below, the complete API is documented in the man page “imapfilter_config”. Obviously, you show change the server, username, and password. I’ve included some of my own rules to get you started. Keep the loops and the code after “end of the example rules”
    --  Options  --

    options.timeout = 120
    options.subscribe = true
    options.expunge = true

    --  Accounts  --

    account = IMAP {
      server = 'some-clever.server.com',
      username = 'foobar@some-clever.server.com',
      password = 'joshua',
      ssl = 'ssl3'

    --  Main Loop  --

    -- if the server supports idle this will always be true

        -- save a list of all messages currently in there
        initial = account.PreInbox:select_all()

        --- begin of example rules
        res = account.PreInbox:contain_from('wordpress@gaillourdet.net')

        res = account.PreInbox:contain_to('glasgow-haskell-users@haskell.org')
          + account.PreInbox:contain_cc('glasgow-haskell-users@haskell.org')

        res = account.PreInbox:contain_subject('[Haskell]')

        res = account.PreInbox:contain_subject('[Haskell-cafe]')

        res = account.PreInbox:contain_to('vim_use@googlegroups.com')
          + account.PreInbox:contain_cc('vim_use@googlegroups.com')
          + account.PreInbox:contain_field('Reply-To','vim_use@googlegroups.com')
          + account.PreInbox:contain_cc('vim_mac@googlegroups.com')
          + account.PreInbox:contain_cc('vim_mac@googlegroups.com')
          + account.PreInbox:contain_field('Reply-To','vim_mac@googlegroups.com')

        --- end of example rules

        --  Remaining  --

        res = initial * account.PreInbox:select_all()

        res = account.PreInbox:select_all() - initial

      until #res == 0
    until not account.PreInbox:enter_idle()
  3. Configure your IMAP server to deliver all mails into the folder “PreInbox”, create it if necessary.
  4. Test your configuration: Execute imapfilter. It should run and apply your rules to every mail in PreInbox.
  5. Let upstart run imapfilter. Create the file “/etc/init/imapfilter.con” with the following contents. Replace “jmg” with your user name.
    description     "imapfilter lua script remotely sorting my mails"

    start on runlevel [2345]
    stop on runlevel [!2345]

    respawn limit 1 10

    exec su -c 'imapfilter' jmg

That’s it! Now, you should enjoy a full featured, blazingly fast mail filtering capability with any old imap server indenpendent of any mail reader software. Since, I’ve deployed this configuration 4 weeks ago I’ve started to actually listen to my phone, when it plays a sound to notify me about new mail. Since it became such a rare event.

Don’t hesitate to contact me when you have question to this configuration.

Now, I am tired writing. So I post this article in this condition and will update it later.

Posted in Linux | Tagged , , , , , , , | 5 Comments

A new float style for LaTeX: plainruled

Today, I’ve been so annoyed by LaTeX’s figures appearance that I’ve defined some tiny new style for the package float. This style simply draws a horizontal rule below and above the body of the figure.

Defining the style is very simple:


Then you can use the style plainruled as any predefined style of the package float, e.g. you can make it the default for any figure by adding the following to the preamble of your document:


In order to see the difference, let’s have a trivial figure in the body of your document:

  Some interesting \\figure contents.
  \caption{Some figure caption.}

Without my settings above this figure is rendered like this:

Using the style plainruled it renders like this:

This is nothing amazing, but simply useful. Therefore I wanted to keep this somewhere I and possibly others might find it for future reference.

Posted in LaTeX | Tagged , | 1 Comment

Von Datenkraken und anderem Obst

Heute Morgen sind gleich mehrere erstaunliche Dinge passiert:

  1. Tagesschau.de hat heise.de bei einer Nachricht über Datenschutz und die wunderbare Welt der Smartphones an Aktualität überboten.
  2. Tagesschau.de hat einen Link auf eine Software auf Github
  3. Es kam heraus, dass Apple vorsorglich Bewegungsprofile aller iPhone-User anlegt und normal lesbar in das Homeverzeichnis des eigenen PC synct.

Letzteres ist eigentlich weder erstaunlich noch besonders überraschend, aber vielleicht doch etwas beunruhigend. Ich wünsche uns allen noch ein frohes Jahr 1984.

Posted in Rants | Tagged , , , | Leave a comment

Protected: Betriebsausflug 2010

This content is password protected. To view it please enter your password below:

Posted in Fotoalben | Tagged , | Enter your password to view comments.