Version française
Home     About     Download     Resources     Contact us    
Browse thread
Type equalities in sub modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Type equalities in sub modules
Hello,

In the example below, is there any way to achieve M.B.t = M.t without  
introducing the intermediate mt type ?

> module M = struct
>   type t = int
>   module B = struct
>     type mt = t
>     type t = mt
>   end
> end

This doesn't work :

> module M = struct
>   type t = int
>   module B = struct
>     type t = M.t
>   end
> end

This doesn't work :

> module M = struct
>   type t = int
>   module B = struct
>     type t = t
>   end
> end

It seems type definitions should have been designed like value  
definitions by having both a 'type' and 'type rec' construct (though  
one can argue this is sufficently rare to justify the above  
inconvenience).

Thanks for your answers,

Daniel