Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Why redefinition of modules is forbidden?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: sjah@l...
Subject: [Caml-list] Why redefinition of modules is forbidden?
Hello!

How to do following thing the best way?

I have to extend old module and its submodule with some
new functions. Old module is big enouth.

This method doesn't work due to %subj%:

module X =
struct
    let f1 = ...
    let f2 = ...
    ...
    let f99 = ...

    module Y =
    struct
        let f1 = ..
        let f2 = ..
        ...
        let f99 = ...
    end
end

module ExtX =
struct
    include X

    let f100 = ...
    ...
    let f199 = ...

    module Y =
    struct
        include Y
        
        let f100 = ...
        ...
        let f199 = ...
    end
end

Multiple definition of the module name Y.
Names must be unique in a given structure or signature.

Following approach works, but it is hard to maintain
big module type signature to reflect changes in X and Y.

module X =
struct
    let f1 = ...
    let f2 = ...
    ...
    let f99 = ...

    module Y =
    struct
        let f1 = ..
        let f2 = ..
        ...
        let f99 = ...
    end
end


module type X_without_Y =
sig
    val f1 ; ...
    val f2 : ...
    ...
    val f99 : ...
end


module ExtX =
struct
    include (X : X_without_Y)

    let f100 = ...
    ...
    let f199 = ...

    module Y =
    struct
        include X.Y

        let f100 = ...
        ...
        let f199 = ...
    end
end

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners