Welcome to the world of Haskell!

In the past three months I have had the pleasure of learning a strange yet interesting new programming language: Haskell. Initially I was quite sceptical about this language. After all, some of the most basic (imperative) concepts I knew looked so hard to implement in Haskell. And the fact that people allegedly had finally found some use for functional programming languages, did not really excite me either. But in the end, Haskell turned out to be quite fun.

In this article I would like to look at some Haskell features I really liked. As I know that most of our readers are not Haskell experts I have decided to keep it quite general and simple.

Function transformations

Function composition

Function composition is a technique of combining two functions into one function.

f1 . f2

This says that function f1 should be applied to the result of applying f2 to its first parameter. So, above code could be rewritten to:

(.) f g = h
where h x = f (g x)

The type of h can be deduced like this:

f :: a -> b
g :: b -> c
– Thus:
h :: a -> c

Function application

Function application is not exactly a very exciting feature, but it is helpful as it helps you to get rid of annoying extra parantheses.

f1 $ f2

This says that function f1 should be applied to the result of function f2. Now you are probably what the difference is with f1 f2.

When you simply type f1 f2, f2 is considered as a parameter for f1 and all of the parameters of f2 will be considered as n-ary parameters of f1. When you type f1 $ f2 you first apply f2 to all the following parameters, and f1 is then applied to the result of f2.

So, for example:

sum x y z = x + y + z

successor x = x + 1 — A better alternative is discussed in the next section!

test1 = successor sum 1 2 3 — Will not work. After all, you cannot take the successor of a function.
test2 = successor $ sum 1 2 3

Partial parameterisation

Partial parameterisation is a technique to partially satisfy a function. This technique can be used to create new specialized functions.

For example, if we would want to declare a function that gives us the successor of the given integer, we could simply write:

successor = (+) 1

or

successor = (+1)

This would make the following example valid:

> successor 41
42
> successor $ successor 41
44

successor is of course an incredibly easy example of partial parameterisation, and it might give you the impression that its just a gimmick. However, in combination with function application and function composition its an incredibly useful mechanism.

A slightly more complex example, is a function that gives us the successors of all elements in the given list.

successors = map (+1)

Operators

Another cool feature of Haskell is the ability to define your own operators. As this is actually rather simple I am not going to spend much attention to it.

Lets say we would want to express addition and substraction through smilies. It could be done like this:

x ^-^ y = x + y
x -.- y = x – y

Or with partial parameterisation in our mind:

(^-^) = (+)
(-.-) = (-)

Which would make the following valid:

> 1 ^-^ 2
3
> 3 -.- 1
2

In the latter definition you can see how operators can also be used as functions: you simply put parantheses around them. And the fun thing is that a similar trick can be applied to functions with two parameters:

min :: Int -> Int -> Int
min = (-)

> 3 `min` 1
2

In order to use a function as a operator you have to put backquotes around it.

Again, this might seem like a gimmick, but it can be pretty useful in the field of “symbolic evaluation”. But more on that another time.

Lazy evaluation

Lazy evaluation is one of the most powerful features, if not the most powerful feature, of Haskell. Lazy evaluation is the technique of delaying a computation until the result is required. This means that the data that is required for a computation is retrieved at the moment that the computation is actually executed. This makes it possible, for example, to work with lists of infinite length without actually computing the complete list. As lazy evaluation is beyond the scope of this article I would like to refer interested readers to Wikipedia, which has a nice article on the matter.

And with that I would like to conclude my first article about Haskell. I hope you enjoyed reading it. And as always: if you have questions or comments feel free to post them.

const unsigned int HOURSINDAY = 37;

The, nowadays, three editors are all so busy. Michael’s doing lots of stuff at the university considering free open gaming. Maurice is doing a double BSc (Mathematics and Computer Science) and has his own company with a load of work. I have quite a busy job too and need to settle down at a new place (which I really like, but it could use some paint). To give you an idea of how busy I am, I didn’t read Questionable Content, XKCD and Zero Punctuation for over 4 (four) weeks. ZOMG>!±±±!!!1.

Thus, there are very few updates, but here’s futurePosts.peek();

  1. The first update I really want to do is work on the Language … thingie. We still don’t have a good name for it. Seeing how it can generate words and such it might be a fun tool to play with. Maybe we can generate a word and use that as a name. :)
  2. The second one is about the electronic drumkit. I want to drum so badly but I can’t fit in in my day, let alone fit enough time to finish the thing, but it shall be done! Sometime in the hopefully near future.
  3. There’s no three. But post something you want to read/talk about.

Anyhow, I know we still have some regular visitors (mostly thanks to Michael I think, his articles are almost always at the top of viewed pages in Google Analytics), and don’t leave. Sign up for the rss/atom feed so you don’t have to check each time but get notified. That is if you’re using a decent rss/atom feed reader, I like Google’s.

If anyone has any ideas for the Language thingie do post them by the way! Implementations for ideas, ideas only (don’t feel limited by implementation difficulties), anything really. A little feedback is always nice to get.

Re: Language

These features are pending proof of concept implementation. Currently I’m very busy with my study and my job and Maurice is as well so you probably won’t see anything anytime soon. But to be honest, from my side it’s also laziness. But today I sat down and wanted to come up with some algorithms.

Read the rest of this entry »

HAI! / Language

Hello World! I’m Maurice, I’m new to .simplicity, nice to meet you, etc.

Language

I’ve been experimenting with some fun stuff lately, it involves language, programming, password-dictionaries, spell checkers, and more :) .

Read the rest of this entry »

Free Gaming Alliance – Continued

Some while ago I wrote an article about the Free Gaming Alliance, an organization that could help with the promotion and development of Free Open Source Games. At the time that I wrote that article I was not sure how well it would be received by the public. In the end the reactions turned out to be fairly positive.

Lets start with a reply to the original article. Some while after the article was published on .simplicity Valentin Anastase from the non-profit organization Freezing Moon replied. He provided a link to two sites, including Freezing Moon’s, dedicated to free gaming. Freezing Moon comes close to the idea that I sketched in the previous article, but it is not completely the same. Opposed to the Free Gaming Alliance, Freezing Moon actually develops games themselves. While I think that we should first deal with other issues concerning free gaming, I am happy to see an initiative like Freezing Moon and I encourage people to check it out.

Another interesting development can be found at OpenGameArt.org. OpenGameArt.org is a website that hosts “free, legal art for open source game projects”. It started small, but the amount of art has been growing fast. And the art that is being hosted on OpenGameArt.org is certainly not bad; it looks very good. If you are looking for art for your Free Open Source Game or want to support free game art (OpenGameArt.org accepts donations), then definitely check OpenGameArt.org.

So, there are initiatives focused on Free Open Source Gaming, but what about me? Through Sirrf I am trying to improve the Free Open Source Gaming ecosystem. I am wondering if I can have an impact on it in other ways, though.

Old Games

I’m a Gamer, can’t help it. Lately I’ve been rediscovering my PSX, while my original is broken, I found a excellent emulator and a neat rom site. With those, I can re-live Medieval times in Medievil one and two, jump on pigs in Tomba, and these are really 2 great games! Why doesn’t Steam have some sort of PSX emulator with (seperate) games for sale? That’d be great. :) Games wouldn’t be expensive and it’d be hours and hours of fun. So, if you can get a PS 1 or 2 and also the games noted earlier, go get them, you’re missing out for a few bucks. Also worth noting is Spyro The Dragon, I don’t recall having so much fun with dragons without brutally slaying them and yelling OOM.

Sorry for the long time no update, hope you are still watching. :)

Some small updates after the break.
Read the rest of this entry »

.simplicity Code and Java Sigslot Event System

Today we are launching .simplicity Code. .simplicity Code is a project created to maintain open-source projects from .simplicity that are too small to be considered as full-blown projects, but too big to be considered as simple code snippets. We are launching this project, because we often work on small projects without any other target audience than ourselves. These projects are the typical projects that are started out of self-interest. We recognize, though, that the code we write for these projects can be of interest to our visitors. .simplicity Code offers us the opportunity to publish this code, without having to offer complete support as a full-blown project would require. As a matter of fact most projects on .simplicity Code will have limited to no support. That does not mean that you will find junk on .simplicity Code. On the contrary, you will find that the code will be most of the time of the same quality as our bigger projects.

Read the rest of this entry »

Nick <3 Ubuntu

Hai!

I installed Ubuntu on my laptop a while ago, but didn’t use my laptop a lot because I had a computer that was about 30 times as fast (P3 Mobile vs. Core 2 Duo). But when I’m not at home, thus not at my computer, I only have my laptop! And since I’m far far away from home now for my study… I got to know Ubuntu a bit more.
Read the rest of this entry »

Sirrf version 0.2.1 released!

0.2.1 is here, 9 days later the simple irrlicht framework team re-emerges with a feature and bug release. Some bugs have been fixed and some new features introduced, the changes include :

  • Script-side GameStates
    It is now truely possible to derive from the GameState class (through CGameState) in scripts. A bug in previous versions prevented this, but this bug has now been fixed.
  • Script-side Components
    EntityComponent can be derived from script-side (through CEntityComponent), classes in script can now create components and register them with entities from script or engine side.
  • Script-side Events
    The event system is now integrated into the script engine. Script-side classes can derive from IHasSlots and can register, connect and disconnect from slot events.
  • Important Bug Fixes:
    • Construction of entity components with parent is now relatively safe. If you are not sure whether your component has a parent, check it after construction. If the component has no parent, destroy it as quickly as possible
    • AssetProcessors on windows were never loading assets unless the files were all lowercase, restrictions were irrlicht related but solved.
    • Minor bug fixes with script side things, Scolor fixes, asset groups on entities and much much more.

Useful links
SourceForge.net page – http://sourceforge.net/projects/sirrf
Downloads – http://sourceforge.net/projects/sirrf/files/ | http://www.ohloh.net/p/sirrf/download?package=Sirrf
Documentation – API | Tutorials

Sirrf version 0.2.0 released!

The latest release of Sirrf, the Simple Irrlicht Framework, version 0.2.0, is now available for download. In the two months since the previous release a lot of changes have taken place. These changes range from small API changes to major feature additions. The most noticeable changes include:

  • Asset Management
    The biggest new feature is asset management. Assets are managed by the AssetManager class. This manager manages so-called asset groups, which represent a collection of assets (meshes, textures, etc). These assets are retrieved from a directory with the appropriate directory structure. In turn the found assets are processed by asset processors. And at the end of the road, the user can use these assets without having to deal with paths. Furthermore asset management makes it possible to reload all assets in realtime, with direct results on the current scene. Reloading assets is as simple as one function call.
  • XML-based Entity files
    It is now possible to load data concerning entities and their components from XML-files. This means that you can now define a scene through XML-files.
  • Local Event System
    As of version 0.2.0 a HasEvents class, which provides the base for a local event system, is available. The availability of local event systems makes the entire framework more performant. Currently the HasEvents class is used by entities and asset groups.
  • Microsoft Visual C++ 2008 support
    Version 0.2.0 is the first release that officialy supports Microsoft Visual C++ 2008. This should make it easier to set up Sirrf-based projects accros multiple platforms.

See the change log for more information regarding the changes in Sirrf version 0.2.0.

This is not the end of Sirrf’s development, though. Sirrf’s development will continue and Sirrf will undoubtely become even better in the future. And you, as a Sirrf user, as a member of the Irrlicht community, can help us improve the framework. This can be done by contributing code to the project, but also by testing the framework. Either way, we hope that Sirrf will be of use.

Useful links
SourceForge.net page – http://sourceforge.net/projects/sirrf
Downloads – http://sourceforge.net/projects/sirrf/files/ | http://www.ohloh.net/p/sirrf/download?package=Sirrf