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

Browse thread
generalization and let module
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] generalization and let module
From: Julien SIGNOLES <>

> Just a single question: why is 'f' not generalizable in the following
> example? I'm not able to find an example using any "let module" and
> breaking the type safety.
> =====
> module M = struct end
> let f = let module N = M in fun x -> x
> =====

What about

let f =
  let module M = struct let x = ref [] end in
  fun x -> let y = List.hd !M.x in M.x := [x]; y ;;

Making this function polymorphic would clearly be unsound.
However, you're right on one account: this can only happen with
structures, but not with module aliasing, or even functor application.
So the non-expansiveness check could be refined.

Jacques Garrigue