include struct
open Optional type'a is_the_default ='a Optional.is_the_defaultlet defaults_to = defaults_to let(!!)= override let singleton = singleton moduletype Singleton = Singleton end module Bool :sigtype t = bool module True_ : Singleton withtype real = t module False_ : Singleton withtype real = t end=structtype t = bool module True_ =(val singleton true: Optional.Singletonwithtype real = t)module False_ =(val singleton false: Optional.Singletonwithtype real = t)end includestructopen Bool.True_type true_ = t let true_ = t end includestructopen Bool.False_type false_ = t let false_ = t end module Test_bool :sigval f : ?x:true_ is_the_default -> ?y:false_ is_the_default -> unit -> bool * bool end=structlet f ?x ?y ()=let x = defaults_to x true_ inlet y = defaults_to y false_ in x, y ;; end let()=let f = Test_bool.fin assert ((true , false)= f ()); assert ((false, false)= f ~x:!!false()); assert ((false, true)= f ~x:!!false ~y:!!true()); ;; module Int :sigtype t = int module N_zero : Singleton withtype real = t module N_one : Singleton withtype real = t module N_million : Singleton withtype real = t end=structtype t = int module N_zero =(val singleton 0 : Optional.Singletonwithtype real = t)module N_one =(val singleton 1: Optional.Singletonwithtype real = t)module N_million =(val singleton 1_000_000 : Optional.Singletonwithtype real = t)end module Test_int :sigval f : ?x:Int.N_zero.t is_the_default -> ?y:Int.N_one.t is_the_default -> ?z:Int.N_million.t is_the_default -> unit -> int * int * int end=structlet f ?x ?y ?z ()=let x = defaults_to x Int.N_zero.tinlet y = defaults_to y Int.N_one.tinlet z = defaults_to z Int.N_million.tin x, y, z ;; end let()=let f = Test_int.fin assert ((0, 1, 1_000_000)= f ()); assert ((0, 1, 13)= f ~z:!!13()); assert ((1, 2, 3)= f ~x:!!1 ~y:!!2 ~z:!!3()); ;;