optional function
Creates State that generates source code that will return the result of
the state computation  or null.
This computation always completes successfully.
Implementation
State optional(State state) {
  final type = getNullableType(state.type);
  final optional = ChoiceState(type, [state, value(type, 'null')]);
  return optional;
}