Thanks!
It is possible to make the type inference smart enough to not need to explicitly type the types:
The reason that you have to provide all type arguments in railroad
is not because they can’t be interference of the argument. It is because it doesn’t know that formatName
is going to introduce a new error type in the then
. Not declaring all the error types means that formatName
cannot be composed with getUser
because they have incompatible types for e
.
The solution is relatively simple: update then
so that the new RailRoad
has e | newE
as its error type. With this we can expand the possible errors in e
which each call to then
which makes it more composable. e
will ways need to be listed because generic types are the only way to have a wildcard type we can infer (‘private’ generics would be ultimately cool to make to kind of constructs).