Skip to content

Instantly share code, notes, and snippets.

@smarter
Created July 5, 2018 19:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save smarter/adaf7eb812cb4e8065dd77d67a0a2aea to your computer and use it in GitHub Desktop.
Save smarter/adaf7eb812cb4e8065dd77d67a0a2aea 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