English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Type from local module would escape its scope?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-07-03 (13:45)
From: Alain Frisch <Alain.Frisch@i...>
Subject: Re: [Caml-list] Type from local module would escape its scope?
Bruno De Fraine wrote:
> While the following is rejected:
> let foo (ignore: 'a -> unit) =
>   let module Foo : FOO =
>   struct
>     type t = int
>     let value = 1
>   end in
>   ignore Foo.value
> ;;

The 'a variable is existential and it must be instantiated (because
functional arguments are used monomorphically). Clearly, it will be
unified with Foo.t, which is abstract, and so the type for foo, if it
were well-typed, would be:

val foo: (Foo.t -> unit) -> unit

Foo.t would escape its scope, which is not ok.

-- Alain