open Batteries class type ['a] number = object ('b) method value: 'a method plus: 'b -> 'b end class int_wrap (i: int) = object val i = i method value = i method plus (other: int number) = {< i = i + other#value >} end class float_wrap (f: float) = object val f = f method value = f method plus (other: float number) = {< f = f +. other#value >} end let parse: string -> 'a number = fun s -> if String.exists s "." then float_of_string s |> new float_wrap else int_of_string s |> new int_wrap