[Haskell-cafe] I miss OO

Michael Mossey mpm at alumni.caltech.edu
Wed Nov 25 15:51:42 EST 2009

I'm fairly new to Haskell, and starting to write some big projects. 
Previously I used OO exclusively, mostly Python. I really miss the 
"namespace" capabilities... a class can have a lot of generic method names 
which may be identical for several different classes because there is no 

In my musical application, many "objects" (or in Haskell, data) have a time 
associated with them. In Python I would have an accessor function called 
"time" in every class.

So if I have objects/data note1, cursor1, and staff1,


Haskell needs something like
   note_time note1
   cursor_time cursor1
   staff_time staff1

which is a lot more visually disorganized.

What's worse, I have a moderate case of RSI (repetitive strain injury) so I 
type slowly and depend on abbreviations a lot. I use the souped-up 
abbreviation capabilities of Emacs. Let's say I have a 
field/member-variable called orientedPcSet that is used across many 
classes. In Python, I can create an abbreviation for that and it is useful 
many times. In Haskell, I might need


which prevents me from using abbreviations effectively (especially the 
dynamic-completion feature). (It would help to make the underscore not part 
of word syntax, but that's not ideal.)

So I'm thinking of moving to a scheme in Haskell using modules, most types 
being defined in their own modules, and doing qualified imports. Generic 
names like 'time' can be defined in each module w/o clashing. Then I have

Note.time note1
Cursor.time cursor1
Staff.time staff1

This is very useful because I can define abbreviations for the type name 
and for oft-used accessor function names and these abbrevs are more 
organized, easier to remember, and easier to combine.

I would be interested in comments... is this a good way to do things? Am I 
trying too hard to impose OO on Haskell and is there a better way?


More information about the Haskell-Cafe mailing list