Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at 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: -- (:)
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