thames-technology/monads

Erasing T for isErr

Closed this issue · 1 comments

The function isErr is not erasing the T of Result<T, E> even though it could do so, and its partner function isOk is already erasing E.

Changing the signature to export function isErr<T, E>(val: Result<T, E>): val is ResErr<never, E> would allow writing if (isErr(value)) { return value; } analogous to if (isOk(value)) { return value; } which already is possible.

Hi @maxmuen, thanks for raising this, it should be a fairly trivial change - would you mind creating a PR?