[Haskell-cafe] generate Haskell code from model

Steffen Mazanek haskell at steffen-mazanek.de
Fri Apr 13 07:48:03 EDT 2007

Hello everybody,

I would like to start a discussion on how to generate
best-practice Haskell code from a model, e.g. from

It seems to be very difficult and unconvenient to simulate
OOP with Haskell (as described in the paper "Object-oriented
style overloading for Haskell"). However, I think it might
be possible to generate "something useful" out of a model to
not start from scratch an implementation.

For example, I could imagine to generate for every class
a module, import and export lists and a type class (with some
restrictions) at the very least.

In the EMF book there is an example, PurchaseOrder, look at


at page 11.

How would you like generated code from this model to look like?

The most obvious way would be something like this:

data PurchaseOrder = PurchaseOrder {shipTo::String, billTo:: String,
data Item = Item {productName::String, quantity::Int, price::Float}

This does not work well if function names are reused or
inheritance comes into play, however, even this might be a useful
starting point (better than nothing).

The benefits of the model+generate approach are well known. Best practices
in programming are propagated, for Haskell e.g. use different modules
for different things, use the tedious import/export lists, Haddock your

What are your ideas?

Best regards,

Dipl.-Inform. Steffen Mazanek
Institut für Softwaretechnologie
Fakultät Informatik

Universität der Bundeswehr München
85577 Neubiberg

Tel: +49 (0)89 6004-2505
Fax: +49 (0)89 6004-4447

E-Mail: steffen.mazanek at unibw.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070413/feb6b6cb/attachment.htm

More information about the Haskell-Cafe mailing list