Main.main naming convention

Hal Daume III hdaume@ISI.EDU
Mon, 9 Sep 2002 16:26:54 -0700 (PDT)


I know I wasn't the intended recipient of this question, but I also lament
this, so I'll answer for myself.

> So?  That just means that the file name of Program1.hs,
> Program2.hs, etc will be different from the name of the
> module that they contain.  

The problem is that often you'll have a library which you import in a lot
of programs which you also want to be executable.  For example, I have a
module:

  NLP.Vocabulary

which provides an abstract interfact to, essentially, a map from strings
to unique ids + some other machinery.  There are some common operations
you want to do only once using vocabularies, for instance, gobble up a
bunch of text files and create a vocabulary containing words in those
documents or perhaps display the elements of a vocabulary in a
list.

Thus, you want a main function in this module so that you can do something
like (from the unix prompt)

  % vocabulary -build myfiles* -o myvocabulary

but you still want to be able to 'import NLP.Vocabulary' in your Haskell
modules.

What you have to do is have a seperate 'ManipulateVocabulary' module which
basically imports NLP.Vocabulary and has a very short & sweet main
function.

In this case, that's not a big deal.  But I have at least 10 such modules
where I am forced to have two modules per concept.  Not impossible, but
obnoxious.

 - Hal