I am having a look at pipe and Option in fp-ts for the first time.
I have this code which does type narrow but I'm sure it can be done without the if statement:
if (O.isNone(this.state)) {
return undefined;
}
return this.lens.get(this.state.value);
You can try to use
pipein combination withOption.fromNullableandOption.map:So for your example, it would be like: