Programmer's Weblog

HLint

Wednesday, February 4, 2009

I am used to pylint, which runs at the start of a build to ensure code quality. If pylint complaints, the build is broken, so I run it prior to any commit to avoid embarrassing BUILD FAILED emails sent to all developers by CI.

No one has high expectations of such a tool, it just reports unused variables and imports or redefined names. It also annoyingly complains about defining names such as file, that shadow builtins. Well, I guess different people are annoyed with different aspects of it. Anyway, my point here is that this tool is simple.

I was thrilled to see HLint suggest that instead of reverse . tail . reverse I could just use init.

./Goals.hs:137:1: Error: Use init
Found:
  reverse . tail . reverse
Why not:
  init

That is just whole new level. It also highlights redundant brackets:

./Controller.hs:17:1: Warning: Redundant brackets
Found:
  (priority n1) `compare` (priority n2)
Why not:
  priority n1 `compare` priority n2

And look at the next one,

./Controller.hs:17:1: Warning: Use on
Found:
  byPriority n1 n2 = (priority n1) `compare` (priority n2)
Why not:
  byPriority = compare `on` priority

I had no idea that `on` existed. How awesome is that? As if by sufficiently advanced technology HLint knows better how to code than I :).

The tool was created by Neil Mitchell, who is also responsible for Hoogle -- Haskell API search -- which I use daily.

It is available thorough cabal install, but cabal install hlint didn't work for me until I cabal installed happy.

Labels:

2 comments

Snowing in London

Monday, February 2, 2009

It was snowing today in London, or as BBC holds it, there were severe weather conditions. By Polish standards, it was nothing special, but London was unprepared. I didn't realise how bad it was until I read an e-mail from Orestis, that he doesn't want to risk coming to office. I had no idea underground did not work, I live in a walking distance from the office and today I was 10 minutes early.

On my route to work I saw palms under snow.

 

Anyway, that must have been great day for kids. If not for snow then at least for closed schools. I took that photo in the evening. Yes, that snowman has style and surely many bitches, and yes, he wears silver $ on his neck.

 

Not only schools were closed. I needed to go to Lloyds TSB, you know, the bank with the most branches. My branch greeted me with this:

Weather conditions, yada yada, they are sorry, and point me to another branch. Guess what, that second branch had a similar note pointing to third branch. At this point I was sure that the third branch will close the cycle. I was wrong, the third branch had a note saying that they are indeed open, but only till 2pm; unlucky for me it was 2:15.

I was pretty amazed when I first learned the notion of Bank Holiday. Idea that no other business can operate when banks are shut still seems dubious to me. Far more convincing is that no other business can operate without the tube.

I am supposed to fly to Poland tomorrow, but all the today's flights were cancelled. The weather is supposed to be the same tomorrow, my only hope is that the UK will get better at coping with the snow.

4 comments