Skip to content

Instantly share code, notes, and snippets.

@jimmydivvy
Created May 25, 2018 08:51
Show Gist options
  • Save jimmydivvy/6b563fa4aa39796284eef17742575230 to your computer and use it in GitHub Desktop.
Save jimmydivvy/6b563fa4aa39796284eef17742575230 to your computer and use it in GitHub Desktop.
object ExistentialTest {
case class Box[T]()
case class Pair[T](a: Box[T], b: Box[T])
val pair: Pair[_] = ???
val pair2 = Pair(pair.a, pair.b)
}
@AndreasKostler
Copy link

AndreasKostler commented May 25, 2018

    object ExistentialTest {

    case class Box[T]()

    case class Pair[F[x] <: Box[x], T](a: F[T], b: F[T]) {
      type Inner = T
    }


    val pair = Pair(Box[Int], Box[Int])

    val pair2 = Pair(pair.a, pair.b)

  }

@AndreasKostler
Copy link

object ExistentialTest {
    import scala.language.existentials


    case class Box[T](value: T)
    case class Pair(a: Box[T] forSome { type T } , b: Box[T]  forSome { type T } ) {
    }

    val pair: Pair = Pair(Box[Int](42), Box[Int](42))

    val pair2 = Pair(pair.a, pair.b)

  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment