I have this sample code:
import {none, some, chain} from 'fp-ts/lib/Option';
import {pipe} from 'fp-ts/lib/pipeable';
const f1 = (input: string) => {
return some(input + " f1")
};
const f2 = (input: string) => {
return some(input + "f2")
};
const f3 = (input: string) => {
return none;
};
const f4 = (input: string) => {
return some(input + "f4");
};
const result = pipe(
f1,
chain(f2),
chain(f3),
chain(f4),
)("X");
console.log("result", result);
And I am getting this compile time error
Argument of type '(input: string) => Option<string>' is not assignable to parameter of type 'Option<string>'.
Type '(input: string) => Option<string>' is missing the following properties from type 'Some<string>': _tag, value
18 f1,
~~
src/index.ts:18:5
18 f1,
~~
Did you mean to call this expression?
What is wrong with my code?
I expect f1
and f2
to run and other function not because of none
returning in f3
and at the end the output to be Some "X f1 f2"