Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to cast both sides of Either? #116

Open
jalvespinto opened this issue Dec 17, 2022 · 1 comment
Open

How to cast both sides of Either? #116

jalvespinto opened this issue Dec 17, 2022 · 1 comment

Comments

@jalvespinto
Copy link

I am trying to have Either<Failure, Concrete> where Concrete extends Abstract class, but I cannot get it to work. If I try to cast the left side I get the error:

type 'Right<Failure, Concrete>' is not a subtype of type 'Either<Failure, Abstract>' in type cast

if I try for the right side I get:

type 'Left<Object, Concrete>' is not a subtype of type 'Either<Failure, Concrete>' in type cast

And bimap does not seems to solve it. Is there an easy way to do it? tks

@sachinmaharjan182
Copy link

@jalvespinto got same problem like yours. In my case i am returning value as Right(value). when i changed my code to below . it worked.
Before
return Right(User())
After
return Right<Failure,User>(User());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants