let moonFull = let v = ref false in fun () -> v := not !v; !v ;; module type S = sig type t val x : t val f : t -> t val g : t -> t -> bool end;; module Weird (Top : sig end) = (struct type t = int let x = if moonFull () then 1 else 2 let f x = x + 2 let g x y = (3*x + 2*y) / (x - y + 1) = 7 end : S);; module Gen (X : functor (Top : sig end) -> S) = X (struct end);; module W1 = Gen (Weird);; (* moon full now *) module W2 = Gen (Weird);; (* moon no longer full now *) W1.g W1.x W2.x;;