Skip to content

Missing Factory instance for scala.Stream (2.12) #183

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

Closed
djspiewak opened this issue Feb 13, 2019 · 5 comments
Closed

Missing Factory instance for scala.Stream (2.12) #183

djspiewak opened this issue Feb 13, 2019 · 5 comments

Comments

@djspiewak
Copy link

Not entirely sure if this is the right place for this; I could file it under fs2, as well. Either way, it appears that there is no instance Factory[A, Stream[A]], which in turn causes some source compatibility issues in packages (such as fs2) which have migrated to collection-compat.

No, I don't make any excuses for the use of scala.Stream. Legacy code. Uggghhhh.

Anyway, is this omission intentional?

@djspiewak
Copy link
Author

djspiewak commented Feb 14, 2019

After a bit of hunting, it appears this may be a type inference issue somewhere. Stream[_] (the existential, not the type constructor) is not being considered compatible with Nothing for the purposes of locating a CanBuildFrom which can satisfy Factory's alias.

@julienrf
Copy link
Contributor

julienrf commented Feb 18, 2019

Anyway, is this omission intentional?

No, it’s not.

Stream[_] (the existential, not the type constructor) is not being considered compatible with Nothing for the purposes of locating a CanBuildFrom which can satisfy Factory's alias.

Then that should be the case with all other collection types? They all define an implicit [A]CanBuildFrom[Coll, A, CC[A]], where Coll = CC[_], and CC is the collection type constructor (e.g., List).

@djspiewak
Copy link
Author

That's what I would have suspected. I really have no idea what's special about Stream. I'll see if I can come up with a better minimization. Right now, my minimizer is using it via the to function on fs2.CompileOps.

@szeiger
Copy link
Contributor

szeiger commented Apr 4, 2019

I cannot reproduce this. In the 2.12.2 REPL:

scala> import scala.collection.generic.CanBuildFrom
import scala.collection.generic.CanBuildFrom

scala> type Factory[-A, +C] = CanBuildFrom[Nothing, A, C] // same as in collection-compat
defined type alias Factory

scala> def f[A] = implicitly[Factory[A, Stream[A]]]
f: [A]=> Factory[A,Stream[A]]

scala> f[Int]
res6: Factory[Int,Stream[Int]] = scala.collection.immutable.Stream$StreamCanBuildFrom@45790cb

@szeiger
Copy link
Contributor

szeiger commented Apr 5, 2019

Probably a duplicate of #137 (which I cannot reproduce in the REPL, either)

szeiger added a commit to szeiger/scala-collection-compat that referenced this issue Apr 5, 2019
I don’t know what changed since these tickets were opened but both
cases work fine now.
SethTisue added a commit that referenced this issue Apr 5, 2019
martijnhoekstra pushed a commit to martijnhoekstra/scala-collection-compat that referenced this issue Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants