Version française
Home     About     Download     Resources     Contact us    
Browse thread
Bug in the module system of version 3.12.0+beta1
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jeremy Yallop <yallop@g...>
Subject: Re: [Caml-list] Bug in the module system of version 3.12.0+beta1
On 21 July 2010 14:38, Dumitru Potop-Butucaru
<dumitru.potop_butucaru@inria.fr> wrote:
> module type Abc =
>   functor (M:Simple) ->
>   sig
>      val x : M.t
>   end

You're trying to treat Abc as a functor from signatures to signatures
(i.e. as a parameterised signature).  In fact, it's something quite
different: it's the *type* of a functor from structures to structures.

You can emulate a parameterised signature using a signature with some
opaque components, which are later specified using substitution.
Here's the "parametrised signature":

  module type ABC =
  sig
    module M : Simple
    val x : M.t
  end

Here's how to supply a value for M:

  module MyModule :
  sig
     include ABC with module M = IntList
     val y : int
  end
= ...

In OCaml 3.12 you can use destructive substitution instead, ensuring
that M doesn't appear in the output signature.  Note the ':=' in the
line that includes ABC:

  module MyModule :
    sig
       include ABC with module M := IntList
       val y : int
    end
  = ...