[Haskell-cafe] 2 modules in one file

Marc Weber marco-oweber at gmx.de
Tue Aug 26 06:45:11 EDT 2008

>  Is it allowed to write two
>  different modules in a single
>  file? Something like:
>  module Mod1 (...) where {
>  ...
>  }
>  module Mod2 (...) where {
>  import Mod1;
>  ...
>  }
>  I tried, and got an error,
>  but would like to confirm
>  that there's no way to do
>  that.

No, that's not possible because haskell will use the module name A.B.C
to look the module up in path A/B/C.[l]hs.
So using modules
module A where
module B where
the compiler could only find one of them. (naming the file A.hs or B.hs)
You have to use one file for each module

I think there is another tool somewhere to merge many modules into one.
But I don't think that's what you're looking for. (I haven't tried that

Marc Weber

More information about the Haskell-Cafe mailing list