serialization of option and either types