let module は expansive ?
# let id = let module M = struct end in fun x -> x ;; val id : '_a -> '_a = <fun>
なんでですか?あんまり考えてないってのもあるけど、ヤバイ例が思いつきません。
Caml mantis でも、
What you propose is changing the value restriction to accept a local
module binding. Before we do that, we'll need to come up with a proof
that such a change is sound. Intuitively, I don't believe it's the
case.
ってダミアンが否定的な事言ってるけど、、、(http://caml.inria.fr/mantis/view.php?id=4511)
追記
そりゃそうか。
let id = let v = ref [] in fun x -> v := [x]; x
が polymorphic にならないのと同じ理由だ:
(* 明らかにまずい例 *) let id = let module M = struct let v = ref [] end in fun x -> M.v := [x]; x
しかし、 Local module の定義を調べて全部 non-expansive なら絶対 ok だと思うんだが、どでしょう。現在の OCaml はそこまで調べずに即、expansive という扱い。