caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* generalization and let module
@ 2007-06-21 15:25 Julien SIGNOLES
  2007-06-22  0:32 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Julien SIGNOLES @ 2007-06-21 15:25 UTC (permalink / raw)
  To: caml-list

Hello all,

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
=====

--
Julien


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] generalization and let module
  2007-06-21 15:25 generalization and let module Julien SIGNOLES
@ 2007-06-22  0:32 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2007-06-22  0:32 UTC (permalink / raw)
  To: julien.signoles; +Cc: caml-list

From: Julien SIGNOLES <julien.signoles@cea.fr>

> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-22  0:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-21 15:25 generalization and let module Julien SIGNOLES
2007-06-22  0:32 ` [Caml-list] " Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).