I was trying to start using fp-ts and I had a really hard time with side-effects. I wrote a little test program that will read a file, print the file to screen and return an Either<Error, string>.
I used the basic do notation as an example and ended up with a code that looks somthing like that
const program = pipe(
TE.tryCatch(() => readFile(), () => new Error('Failed to read file')),
TE.chainFirst((text) => pipe(log(text), TE.fromIO)),
);
This code compiles, but typescript infers that the program variable gets the type TE.TaskEither<unknown, string> and I was expecting the type TE.TaskEither<Error, string>.
Is there a way to keep the error type inside the TaskEither? Or am I using this librery all wrong?
p.s I am using fp-ts version 2.8.6