(************************************************************ counter.ml Created : Fri Aug 8 20:16:18 2003 Last modified: Fri Aug 08 21:00:17 2003 Compile: ocamlc counter.ml -o counter # FTP Directory: sources/ocaml # ************************************************************) (** 型エラーを起こします。 File "counter.ml", line 8, characters 28-70: This expression has type int * (unit -> int * (unit -> 'a)) but is here used with type int * (unit -> 'a) Unify 時に occur check で引っかかる。 Unify((int * (unit -> 'a)), 'a) 再帰型を許していないので、こんな関数はかけない。そこで... (counter2.ml に続く) *) let rec counter_new init = (init, (fun () -> (counter_new (init + 1)))) let counter_value (v, _) = v let counter_increment (_, f) = f ()