Skip to content
Permalink
Browse files

Merge branch 'series/1.0' into pr/ChristopherDavenport/1438

  • Loading branch information...
mpilquist committed May 4, 2019
2 parents 672b16c + a286e3c commit 634ed8be56ea43ac3354a4806ff3703f442ebfc8
@@ -2,7 +2,7 @@ language: scala

scala:
- 2.11.12
- 2.13.0-M5
- 2.13.0-RC1
- 2.12.7

jdk:
@@ -28,7 +28,7 @@ script:
- sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -Dfs2.test.verbose testJVM
- sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -Dfs2.test.verbose testJS
- sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 doc mimaReportBinaryIssues
- (test $TRAVIS_SCALA_VERSION == "2.11.12" && sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -J-Xms2g -J-Xmx2g docs/tut) || test $TRAVIS_SCALA_VERSION == "2.12.7" || test $TRAVIS_SCALA_VERSION == "2.13.0-M5"
- (test $TRAVIS_SCALA_VERSION == "2.11.12" && sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -J-Xms2g -J-Xmx2g docs/tut) || test $TRAVIS_SCALA_VERSION == "2.12.7" || test $TRAVIS_SCALA_VERSION == "2.13.0-RC1"

after_success:
- test $PUBLISH == "true" && test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "series/1.0" && GPG_WARN_ON_FAILURE=true sbt +publish
@@ -136,6 +136,7 @@ If you have a project you'd like to include in this list, either open a PR or le
* [fs2-cron](https://github.com/fthomas/fs2-cron): FS2 streams based on cron expressions.
* [fs2-crypto](https://github.com/Spinoco/fs2-crypto): TLS support for fs2.
* [fs2-elastic](https://github.com/amarrella/fs2-elastic): Simple client for Elasticsearch.
* [fs2-google-pubsub](https://github.com/permutive/fs2-google-pubsub): A [Google Cloud Pub/Sub](https://cloud.google.com/pubsub/) implementation using fs2 and cats-effect.
* [fs2-grpc](https://github.com/fiadliel/fs2-grpc): gRPC implementation for FS2 / Cats Effect.
* [fs2-http](https://github.com/Spinoco/fs2-http): Http server and client library implemented in fs2.
* [fs2-jms](https://github.com/kiambogo/fs2-jms): JMS connectors for FS2 streams
@@ -48,13 +48,12 @@ lazy val commonSettings = Seq(
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
javaOptions in (Test, run) ++= Seq("-Xms64m", "-Xmx64m"),
libraryDependencies ++= Seq(
compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.9"),
"org.typelevel" %%% "cats-core" % "1.6.0",
"org.typelevel" %%% "cats-laws" % "1.6.0" % "test",
"org.typelevel" %%% "cats-effect" % "1.2.0",
"org.typelevel" %%% "cats-effect-laws" % "1.2.0" % "test",
"org.scala-lang.modules" %%% "scala-collection-compat" % "0.3.0",
"org.scalatest" %%% "scalatest" % "3.0.6" % "test"
compilerPlugin("org.typelevel" %% "kind-projector" % "0.10.0"),
"org.typelevel" %%% "cats-core" % "2.0.0-M1",
"org.typelevel" %%% "cats-laws" % "2.0.0-M1" % "test",
"org.typelevel" %%% "cats-effect" % "2.0.0-M1",
"org.typelevel" %%% "cats-effect-laws" % "2.0.0-M1" % "test",
"org.scalatest" %%% "scalatest" % "3.0.8-RC2" % "test"
),
libraryDependencies += {
CrossVersion.partialVersion(scalaVersion.value) match {
@@ -230,7 +229,13 @@ lazy val mimaSettings = Seq(
ProblemFilters.exclude[IncompatibleMethTypeProblem]("fs2.Stream#Compiler.apply"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("fs2.Stream#Compiler.apply"),
// bracketWithToken was private[fs2]
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.bracketWithToken")
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.bracketWithToken"),
//forStrategy/NoneTerminated were private[fs2]
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.concurrent.Queue.forStrategy"),
ProblemFilters.exclude[DirectMissingMethodProblem](
"fs2.concurrent.Queue.forStrategyNoneTerminated"),
ProblemFilters.exclude[DirectMissingMethodProblem](
"fs2.concurrent.InspectableQueue.forStrategy")
)
)

@@ -260,7 +265,7 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
}
baseDirectory.value / "../shared/src/main" / dir
},
libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.9"
libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.10"
)
.jsSettings(commonJsSettings: _*)

@@ -4,7 +4,7 @@ import java.util.concurrent.atomic.AtomicLong

import org.scalacheck.Gen
import cats.effect.IO
import cats.implicits.{catsSyntaxEither _, _}
import cats.implicits.{catsSyntaxEither => _, _}

import scala.concurrent.duration._
import TestUtil._
@@ -63,8 +63,8 @@ class StreamSpec extends Fs2Spec with Inside {
val stream: Stream[IO, Int] = Stream.fromEither[IO](either)

either match {
case Left(_) stream.compile.toList.attempt.unsafeRunSync() shouldBe either
case Right(_) stream.compile.toList.unsafeRunSync() shouldBe either.toList
case Left(_) => stream.compile.toList.attempt.unsafeRunSync() shouldBe either
case Right(_) => stream.compile.toList.unsafeRunSync() shouldBe either.toList
}
}

@@ -0,0 +1,12 @@
package fs2

import scala.collection.generic.CanBuildFrom
import scala.collection.mutable.Builder

package object internal {
private[fs2] type Factory[-A, +C] = CanBuildFrom[Nothing, A, C]

private[fs2] implicit class FactoryOps[-A, +C](private val factory: Factory[A, C]) {
def newBuilder: Builder[A, C] = factory()
}
}
@@ -0,0 +1,5 @@
package fs2

package object internal {
private[fs2] type Factory[-A, +C] = scala.collection.Factory[A, C]
}
@@ -1,6 +1,7 @@
package fs2

import cats._
import cats.arrow.FunctionK
import cats.effect._
import fs2.internal._

@@ -253,15 +254,27 @@ object Pull extends PullLowPriority {
.syncInstance[Algebra[F, O, ?]]
.bracketCase(acquire.get)(a => use(a).get)((a, c) => release(a, c).get))
}

/**
* `FunctionK` instance for `F ~> Pull[F, INothing, ?]`
*
* @example {{{
* scala> import cats.Id
* scala> Pull.functionKInstance[Id](42).flatMap(Pull.output1).stream.compile.toList
* res0: cats.Id[List[Int]] = List(42)
* }}}
*/
implicit def functionKInstance[F[_]]: F ~> Pull[F, INothing, ?] =
FunctionK.lift[F, Pull[F, INothing, ?]](Pull.eval)
}

private[fs2] trait PullLowPriority {
implicit def monadInstance[F[_], O]: Monad[Pull[F, O, ?]] =
new Monad[Pull[F, O, ?]] {
override def pure[A](a: A): Pull[F, O, A] = Pull.pure(a)
override def flatMap[A, B](p: Pull[F, O, A])(f: A Pull[F, O, B]): Pull[F, O, B] =
override def flatMap[A, B](p: Pull[F, O, A])(f: A => Pull[F, O, B]): Pull[F, O, B] =
p.flatMap(f)
override def tailRecM[A, B](a: A)(f: A Pull[F, O, Either[A, B]]): Pull[F, O, B] =
override def tailRecM[A, B](a: A)(f: A => Pull[F, O, Either[A, B]]): Pull[F, O, B] =
f(a).flatMap {
case Left(a) => tailRecM(a)(f)
case Right(b) => Pull.pure(b)
@@ -1,6 +1,7 @@
package fs2

import cats._
import cats.arrow.FunctionK
import cats.data.{Chain, NonEmptyList}
import cats.effect._
import cats.effect.concurrent._
@@ -11,7 +12,6 @@ import fs2.internal.FreeC.Result
import fs2.internal.{Resource => _, _}
import java.io.PrintStream

import scala.collection.compat._
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._

@@ -3025,9 +3025,11 @@ object Stream extends StreamLowPriority {
* }}}
*/
def emits[F[x] >: Pure[x], O](os: Seq[O]): Stream[F, O] =
if (os.isEmpty) empty
else if (os.size == 1) emit(os.head)
else fromFreeC(Algebra.output[F, O](Chunk.seq(os)))
os match {
case Nil => empty
case Seq(x) => emit(x)
case _ => fromFreeC(Algebra.output[F, O](Chunk.seq(os)))
}

/** Empty pure stream. */
val empty: Stream[Pure, INothing] =
@@ -4376,6 +4378,18 @@ object Stream extends StreamLowPriority {
}
}

/**
* `FunctionK` instance for `F ~> Stream[F, ?]`
*
* @example {{{
* scala> import cats.Id
* scala> Stream.functionKInstance[Id](42).compile.toList
* res0: cats.Id[List[Int]] = List(42)
* }}}
*/
implicit def functionKInstance[F[_]]: F ~> Stream[F, ?] =
FunctionK.lift[F, Stream[F, ?]](Stream.eval)

implicit def monoidKInstance[F[_]]: MonoidK[Stream[F, ?]] =
new MonoidK[Stream[F, ?]] {
def empty[A]: Stream[F, A] = Stream.empty
@@ -4388,10 +4402,10 @@ private[fs2] trait StreamLowPriority {
new Monad[Stream[F, ?]] {
override def pure[A](x: A): Stream[F, A] = Stream(x)

override def flatMap[A, B](fa: Stream[F, A])(f: A Stream[F, B]): Stream[F, B] =
override def flatMap[A, B](fa: Stream[F, A])(f: A => Stream[F, B]): Stream[F, B] =
fa.flatMap(f)

override def tailRecM[A, B](a: A)(f: A Stream[F, Either[A, B]]): Stream[F, B] =
override def tailRecM[A, B](a: A)(f: A => Stream[F, Either[A, B]]): Stream[F, B] =
f(a).flatMap {
case Left(a) => tailRecM(a)(f)
case Right(b) => Stream(b)
Oops, something went wrong.

0 comments on commit 634ed8b

Please sign in to comment.
You can’t perform that action at this time.