Version française
Home     About     Download     Resources     Contact us    
Browse thread
Signature matching question?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Signature matching question?
> 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