prat
02/17/2018, 3:58 AMEither
instance for Hash
. it's type checked at the compile time but i got java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
when I test laws. any pointer? how can i debug this?prat
02/17/2018, 4:01 AM@instance(Either::class)
interface EitherHashInstance<L, R> : EitherEqInstance<L, R>, Hash<Either<L, R>> {
override fun EQL(): Eq<L>
override fun EQR(): Eq<R>
fun HSL(): Hash<L>
fun HSR(): Hash<R>
override fun hash(a: Either<L, R>): Int = when (a) {
is Either.Left -> HSL().hash(a.a).hashCode()
is Either.Right -> HSR().hash(a.b).hashCode()
}
}