Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Type visibility limitation in recursive modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-12-23 (14:25)
From: Márk_S._Zoltán <zoltan.s.mark@d...>
Subject: Type visibility limitation in recursive modules
Behold the following code snippet:

module rec Aleph :
        type t = Tag of Beth.t
    end =
        type t = Tag of Beth.t
and Beth :
        type t
        val scandalous : Aleph.t
    end =
        type t = Aleph.t list
        let scandalous = Aleph.Tag((* HERE BE DRAGONS *) [])

The compiler complains that the empty list after HERE BE DRAGONS has 
type 'a list but it is used with type Beth.t. I'd expect the compiler to 
discover that those types can be unified via 'a == Aleph.t, since as far 
as I can tell, all necessary facts are visible at that point. Replacing 
"Beth : sig type t ..." with "Beth : sig type t = Aleph.t list ..." does 
away with the error, but I would very much like to keep Beth.t an opaque 
type. Is this an intended behavior? And if it is intended, is there a 
way to tell the compiler what I really want it to do?

Thanks in advance for any help.