Created
December 25, 2019 12:55
-
-
Save happy-bracket/dbcc91e6dd6afd0fda1fd3b28360b9d5 to your computer and use it in GitHub Desktop.
EitherN, but beter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Either2<A, B> { | |
data class Op1<A>(val value: A) : Either2<A, Nothing>() | |
data class Op2<B>(val value: B) : Either2<Nothing, B>() | |
} | |
sealed class Either3<A, B, C> : Either2<A, B>() { | |
data class Op3<C>(val value: C) : Either3<Nothing, Nothing, C>() | |
} | |
sealed class Either4<A, B, C, D> : Either3<A, B, C>() { | |
data class Op4<D>(val value: D) : Either4<Nothing, Nothing, Nothing, D>() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment