Skip to content

Instantly share code, notes, and snippets.

@barambani
Forked from smarter/fs2.scala
Created October 14, 2018 23:17
Show Gist options
  • Save barambani/29c8bf74680b87ee7668eb702c2ff812 to your computer and use it in GitHub Desktop.
Save barambani/29c8bf74680b87ee7668eb702c2ff812 to your computer and use it in GitHub Desktop.
trait Stream[+F[_], +A]
object Stream {
// Make scalac get over its oudenophobia.
type Nothing2[X] <: Nothing
def emits[F[x] >: Nothing2[x], A](as: List[A]): Stream[F, A] = new Stream[F, A] {}
implicit class InvariantOps[F[x] >: Nothing2[x], A](private val self: Stream[F, A]) extends AnyVal {
def ethrough[B](p: Stream[F, A] => Stream[F, B]): Stream[F, B] = p(self)
}
}
object Test {
val a = Stream.emits(List(1)).ethrough(identity)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment