Haskell++

Haskell++ is an `object oriented' extension of Haskell, which supports a form of inheritance via extended class and instance declarations. In addition to ordinary Haskell classes, the Haskell++ programmer can declare `object classes' whose instances can inherit method definitions from one another. For example, an object class Point may have instances at types VanillaPoint and ColourPoint, and the ColourPoint instance may inherit some of its methods from the VanillaPoint instance. Haskell++ is described in detail in Haskell++: An Object-Oriented Extension of Haskell, a joint paper with Jan Sparud which was presented at the Haskell Workshop in June '95. For a more extensive example of its use, there is a ray tracing package developed as an undergraduate project.

Haskell++ is implemented via a translator to Haskell, which can be fetched via this page, and which is itself written in Haskell.To use Haskell++ you will therefore need a Haskell implementation. Existential types can be used in both Haskell and Haskell++ to type the dynamic binding of object-oriented languages (see Läufer96), and since you will almost certainly want to use dynamic binding you ought to use a Haskell implementation that supports them.

The translator is called h++, and can be invoked either with or without a command-line argument. If the argument is present, for example foo, then Haskell++ source is read from foo.h++ and the Haskell translation is written to foo.hs. If no argument is given the translation works from standard input to standard output.

The translator is a prototype, and is rather `rough and ready'.

Nevertheless, even as it stands the translator can be quite useful!

If you still want it, you can fetch the source of the translator from h++.hs. You will also need the parsing library it uses, Parselib.hs, which is based on Graham Hutton's JFP article. It's been updated to Haskell 98, and at least loads into Hugs, but has not been thoroughly tested since the updates.

I'm interested to hear of experience in using Haskell++, positive or negative. I'm especially interested to know whether Haskell++ is sufficient powerful to represent interesting object-oriented programs in practice, or whether further language extensions are needed.

I'm not particularly interested in discussing whether or not a change in state is suitably represented by returning a new object. I will accept bug reports for the translator, but I don't promise to do anything with them!


John Hughes
Last modified: Mon Mar 26 11:24:51 MET DST 2001