(small update to make it closer to my real task)
How to write f2 using dependent pattern matching? (Code below compiles except definition of f2)
Inductive parse_ret : Set :=
No : parse_ret | Yes : parse_ret.
Inductive exp : parse_ret -> Set :=
| No_parse : exp No
| Yes_parse : exp Yes.
Definition f1 (p : parse_ret) : option (exp p) :=
match p with
| No => Some No_parse
| Yes => Some Yes_parse
end.
Definition f2' : option nat :=
match f1 No with
| Some No_parse => Some 1
| Some Yes_parse => Some 1
| None => None
end.
So, f2' is almost what I need, but Some Yes_parse is obviously redundant here because we provided No constructor to f1 and f1's return type becomes option (exp No).
How to write definition for f2? avoiding the Non exhaustive pattern-matching error?
Definition f2 : option nat :=
match f1 No with
| Some No_parse => Some 1
| None => None
end.