Haskell has been my favorite programming language in the past month, and for good reason. Its (purely) functional and has strong, static typing.

The language feels more graceful to me, where design and function are key. It is a joy to program in and I would love to keep exploring it.

On my path to learning a new language, I usually try to implement something to get some real-world experience. In this instance, I have chosen to implement an Open AIM client. AIM operates on the legacy TOC(text based) protocol, or the feature full OSCAR protocol, which is what most AIM clients use. I decided that OSCAR would be more fun to do, especially with the three step login process.

The client that I wrote is very simple – handles login to AIM and just sits there. It can get IM’s though. The bulk of the AIM client that I enjoyed writing was the protocol handlers, and implementing the login process.

It would be very easy to extend this client to be a bot, if you are looking for a practical use for it. For me, the learning experience is enough.

The main function is listed below.

start_aim = do
	putStrLn "Haskell AIM Client - OSCAR Protocol"
	appKey <- getAppKey
	screenName <- getScreenName
	password <- getPassword
	let clientInfo = AIMClientInfo 1 "HaskellClient" appKey
	result <- aim_open_auth clientInfo screenName password
	case result of
		Just info -> do
			boss_result <- aim_boss_session clientInfo info
			case boss_result of
				Just si -> aim_oscar_login si
				Nothing -> putStrLn "Unable to authenticate with BOSS server."
		Nothing -> return ()

If you want to try out this AIM client, you must have an Open AIM Developer key.

The first step is to download the source and use cabal to configure, build, and install it.

# wget http://www.moostrax.com/cmoos/haim.tar.gz

# tar -xzf haim.tar.gz

# cd haim

# cabal configure && cabal build && cabal install

And then run it.

# ~/.cabal/bin/haim

The output will look something like this:

Haskell AIM Client - OSCAR Protocol
An Open AIM Developer key is required: http://developer.aim.com/manageKeys.jsp
Open AIM Key> 
AIM Screen Name> 
AIM Password> 
Connected to AIM server.
Entered OSCAR client loop.
Login accepted by OSCAR server. Setting up rights.
Max Watchers: 2000
Max Buddies: 1000
Max Temp Buddies: 160
Max Denies: 1000

Like I said, the client is very simple, and just sits and waits. When you login you will see some information about your buddy list, and other AIM login data.