I have 3 functions, f1
, f2
, f3
.
f1
and f3
are sync and return Option<string>
but f2
is an async function return Promise<Option<string>>
.
How should I use these three functions in a single pipe?
Here is my code:
import {some, chain} from 'fp-ts/lib/Option';
import {pipe} from 'fp-ts/lib/pipeable';
const f1 = (input: string) => {
return some(input + " f1")
};
const f2 = async (input: string) => {
return some(input + " f2")
};
const f3 = (input: string) => {
return some(input + " f3");
};
const result = pipe(
"X",
f1,
chain(f2),
chain(f3),
);
console.log("result", result);