Hello, I have a question about kotlin, not arrow, ...
# arrow
z
Hello, I have a question about kotlin, not arrow, but I think this might be a good place to ask anyways. The question is, how do you build a simple sum-type in kotlin? I have tried sealed classes, but I have hit a wall in this situation: I wanted to do something like type S = A | B | C. So i did like so:
Copy code
sealed class S {}
data class A: S() {}
data class B: S() {}
data class C: S() {}
But then I have a Decoder<T> type, which is defined like so:
Copy code
interface State<A, S> {
    val runState: (s: S) -> Pair<A, S>
}
typealias Decoder<A> = State<A, ByteArrayBuffer>
Then I created Decoder<A>, Decoder<B> and Decoder<C>. And I wanted to use a when expression to create Decoder<S>. But the compiler complains that I am returning A instead of S in the Decoder<S> definition. Any ideas what to do?