Skip to content

Instantly share code, notes, and snippets.

@tonymorris

tonymorris/WTH.scala

Last active Dec 11, 2015
Embed
What would you like to do?
What The Hell Scala?
case class Cont[F[+_], +A] extends Free[F, A]
sealed trait Free[F[+_], +A]
case class FreeM[I, +A](free: Free[({type f[+x] = Map[I, x]})#f, A]) {
def run = {
free match {
case Cont() =>
error("")
}
}
}
/*
$ scalac X.scala
WTH.scala:7: error: constructor cannot be instantiated to expected type;
found : Cont[F,A(in class Cont)]
required: Free[[+x]scala.collection.immutable.Map[I,x],A(in class FreeM)]
case Cont(e) =>
^
one error found
*/
@Sciss

This comment has been minimized.

Copy link

@Sciss Sciss commented Jan 13, 2013

// more reduced
sealed trait Foo[F[+_]]
case class Bar[F[+_]]() extends Foo[F]

def works[F[+_]](f: Foo[F]) {
  f match {
    case Bar() => ???
  }
}

def fails[I](f: Foo[({type F[+x] = Map[I, x]})#F]) {
  f match {
    case Bar() => ???
  }
}
@retronym

This comment has been minimized.

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