Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type inference regression in scalaz: #8290

Closed
scabug opened this issue Feb 15, 2014 · 5 comments

Comments

@scabug
Copy link

commented Feb 15, 2014

Regressed in the last few days. I'm minimizing.

[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:34: no type parameters for method @>>>: (g: scalaz.typelevel.Func[G,scalaz.Applicative,Int,C])scalaz.typelevel.Func[[α]scalaz.IndexedStateT[[+X]X,Boolean,Boolean,G[α]],scalaz.Applicative,Char,C] exist so that it can be applied to arguments (scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Int,Int])
[info] [error]  --- because ---
[info] [error] argument expression's type is not compatible with formal parameter type;
[info] [error]  found   : scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Int,Int]
[info] [error]  required: scalaz.typelevel.Func[?G,scalaz.Applicative,Int,?C]
[info] [error]     } @>>> AppFuncU { (x: Int) => x }
[info] [error]       ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:34: type mismatch;
[info] [error]  found   : scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Int,Int]
[info] [error]  required: scalaz.typelevel.Func[G,scalaz.Applicative,Int,C]
[info] [error]     } @>>> AppFuncU { (x: Int) => x }
[info] [error]                     ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:37: inferred type arguments [scalaz.typelevel.HNilFunc[scalaz.Applicative,Char,Int]] do not conform to method consA's type parameter bounds [T <: scalaz.typelevel.HListFunc[scalaz.Applicative,Char,C]]
[info] [error]     val countAll = countChar :: countLine :: (countWord consA AppFunc.HNil[Char, Int])
[info] [error]                                                         ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:37: type mismatch;
[info] [error]  found   : scalaz.typelevel.HNilFunc[scalaz.Applicative,Char,Int]
[info] [error]  required: T
[info] [error]     val countAll = countChar :: countLine :: (countWord consA AppFunc.HNil[Char, Int])
[info] [error]                                                                           ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:40: recursive value x$4 needs type
[info] [error]     val charCount :: lineCount ::  wordCountState :: HNil = countAll traverse text
[info] [error]  
@scabug

This comment has been minimized.

Copy link
Author

commented Feb 15, 2014

@scabug

This comment has been minimized.

Copy link
Author

commented Feb 15, 2014

@retronym said:
/cc adriaan: dbuild caught another one

@scabug

This comment has been minimized.

Copy link
Author

commented Feb 15, 2014

@retronym said:
Behaviour changed at #7753 / c0edf768912

@scabug

This comment has been minimized.

Copy link
Author

commented Feb 15, 2014

@retronym said:
Diff of -Xprint:typer of WordCount.scala: https://gist.github.com/retronym/9024155

@scabug

This comment has been minimized.

Copy link
Author

commented Feb 15, 2014

@retronym said:
Not sure if we can do much about this.

We are inferring an equivalent type here:

-      val countChar: scalaz.typelevel.Func[scalaz.Unapply[scalaz.Applicative,Int]{type M[X] = Int; type A = Int}#M,scalaz.Applicative,Char,Int] = scalaz.typelevel.AppFuncU.apply[Char, Int](((c: Char) => 1))(scalaz.this.Unapply.unapplyA[scalaz.Applicative, Int](scalaz.this.Applicative.monoidApplicative[Int](scalaz.std.anyVal.intInstance)));
+      val countChar: scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Char,Int] = scalaz.typelevel.AppFuncU.apply[Char, Int](((c: Char) => 1))(scalaz.this.Unapply.unapplyA[scalaz.Applicative, Int](scalaz.this.Applicative.monoidApplicative[Int](scalaz.std.anyVal.intInstance)));

But later one, we're unable to unify the PolyType [X]Int with the HKTypeVar ?G

res1 = {scala.reflect.internal.Types$ClassNoArgsTypeRef@3182}"Int"
res2 = {scala.reflect.internal.Types$AppliedTypeVar@3322}"?G[_]"
substitutes = {scala.collection.immutable.$colon$colon@3329}"::" size = 1
tp1 = {scala.reflect.internal.Types$PolyType@3169}"[X]Int"
tp2 = {scala.reflect.internal.Types$PolyType@3316}"[_]?G[_]"
tparams1 = {scala.collection.immutable.$colon$colon@3181}"::" size = 1
(0)  = {scala.reflect.internal.Symbols$AbstractTypeSymbol@3207}"type X"
tparams2 = {scala.collection.immutable.$colon$colon@3190}"::" size = 1
(0)  = {scala.reflect.internal.Symbols$AbstractTypeSymbol@3194}"type _"
      (tparams1 corresponds tparams2)(cmp) && (sub1(res1) <:< sub2(res2))
Int <:< ?G[X]
-----------------------
this = {scala.reflect.internal.Types$ClassNoArgsTypeRef@3182}"Int"
scala.reflect.internal.tpe.TypeComparers$class.cmp$1(scala.reflect.internal.SymbolTable, scala.reflect.internal.Symbols$Symbol, scala.reflect.internal.Symbols$Symbol, scala.collection.immutable.List, scala.collection.immutable.List, boolean, scala.collection.immutable.List) = true
that = {scala.reflect.internal.Types$AppliedTypeVar@3364}"?G[X]"

Which hits #2712.

@scabug scabug closed this Feb 15, 2014

@scabug scabug added this to the 2.11.0-RC1 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.