[Haskell-cafe] Define a module in multiple files

Roel van Dijk vandijk.roel at gmail.com
Mon Nov 30 13:07:14 EST 2009


On Mon, Nov 30, 2009 at 6:27 PM, Ozgur Akgun <ozgurakgun at gmail.com> wrote:
> Nice idea, but this way you still need to modify the single module which
> glues them alltogether.
> I wanted to allow the users of the module add some functionality to the
> module itself.

I don't think that is possible.

But a user could easily create a new module which offers all the
functionality of the old one plus the user's own additions.

-- Some library module
module A (a) where
a = 1

-- Custom module written by user
module UserModule (module A, myFunction) where
import A
userPrint = print

-- Program which uses UserModule
module Main where
import UserModule

main = userPrint a

The idea is that UserModule re-exports all symbols from module A. So
importing UserModule brings all symbols from A in scope and possibly
extra symbols defined in UserModule itself.


More information about the Haskell-Cafe mailing list