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