Ifvwm
08/27/2019, 3:56 AMsealed class nEither<A,B>
data class nLeft<A,B>(val v:A): nEither<A,B>()
data class nRight<A,B>(val v:B): nEither<A,B>()
fun <A,B,C> either(f:(A)->C, g:(B)->C, v:nEither<A,B>): C{
when (v) {
is nLeft<A,B> -> return f(v.v)
is nRight<A,B> -> return g(v.v)
}
}
fun <T> id(x:T):T{
return x
}
fun main(){
val z2 = {
x:T -> x
}
either(z2,z2,nLeft<String,Any>("aha"))
}
karelpeeters
08/27/2019, 6:12 AMclass Left<A>(val left: A) : Either<A, Nothing>
Ifvwm
08/27/2019, 6:54 AMKroppeb
08/27/2019, 8:15 AMIfvwm
08/27/2019, 8:36 AMMike
08/27/2019, 11:45 AM