Open atomanyih opened 2 years ago
Wow, what a code example. Would you be able to share the background of the code? I'm intrigued. Optional, not required for help.
FromReader
cannot infer from the parent signature if there is more than one function in the pipe.
const getAndEatSausge = (length: Sausage["length"]) => pipe(
RTE.fromReader(getSausage(length)) as RTE.ReaderChainEither<Sausage, VeganError, Sausage>,
RTE.chainW(eatSausage)
)
Alternatively there is RTE.rightReader
where the default error type is never
such that TS can do the job.
pipe(
getSausage(length),
RTE.rightReader,
RTE.chainW(eatSausage)
)
🐛 Bug report
Current Behavior
Hullo again with another issue. Please excuse me if I'm totally misunderstanding what's going on here!
It seems that
fromReader
returnsReaderTaskEither
withunknown
as the left (error) parameter. If this is then chained, the error type isunknown | VeganError
which reduces tounknown
, erasingchainW
ed error types.Expected behavior
The above code should compile
Suggested solution(s)
I might expect
fromReader
to returnnever
as the error parameter, as it can never error. This would also properly union when widened withchainW
.See working example where I substitute the
fromReader
with a never-error RTE:Your environment