Last active
August 29, 2015 13:56
-
-
Save travisbrown/8893312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._, Scalaz._ | |
trait Baz extends Foo { | |
def r = List(1).liftM[T] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.10.3" | |
libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.0.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._, Scalaz._ | |
trait Foo { | |
type T[M[_], A] = ReaderT[M, String, A] | |
} | |
trait Bar extends Foo { | |
def r = List(1).liftM[T] | |
} |
This has progressed in 2.11, somewhere between: scala/scala@185ff4c...d068b16
% scalac-hash d068b16 -classpath /Users/jason/code/gist/8893312/target/scala-2.11.0-M5/classes:/Users/jason/.ivy2/cache/org.scalaz/scalaz-core_2.11.0-M8/bundles/scalaz-core_2.11.0-M8-7.0.5.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11.0-M8/bundles/scala-parser-combinators_2.11.0-M8-1.0.0-RC5.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11.0-M8/bundles/scala-xml_2.11.0-M8-1.0.0-RC7.jar /Users/jason/code/gist/8893312/baz.scala /Users/jason/code/gist/8893312/foo.scala
/Users/jason/code/gist/8893312/foo.scala:4: error: kinds of the type arguments (M,String,A) do not conform to the expected kinds of the type parameters (type F,type E,type A).
M's type parameters do not match type F's expected parameters:
type _ is invariant, but type _ is declared covariant
type T[M[_], A] = ReaderT[M, String, A]
^
one error found
% subl foo.scala
% git diff
diff --git a/foo.scala b/foo.scala
index e6e1838..c082847 100644
--- a/foo.scala
+++ b/foo.scala
@@ -1,7 +1,7 @@
import scalaz._, Scalaz._
trait Foo {
- type T[M[_], A] = ReaderT[M, String, A]
+ type T[M[+_], A] = ReaderT[M, String, A]
}
trait Bar extends Foo {
% scalac-hash d068b16 -classpath /Users/jason/code/gist/8893312/target/scala-2.11.0-M5/classes:/Users/jason/.ivy2/cache/org.scalaz/scalaz-core_2.11.0-M8/bundles/scalaz-core_2.11.0-M8-7.0.5.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11.0-M8/bundles/scala-parser-combinators_2.11.0-M8-1.0.0-RC5.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11.0-M8/bundles/scala-xml_2.11.0-M8-1.0.0-RC7.jar /Users/jason/code/gist/8893312/baz.scala /Users/jason/code/gist/8893312/foo.scala
warning: there were 1 feature warning(s); re-run with -feature for details
one warning found
With the older compiler (even with the required variance annotation on M
):
% scalac-hash 185ff4c -classpath /Users/jason/code/gist/8893312/target/scala-2.11.0-M5/classes:/Users/jason/.ivy2/cache/org.scalaz/scalaz-core_2.11.0-M8/bundles/scalaz-core_2.11.0-M8-7.0.5.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11.0-M8/bundles/scala-parser-combinators_2.11.0-M8-1.0.0-RC5.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11.0-M8/bundles/scala-xml_2.11.0-M8-1.0.0-RC7.jar /Users/jason/code/gist/8893312/baz.scala /Users/jason/code/gist/8893312/foo.scala
/Users/jason/code/gist/8893312/baz.scala:4: error: kinds of the type arguments (Baz.this.T) do not conform to the expected kinds of the type parameters (type G).
Baz.this.T's type parameters do not match type G's expected parameters:
<none>'s bounds<notype> are stricter than type _'s declared bounds >: Nothing <: Any
def r = List(1).liftM[T]
^
one error found
It progressed in https://issues.scala-lang.org/browse/SI-7902 / scala/scala@03a06e0.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bar
is fine, butBaz
crashes with the following error: