-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `.nested` syntax. * Add test for new `.nested` syntax. * Fix binary compatibility issue. * Change mixin in SyntaxSuite.
- Loading branch information
1 parent
9af5186
commit 6353e99
Showing
4 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters