Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Camlp4 3.01 released
@ 2001-03-11  5:04 Daniel de Rauglaudre
  2001-03-12 11:52 ` [Caml-list] Caml 3.01 : pb with include Christophe Raffalli
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel de Rauglaudre @ 2001-03-11  5:04 UTC (permalink / raw)
  To: caml-list

Hi evribody,

Camlp4 3.01 compatible with OCaml 3.01 has been released
      http://caml.inria.fr/camlp4/

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Caml-list] Caml 3.01 : pb with include
  2001-03-11  5:04 [Caml-list] Camlp4 3.01 released Daniel de Rauglaudre
@ 2001-03-12 11:52 ` Christophe Raffalli
  2001-03-12 17:13   ` Andreas Rossberg
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe Raffalli @ 2001-03-12 11:52 UTC (permalink / raw)
  To: caml-list


I tried to use the new include feature for my algebra library. I failed
!
Am I missing something ?

Here is a small example I created just to show the problem:

module type Semi_Group =
sig
  type t
  val e : t
  val ( ** ) : t -> t -> t
end

module type Group =
sig
  include Semi_Group
  val inv : t -> t
end

module type Semi_Group_Morphism =
sig
  module SG1 : Semi_Group
  module SG2 : Semi_Group
  val f : SG1.t -> SG2.t
end

module type Group_Morphism =
sig
  module G1 : Group
  module G2 : Group
  include Semi_Group_Morphism with module SG1 = G1 and module SG2 = G2
end

(*
Nice : SG1 et SG2 are groups : Here isCaml answer 

module type Group_Morphism =
  sig
    module G1 : Group
    module G2 : Group
    module SG1 :
      sig
        type t = G1.t
        val e : t
        val ( ** ) : t -> t -> t
        val inv : t -> t
      end
    module SG2 :
      sig
        type t = G2.t
        val e : t
        val ( ** ) : t -> t -> t
        val inv : t -> t
      end
    val f : SG1.t -> SG2.t
 
end                                                                           
*)

module Idt_Semi_Group_Morphism(SG : Semi_Group) = (
struct
  module SG1 = SG
  module SG2 = SG
  let f = fun x -> x
end : Semi_Group_Morphism with module SG1 = SG and module SG2 = SG)

module Idt_Group_Morphism(G : Group) = (
struct
  module G1 = G
  module G2 = G
  include (Idt_Semi_Group_Morphism(G) : Semi_Group_Morphism with module
SG1 = G and module SG2 = G)
end : Group_Morphism with module SG1 = G and module SG2 = G and module
G1 = G and module G2 = G)

(* 
Heavy and does not work ! 

Signature mismatch:
Modules do not match:
  sig
    module SG1 : sig type t = G.t val e : t val ( ** ) : t -> t -> t end
    module SG2 : sig type t = G.t val e : t val ( ** ) : t -> t -> t end
    val f : SG1.t -> SG2.t
  end
is not included in
  sig
    module SG1 :
      sig
        type t = G.t
        val e : t
        val ( ** ) : t -> t -> t
        val inv : t -> t
      end
    module SG2 :
      sig
        type t = G.t
        val e : t
        val ( ** ) : t -> t -> t
        val inv : t -> t
      end
    val f : SG1.t -> SG2.t
  end
Modules do not match:
  sig type t = G.t val e : t val ( ** ) : t -> t -> t end
is not included in
  sig type t = G.t val e : t val ( ** ) : t -> t -> t val inv : t -> t
end
The field `inv' is required but not
provided                                    
*)

-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Caml 3.01 : pb with include
  2001-03-12 11:52 ` [Caml-list] Caml 3.01 : pb with include Christophe Raffalli
@ 2001-03-12 17:13   ` Andreas Rossberg
  2001-03-13 10:32     ` Xavier Leroy
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Rossberg @ 2001-03-12 17:13 UTC (permalink / raw)
  To: caml-list; +Cc: Christophe Raffalli

Christophe Raffalli wrote:
> 
> I tried to use the new include feature for my algebra library. I failed
> !
> Am I missing something ?

Actually it is not the include feature causing the trouble, but rather
your use of with module constraints.

> Here is a small example I created just to show the problem:
> 
> module type Semi_Group =
> sig
>   type t
>   val e : t
>   val ( ** ) : t -> t -> t
> end
> 
> module type Group =
> sig
>   include Semi_Group
>   val inv : t -> t
> end
> 
> module type Semi_Group_Morphism =
> sig
>   module SG1 : Semi_Group
>   module SG2 : Semi_Group
>   val f : SG1.t -> SG2.t
> end
> 
> module type Group_Morphism =
> sig
>   module G1 : Group
>   module G2 : Group
>   include Semi_Group_Morphism with module SG1 = G1 and module SG2 = G2
> end
> 
> (*
> Nice : SG1 et SG2 are groups : Here isCaml answer

Well, not so nice really, because this treatment exactly is what causes
the later error. See below.

> module type Group_Morphism =
>   sig
>     module G1 : Group
>     module G2 : Group
>     module SG1 :
>       sig
>         type t = G1.t
>         val e : t
>         val ( ** ) : t -> t -> t
>         val inv : t -> t
>       end
>     module SG2 :
>       sig
>         type t = G2.t
>         val e : t
>         val ( ** ) : t -> t -> t
>         val inv : t -> t
>       end
>     val f : SG1.t -> SG2.t
> 
> end
> *)
> 
> module Idt_Semi_Group_Morphism(SG : Semi_Group) = (
> struct
>   module SG1 = SG
>   module SG2 = SG
>   let f = fun x -> x
> end : Semi_Group_Morphism with module SG1 = SG and module SG2 = SG)
> 
> module Idt_Group_Morphism(G : Group) = (
> struct
>   module G1 = G
>   module G2 = G
>   include (Idt_Semi_Group_Morphism(G) : Semi_Group_Morphism with module
> SG1 = G and module SG2 = G)
> end : Group_Morphism with module SG1 = G and module SG2 = G and module
> G1 = G and module G2 = G)

Just an aside: some of the outer module constraints here are redundant,
because they are already specified in the signature Group_Morphism. It
should suffice to say:

 ... : Group_Morphism with module G1 = G and module G2 = G

The signature annotation (at the include) also is a bit unnecessary, but
is the one that seems to be causing the error.

> (*
> Heavy and does not work !
> 
> Signature mismatch:
> Modules do not match:
>   sig
>     module SG1 : sig type t = G.t val e : t val ( ** ) : t -> t -> t end
>     module SG2 : sig type t = G.t val e : t val ( ** ) : t -> t -> t end
>     val f : SG1.t -> SG2.t
>   end

That is the result signature of the functor application
Idt_Semi_Group_Morphism(G).

> is not included in
>   sig
>     module SG1 :
>       sig
>         type t = G.t
>         val e : t
>         val ( ** ) : t -> t -> t
>         val inv : t -> t
>       end
>     module SG2 :
>       sig
>         type t = G.t
>         val e : t
>         val ( ** ) : t -> t -> t
>         val inv : t -> t
>       end
>     val f : SG1.t -> SG2.t
>   end

And that is the signature the compiler seems to calculate for

  Semi_Group_Morphism with module SG1 = G and module SG2 = G

Like in the case of Group_morphism above, SG1 and SG2 contain an inv
member in this signature. I think this semantics of module constraints
is not right - it should not extend subsignatures, only propagate type
identities. This not exactly is a bug, but IMHO not what you want in
most situations - at least not in this particular situation. Was there a
particular motivation to design the language this way?

> Modules do not match:
>   sig type t = G.t val e : t val ( ** ) : t -> t -> t end
> is not included in
>   sig type t = G.t val e : t val ( ** ) : t -> t -> t val inv : t -> t
> end
> The field `inv' is required but not
> provided
> *)

And this is correct, given the semantics of module constraints.

The simplest workaround is to remove the signature annotation at the
include spec (did not try it, though). Alternatively, you could avoid
using module constraints and restrict yourself to type constraints, ie.

  include (Idt_Semi_Group_Morphism(G) : Semi_Group_Morphism
           with type SG1.t = G.t and type SG2.t = G.t)

And similar in signature Group_Morphism.

Best regards,

	- Andreas

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids.
 If Pac Man affected us as kids, we would all be running around in
 darkened rooms, munching pills, and listening to repetitive music."
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Caml 3.01 : pb with include
  2001-03-12 17:13   ` Andreas Rossberg
@ 2001-03-13 10:32     ` Xavier Leroy
  2001-03-13 11:18       ` Andreas Rossberg
  2001-03-13 11:23       ` Christophe Raffalli
  0 siblings, 2 replies; 6+ messages in thread
From: Xavier Leroy @ 2001-03-13 10:32 UTC (permalink / raw)
  To: Andreas Rossberg; +Cc: caml-list, Christophe Raffalli

> Like in the case of Group_morphism above, SG1 and SG2 contain an inv
> member in this signature. I think this semantics of module constraints
> is not right - it should not extend subsignatures, only propagate type
> identities. This not exactly is a bug, but IMHO not what you want in
> most situations - at least not in this particular situation. Was there a
> particular motivation to design the language this way?

I can't remember, but the design and implementation of "with module"
dates back to 1996, so my memory is a bit hazy :-)

I agree with you that the most natural interpretation of the "with
module" constraint is to stand for a bunch of "with type" constraints
on the type components of the modules.  With this interpretation, the
current behavior is a bug.  SML'97 also interprets sharing constraints
between structures as the implied sharing constraints between the type
components of these modules.

There might be examples of signature surgery where the current
behavior is useful (I need to go back to my examples to check),
but I agree it's confusing.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Caml 3.01 : pb with include
  2001-03-13 10:32     ` Xavier Leroy
@ 2001-03-13 11:18       ` Andreas Rossberg
  2001-03-13 11:23       ` Christophe Raffalli
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Rossberg @ 2001-03-13 11:18 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: caml-list, Christophe Raffalli

Xavier Leroy wrote:
> 
> I can't remember, but the design and implementation of "with module"
> dates back to 1996, so my memory is a bit hazy :-)

BTW, to challenge your memory a bit more :-), was there a reason not to
integrate manifest module specifications along with "with module"? It
seems a bit odd that I can write

  sig
    module X : S
  end
  with module X = Y

and now even

  sig
    module X : S
    include sig module Y : T end with module Y = X
  end

but not simply

  sig
    module X : S = Y
  end

and

  sig
    module X : S
    module Y : T = X
  end

as for types.

> There might be examples of signature surgery where the current
> behavior is useful (I need to go back to my examples to check),

I believe so as well, but up to now I was not able to come up with any.
If you have an interesting example, I would like to learn about it.

Cheers,
	- Andreas


PS: The docs seem to be somewhat `conservative' on include for
signatures: they say the syntax is

	include modtype-path

but obviously it is the more general

	include module-type

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids.
 If Pac Man affected us as kids, we would all be running around in
 darkened rooms, munching pills, and listening to repetitive music."
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Caml 3.01 : pb with include
  2001-03-13 10:32     ` Xavier Leroy
  2001-03-13 11:18       ` Andreas Rossberg
@ 2001-03-13 11:23       ` Christophe Raffalli
  1 sibling, 0 replies; 6+ messages in thread
From: Christophe Raffalli @ 2001-03-13 11:23 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: Andreas Rossberg, caml-list


What I realy would like are more flexible include and constaints to make the
following work:

module type Semi_Group =
sig
  type t
  val e : t
  val ( ** ) : t -> t -> t
end

module type Group =
sig
  include Semi_Group
  val inv : t -> t
end

module type Semi_Group_Morphism =
sig
  module G1 : Semi_Group
  module G2 : Semi_Group
  val f : G1.t -> G2.t
end

(* I would like to be able to use include for the next definition:
something like:

module type Group_Morphism =
sig
  include Semi_Group_Morphism with module G1 : Group and module G2 : Group
end
*)

module type Group_Morphism =
sig
  module G1 : Group
  module G2 : Group
  val f : G1.t -> G2.t
end

module Idt_Semi_Group_Morphism(SG : Semi_Group) = (
struct
  module G1 = SG
  module G2 = SG
  let f = fun x -> x
end : Semi_Group_Morphism with module G1 = SG and module G2 = SG)

(* I can't make the next definition work using include at all *)
 
module Idt_Group_Morphism(G : Group) = (
struct
  include (Idt_Semi_Group_Morphism(G) : Semi_Group_Morphism with module G1 = G
and module G2 = G)
end : Group_Morphism with module G1 = G and module G2 = G)

-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-03-13 13:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-11  5:04 [Caml-list] Camlp4 3.01 released Daniel de Rauglaudre
2001-03-12 11:52 ` [Caml-list] Caml 3.01 : pb with include Christophe Raffalli
2001-03-12 17:13   ` Andreas Rossberg
2001-03-13 10:32     ` Xavier Leroy
2001-03-13 11:18       ` Andreas Rossberg
2001-03-13 11:23       ` Christophe Raffalli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox