[Haskell-cafe] Define a module in multiple files

Roel van Dijk vandijk.roel at gmail.com
Mon Nov 30 12:21:44 EST 2009


On Mon, Nov 30, 2009 at 5:15 PM, Ozgur Akgun <ozgurakgun at gmail.com> wrote:
> Is there a way of splitting the definition of a module into multiple files?

Let's say you have some module A which introduces 3 symbols:

module A (a, b, c) where
a = 1
b = 2
c = 3

Now we will split it in 3 modules:

module B ( b ) where
b = 2

module C ( c ) where
c = 3

module A (a, b, c) where
import B ( b )
import C ( c )
a = 1

You can also do the inverse: create a single module of which parts are
exported in multiple other modules. This can be useful to avoid
circular dependencies while still presenting a nice interface to your
library users.


More information about the Haskell-Cafe mailing list