Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Signature matching question?
@ 1999-02-12  1:47 Manuel Fahndrich
  1999-02-19 15:29 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Manuel Fahndrich @ 1999-02-12  1:47 UTC (permalink / raw)
  To: CAML List (E-mail)


I've run into the following problem with signature matching.

Consider the following module type and module definitions:

module type FOO =
  sig

    type bar

    module A :
  	sig

	  val fresh : unit -> bar

  	end

  end

module Foo : FOO =
  struct

    module A =
      struct
	type t = {foo: int}

	let fresh () = {foo=1}

      end

    type bar = A.t

  end

ocamlc -i test.ml
File "test.ml", line 19, characters 2-133:
Signature mismatch:
Modules do not match:
  sig
    module A : sig type t = { foo: int } val fresh : unit -> t end
    type bar = A.t
  end
is not included in
  FOO
Modules do not match:
  sig type t = { foo: int } val fresh : unit -> t end
is not included in
  sig val fresh : unit -> bar end
Values do not match:
  val fresh : unit -> t
is not included in
  val fresh : unit -> bar


Is this intended behavior, or a bug? I would assume that within a module,
delcarations are treated as an unordered set.
Thus, the compiler should first find all type equivalences before matching
individual types.

-Manuel




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

* Re: Signature matching question?
  1999-02-12  1:47 Signature matching question? Manuel Fahndrich
@ 1999-02-19 15:29 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 1999-02-19 15:29 UTC (permalink / raw)
  To: Manuel Fahndrich, CAML List (E-mail)

> I've run into the following problem with signature matching.
>
> module type FOO =
>   sig
>     type bar
>     module A : sig val fresh : unit -> bar end
>   end
> 
> module Foo : FOO =
>   struct
>     module A =
>       struct type t = {foo: int} let fresh () = {foo=1} end
>     type bar = A.t
>   end
>
> [... Signature mismatch ...]

> Is this intended behavior, or a bug? I would assume that within a module,
> delcarations are treated as an unordered set.

It is a bug.  The intent is, as you say, to perform signature matching
independently of the order of module components.  The typing rules
currently implemented get it right when there are only type and value
components, something is wrong with nested modules as in your example.

Indeed, your example type-checks when rewritten as follows:

> module Foo1 =
>   struct
>     module A =
>       struct type t = {foo: int} let fresh () = {foo=1} end
>     type bar = A.t
>   end
> module Foo : FOO = Foo1

The naming of the structure allows the type-checker to get its type
names right.

It's not obvious how to change the signature matching rules, though,
so I don't promise a quick fix.

- Xavier Leroy




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

end of thread, other threads:[~1999-02-19 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-12  1:47 Signature matching question? Manuel Fahndrich
1999-02-19 15:29 ` Xavier Leroy

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