Creates a singleton from a function constructor.