クイズの件

OCaml
module A1 = F(V1)
が無限ループしなくて
module A2 = F(V2)
が無限ループする例ならできました。

module type T = sig
  type t
  val g : (t -> t) -> bool
end

module V1 : T = struct
  type t = unit
  let g f = f (); true
end

module V2 : T = struct
  type t = bool
  let g f = f true && not (f false)
end

module F (V : T) = struct
  let x = V.g (fun x ->
    if V.g (fun y ->
      if x = y then y else let rec loop x = loop x in loop ())
    then x else x)
end


追記:
module A1 = F(V1)
で無限ループして
module A2 = F(V2)
で無限ループしない例も。

module F (V : T) = struct
  let x = V.g (fun x ->
    if V.g (fun y -> x)
    then let rec loop x = loop x in loop ()
    else x)
end