Version française
Home     About     Download     Resources     Contact us    
Browse thread
Implicitely abstracted type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: rossberg@m...
Subject: Re: [Caml-list] Implicitely abstracted type
> Yesterday I encountered an ocaml error that, if I can now make some
> sense out of it -- it's not properly speaking a bug -- was quite
> confusing at first and took me  some time to figure out.
>
> What happens is that a sum-type defined in a module can implicitely be
> turned into abstract because of its inner contents.
>
> Here is a small example:
> ------
> module F (A : sig type a end) = struct
>   type a = A.a
>   type t = X of A.a
> end
>
> (* if A.a is abstract, the type F.t is made abstract *)
> module A = F (struct type a end)
> (*
>   The inferred interface is:
>   module A : sig type a type t end

That is a well-known limitation. The fix is to name the argument module:

  module TA = struct type a end
  module A = F (TA)

/Andreas