Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/main/scala/cats/syntax/all.scala
  • Loading branch information
Avasil committed May 22, 2018
2 parents fe718ed + 6353e99 commit 71c483c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ lazy val docSettings = Seq(
includeFilter in Jekyll := (includeFilter in makeSite).value
)

lazy val binaryCompatibleVersion = "1.0.0"
lazy val binaryCompatibleVersions = Set("1.0.0", "1.1.0")

def mimaSettings(moduleName: String) = Seq(
mimaPreviousArtifacts := Set("org.typelevel" %% moduleName % binaryCompatibleVersion)
mimaPreviousArtifacts := binaryCompatibleVersions.map(v => "org.typelevel" %% moduleName % v)
)

lazy val docs = project
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/scala/cats/syntax/all.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ trait AllSyntaxBinCompat0
with ApplicativeErrorExtension
with TrySyntax

trait AllSyntaxBinCompat1 extends FlatMapOptionSyntax with ParallelFlatSyntax
trait AllSyntaxBinCompat1
extends FlatMapOptionSyntax
with NestedSyntax
with ParallelFlatSyntax
27 changes: 27 additions & 0 deletions core/src/main/scala/cats/syntax/nested.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cats
package syntax

import cats.data.Nested

trait NestedSyntax {
implicit final def catsSyntaxNestedId[F[_], G[_], A](value: F[G[A]]): NestedIdOps[F, G, A] =
new NestedIdOps[F, G, A](value)
}

final class NestedIdOps[F[_], G[_], A](val value: F[G[A]]) extends AnyVal {
/**
* Wrap a value in `Nested`.
*
* `x.nested` is equivalent to `Nested(x)`.
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> List(Some(3), None).nested.map(_+1).value
* res0: List[Option[Int]] = List(Some(4), None)
* }}}
*/
def nested: Nested[F, G, A] = Nested[F, G, A](value)
}


1 change: 1 addition & 0 deletions core/src/main/scala/cats/syntax/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ package object syntax {
object monad extends MonadSyntax
object monadError extends MonadErrorSyntax
object monoid extends MonoidSyntax
object nested extends NestedSyntax
object option extends OptionSyntax
object order extends OrderSyntax
object parallel extends ParallelSyntax
Expand Down
7 changes: 7 additions & 0 deletions tests/src/test/scala/cats/tests/SyntaxSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cats
package tests

import cats.arrow.Compose
import cats.data.Nested
import cats.instances.AllInstances
import cats.syntax.{AllSyntax, AllSyntaxBinCompat1}

Expand Down Expand Up @@ -347,5 +348,11 @@ object SyntaxSuite extends AllInstances with AllSyntax with AllSyntaxBinCompat1
val gea4 = ga.recoverWith(pfegea)
}

def testNested[F[_], G[_], A]: Unit = {
val fga: F[G[A]] = mock[F[G[A]]]

val nested: Nested[F, G, A] = fga.nested
}

}

0 comments on commit 71c483c

Please sign in to comment.