Allow custom serialization of functions