Computing the Canonical Cover in Haskell

Today I had a little too much free time on my hand, but didn’t want to start anything that I couldn’t finish before the start of my vacation on Monday. Since I know I will teach two tutorial groups for the intro course on databases at TUM next term, I decided to write a little program that might be helpful when it comes to learning about the canonical cover.
The problem appeared to be very mathematical, so I decided to do it in Haskell. The program itself is kind of boring: You enter a set of functional dependencies and get back the canonical cover. The only usecase I can think of is somebody trying to learn the algorithm and checking if their result is correct.
But writing it sure was a lot of fun! The source code is on Github, a binary for Linux is here.

Galaxy Note 10.1 – Or when a left click is not a click

So, if you have a passing familiarity with Android, this code will look just fine:

@Override
public boolean onGenericMotion(View v, MotionEvent event) {
        if((event.getButtonState() & MotionEvent.BUTTON_PRIMARY) != 0)
                codeForLeftClick();

        if((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0)
                codeForRightClick();
 
        if ((event.getButtonState() & MotionEvent.BUTTON_TERTIARY) != 0)
                codeForMiddleClick();

        //Other stuff
	return true;
}

What it does is detect left, right and middle clicks on a mouse that’s connected to a phone or tablet via Bluetooth or a USB OTG cable.

Or at least that’s what it does on most phones and tablets. On the Galaxy Note 10.1 however it doesn’t: It works fine for right clicks (if you keep in mind that this tablet maps them to the back-button even if you indicate you consumed the event and think of filtering out any back-buttons coming from the mouse in onKeyUp(…) ) and middle clicks (with the caveat that middle clicks map to the home button and will minimize your app).

For left clicks, however nothing happens. That’s odd. Well there must be another event that is fired than. ACTION_DOWN maybe? No. Turns out there is actually no event associated with a left click that gets passed to the onGenericMotionListener. At all. (The only events you get are ACTION_HOVER_MOVE and right/middle clicks).

The only way to find out if there was a left click is to use another method (like onTouch(…)) which is inconsistent at least and annoying if you need to debug an app and don’t have any device that behaves like this (like I did this week).

[Short Linkdump] Accidentally Turing Complete

As I have been kind of busy with classes and some project work, I didn’t have that much time to update this blog. However, I am planning to write a longer article based on a 10 page report I did for a seminar on code quality as soon as the grading process is finished. (I don’t want to be accused of plagiarizing my own stuff.) It will very likely also include some samples of code of poor quality that I refactored in Easy Feed Editor a few days ago.
In the meanwhile, I leave you with this link to an article about “languages” that became Turing complete without anyone ever aiming for that. The one that surprised me the most was MediaWiki Templates…