Version française
Home     About     Download     Resources     Contact us    
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: Jonathan Roewen <jonathan.roewen@g...>
Subject: Re: [Caml-list] Type from local module would escape its scope?
> The following is accepted:
>
> module type FOO =
> sig
>   type t
>   val value : t
> end ;;
>
> let foo () =
>   let module Foo : FOO =
>   struct
>     type t = int
>     let value = 1
>   end in
>   ignore Foo.value
> ;;
>
> 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
> ;;
>
> With an error on the expression "Foo.value" stating that "The type
> constructor Foo.t would escape its scope". Reading about the typical
> case for this error message in http://caml.inria.fr/pub/ml-archives/
> caml-list/2002/10/0cf087feab3ef8dc5ccba5a8592472fb.en.html didn't
> really help me. Why does it make a difference whether ignore is an
> argument?

Because the type isn't visible (ignore returns unit, not Foo.t).

Jonathan