and they all remain compatible with Either
# arrow
p
and they all remain compatible with Either
d
Thank you, my intent is to have some kind of “sealed safety”, like what we can have with `sealed class`es like
Copy code
sealed class Result {
  object Success : Result()
  object Failure : Result()
}

sealed NetworkError {
  object Success : NetworkResult()
  object NoNetwork : NetworkResult()
}
but with some kind of ereditariety
p
yes, that SomeError is a sealed class, and so is NetworkError
“Success” is the right side of every Either
and you only have to fill the left side with errors
and for that you create the sealed class hierarchy I’ve suggested
d
But there are 2 problems there :) 1) can't extend the sealed in another file 2) if LoginError extend NetworkError, WrongCredentials is a network error, so it must be covered in a
when (NetworkError)
, but viceversa a LoginError cannot be a NetworkError.NoNetwork
I think I have to do
Copy code
sealed class LoginError {
    object WrongCredentials : LoginError() 
    class Network(
        val reason: NetworkError
    ) : LoginError() 
}
Either is a good solution though
d

https://www.youtube.com/watch?v=OuCVkBSBwBA&t=1038s

minute 17
abstract class FeatureFailure
and he’s spanish so he must know about functional programming in kotlin
😂 1
d
Looks interesting, thank you! I'll try to play with it