Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uber import in docs. (#1026) #1104

Merged
merged 1 commit into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/CoflatMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import simulacrum.typeclass
*
* Example:
* {{{
* scala> import cats.std.option._
* scala> import cats.implicits._
* scala> import cats.Monad
* scala> import cats.CoflatMap
* scala> val fa = Monad[Option].pure(3)
Expand All @@ -35,7 +35,7 @@ import simulacrum.typeclass
*
* Example:
* {{{
* scala> import cats.std.option._
* scala> import cats.implicits._
* scala> import cats.Monad
* scala> import cats.CoflatMap
* scala> val fa = Monad[Option].pure(3)
Expand Down
12 changes: 5 additions & 7 deletions core/src/main/scala/cats/Foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ import simulacrum.typeclass
*
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.list._
* scala> import cats.std.option._
* scala> import cats.implicits._
* scala> def parseInt(s: String): Option[Int] = Xor.catchOnly[NumberFormatException](s.toInt).toOption
* scala> val F = Foldable[List]
* scala> F.traverse_(List("333", "444"))(parseInt)
Expand All @@ -118,7 +117,7 @@ import simulacrum.typeclass
*
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.list._
* scala> import cats.implicits._
* scala> def parseInt(s: String): Xor[String, Int] =
* | try { Xor.Right(s.toInt) }
* | catch { case _: NumberFormatException => Xor.Left("boo") }
Expand All @@ -145,8 +144,7 @@ import simulacrum.typeclass
* For example:
*
* {{{
* scala> import cats.std.list._
* scala> import cats.std.option._
* scala> import cats.implicits._
* scala> val F = Foldable[List]
* scala> F.sequence_(List(Option(1), Option(2), Option(3)))
* res0: Option[Unit] = Some(())
Expand All @@ -164,7 +162,7 @@ import simulacrum.typeclass
*
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.list._
* scala> import cats.implicits._
* scala> val F = Foldable[List]
* scala> F.sequenceU_(List(Xor.right[String, Int](333), Xor.Right(444)))
* res0: Xor[String, Unit] = Right(())
Expand All @@ -188,7 +186,7 @@ import simulacrum.typeclass
* For example:
*
* {{{
* scala> import cats.std.list._
* scala> import cats.implicits._
* scala> val F = Foldable[List]
* scala> F.foldK(List(1 :: 2 :: Nil, 3 :: 4 :: 5 :: Nil))
* res0: List[Int] = List(1, 2, 3, 4, 5)
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/cats/arrow/Arrow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait Arrow[F[_, _]] extends Split[F] with Strong[F] with Category[F] { self =>
*
* Example:
* {{{
* scala> import cats.std.function._
* scala> import cats.implicits._
* scala> import cats.arrow.Arrow
* scala> val fab: Double => Double = x => x + 0.3
* scala> val f: Int => Double = x => x.toDouble / 2
Expand All @@ -34,7 +34,7 @@ trait Arrow[F[_, _]] extends Split[F] with Strong[F] with Category[F] { self =>
*
* Example:
* {{{
* scala> import cats.std.function._
* scala> import cats.implicits._
* scala> import cats.arrow.Arrow
* scala> val f: Int => Int = _ * 2
* scala> val fab = Arrow[Function1].first[Int,Int,Int](f)
Expand All @@ -49,7 +49,7 @@ trait Arrow[F[_, _]] extends Split[F] with Strong[F] with Category[F] { self =>
*
* Example:
* {{{
* scala> import cats.std.function._
* scala> import cats.implicits._
* scala> import cats.arrow.Arrow
* scala> val f: Int => Int = _ * 2
* scala> val fab = Arrow[Function1].second[Int,Int,Int](f)
Expand All @@ -68,7 +68,7 @@ trait Arrow[F[_, _]] extends Split[F] with Strong[F] with Category[F] { self =>
*
* Example:
* {{{
* scala> import cats.std.function._
* scala> import cats.implicits._
* scala> import cats.arrow.Arrow
* scala> val toLong: Int => Long = _.toLong
* scala> val toDouble: Float => Double = _.toDouble
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/arrow/Choice.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait Choice[F[_, _]] extends Category[F] {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.function._
* scala> import cats.implicits._
* scala> val b: Boolean => String = _ + " is a boolean"
* scala> val i: Int => String = _ + " is an integer"
* scala> val f: (Boolean Xor Int) => String = Choice[Function1].choice(b, i)
Expand All @@ -34,7 +34,7 @@ trait Choice[F[_, _]] extends Category[F] {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.function._
* scala> import cats.implicits._
* scala> val f: (Int Xor Int) => Int = Choice[Function1].codiagonal[Int]
*
* scala> f(Xor.right(3))
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object OptionT extends OptionTInstances {
* Note: The return type is a FromOptionPartiallyApplied[F], which has an apply method
* on it, allowing you to call fromOption like this:
* {{{
* scala> import cats.std.list._
* scala> import cats.implicits._
* scala> val o: Option[Int] = Some(2)
* scala> OptionT.fromOption[List](o)
* res0: OptionT[List, Int] = OptionT(List(Some(2)))
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/StateT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ final class StateT[F[_], S, A](val runF: F[S => F[(S, A)]]) extends Serializable
* global state containing the various states needed for each individual `StateT`.
*
* {{{
* scala> import cats.std.option._ // needed for StateT.apply
* scala> import cats.implicits._ // needed for StateT.apply
* scala> type GlobalEnv = (Int, String)
* scala> val x: StateT[Option, Int, Double] = StateT((x: Int) => Option((x + 1, x.toDouble)))
* scala> val xt: StateT[Option, GlobalEnv, Double] = x.transformS[GlobalEnv](_._1, (t, i) => (i, t._2))
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/scala/cats/data/XorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ final case class XorT[F[_], A, B](value: F[A Xor B]) {
*
* Example:
* {{{
* scala> import cats.std.option._
* scala> import cats.std.list._
* scala> import cats.syntax.cartesian._
* scala> import cats.implicits._
* scala> type Error = String
* scala> val v1: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList("error 1"))
* scala> val v2: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList("error 2"))
Expand Down Expand Up @@ -192,7 +190,7 @@ trait XorTFunctions {
* Note: The return type is a FromXorPartiallyApplied[F], which has an apply method
* on it, allowing you to call fromXor like this:
* {{{
* scala> import cats.std.option._
* scala> import cats.implicits._
* scala> val t: Xor[String, Int] = Xor.right(3)
* scala> XorT.fromXor[Option](t)
* res0: XorT[Option, String, Int] = XorT(Some(Right(3)))
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/syntax/coproduct.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class CoproductOps[F[_], A](val fa: F[A]) extends AnyVal {
* {{{
* scala> import cats.data.Coproduct
* scala> import cats.Eval
* scala> import cats.syntax.coproduct._
* scala> import cats.implicits._
* scala> List(1, 2, 3).leftc[Eval]
* res0: Coproduct[List, Eval, Int] = Coproduct(Left(List(1, 2, 3)))
* }}}
Expand All @@ -34,7 +34,7 @@ final class CoproductOps[F[_], A](val fa: F[A]) extends AnyVal {
* {{{
* scala> import cats.data.Coproduct
* scala> import cats.Eval
* scala> import cats.syntax.coproduct._
* scala> import cats.implicits._
* scala> List(1, 2, 3).rightc[Eval]
* res0: Coproduct[Eval, List, Int] = Coproduct(Right(List(1, 2, 3)))
* }}}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class EitherOps[A, B](val eab: Either[A, B]) extends AnyVal {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.syntax.either._
* scala> import cats.implicits._
*
* scala> val i: Either[String, Int] = Right(3)
* scala> i.toXor
Expand Down
10 changes: 4 additions & 6 deletions core/src/main/scala/cats/syntax/flatMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ final class FlatMapOps[F[_], A](fa: F[A])(implicit F: FlatMap[F]) {
*
* Example:
* {{{
* scala> import cats.std.list._
* scala> import cats.syntax.flatMap._
* scala> import cats.implicits._
* scala> List("12", "34", "56").mproduct(_.toList)
* res0: List[(String, Char)] = List((12,1), (12,2), (34,3), (34,4), (56,5), (56,6))
* }}}
Expand All @@ -48,8 +47,7 @@ final class FlatMapOps[F[_], A](fa: F[A])(implicit F: FlatMap[F]) {
*
* {{{
* scala> import cats.Eval
* scala> import cats.std.option._
* scala> import cats.syntax.flatMap._
* scala> import cats.implicits._
* scala> val fa: Option[Int] = Some(3)
* scala> def fb: Option[String] = Some("foo")
* scala> fa.followedByEval(Eval.later(fb))
Expand All @@ -68,7 +66,7 @@ final class FlattenOps[F[_], A](ffa: F[F[A]])(implicit F: FlatMap[F]) {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.syntax.flatMap._
* scala> import cats.implicits._
* scala> type ErrorOr[A] = String Xor A
* scala> val x: ErrorOr[ErrorOr[Int]] = Xor.right(Xor.right(3))
* scala> x.flatten
Expand All @@ -86,7 +84,7 @@ final class IfMOps[F[_]](fa: F[Boolean])(implicit F: FlatMap[F]) {
* Example:
* {{{
* scala> import cats.{Eval, Now}
* scala> import cats.syntax.flatMap._
* scala> import cats.implicits._
*
* scala> val b1: Eval[Boolean] = Now(true)
* scala> val asInt1: Eval[Int] = b1.ifM(Now(1), Now(0))
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/scala/cats/syntax/foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ final class NestedFoldableOps[F[_], G[_], A](fga: F[G[A]])(implicit F: Foldable[
*
* Example:
* {{{
* scala> import cats.std.list._
* scala> import cats.std.set._
* scala> import cats.syntax.foldable._
* scala> import cats.implicits._
*
* scala> val l: List[Set[Int]] = List(Set(1, 2), Set(2, 3), Set(3, 4))
* scala> l.foldK
Expand Down
7 changes: 2 additions & 5 deletions core/src/main/scala/cats/syntax/monadCombine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ final class MonadCombineOps[F[_], G[_], A](fga: F[G[A]])(implicit F: MonadCombin
*
* Example:
* {{{
* scala> import cats.std.list._
* scala> import cats.std.vector._
* scala> import cats.syntax.monadCombine._
* scala> import cats.implicits._
* scala> val x: List[Vector[Int]] = List(Vector(1, 2), Vector(3, 4))
* scala> x.unite
* res0: List[Int] = List(1, 2, 3, 4)
Expand All @@ -36,8 +34,7 @@ final class SeparateOps[F[_], G[_, _], A, B](fgab: F[G[A, B]])(implicit F: Monad
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.list._
* scala> import cats.syntax.monadCombine._
* scala> import cats.implicits._
* scala> val l: List[Xor[String, Int]] = List(Xor.right(1), Xor.left("error"))
* scala> l.separate
* res0: (List[String], List[Int]) = (List(error),List(1))
Expand Down
17 changes: 8 additions & 9 deletions core/src/main/scala/cats/syntax/option.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class OptionIdOps[A](val a: A) extends AnyVal {
*
* Example:
* {{{
* scala> import cats.syntax.option._
* scala> import cats.implicits._
* scala> 3.some
* res0: Option[Int] = Some(3)
* }}}
Expand All @@ -35,7 +35,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.syntax.option._
* scala> import cats.implicits._
*
* scala> val error1: Option[String] = Some("error!")
* scala> error1.toLeftXor(3)
Expand All @@ -56,7 +56,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.syntax.option._
* scala> import cats.implicits._
*
* scala> val result1: Option[Int] = Some(3)
* scala> result1.toRightXor("error!")
Expand All @@ -77,7 +77,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal {
* Example:
* {{{
* scala> import cats.data.Validated
* scala> import cats.syntax.option._
* scala> import cats.implicits._
*
* scala> val error1: Option[String] = Some("error!")
* scala> error1.toInvalid(3)
Expand All @@ -99,7 +99,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal {
* Example:
* {{{
* scala> import cats.data.ValidatedNel
* scala> import cats.syntax.option._
* scala> import cats.implicits._
*
* scala> val error1: Option[String] = Some("error!")
* scala> error1.toInvalidNel(3)
Expand All @@ -120,7 +120,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal {
* Example:
* {{{
* scala> import cats.data.Validated
* scala> import cats.syntax.option._
* scala> import cats.implicits._
*
* scala> val result1: Option[Int] = Some(3)
* scala> result1.toValid("error!")
Expand All @@ -141,7 +141,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal {
* Example:
* {{{
* scala> import cats.data.ValidatedNel
* scala> import cats.syntax.option._
* scala> import cats.implicits._
*
* scala> val result1: Option[Int] = Some(3)
* scala> result1.toValidNel("error!")
Expand All @@ -160,8 +160,7 @@ final class OptionOps[A](val oa: Option[A]) extends AnyVal {
*
* Example:
* {{{
* scala> import cats.syntax.option._
* scala> import cats.std.string._
* scala> import cats.implicits._
*
* scala> val someString: Option[String] = Some("hello")
* scala> someString.orEmpty
Expand Down
18 changes: 5 additions & 13 deletions core/src/main/scala/cats/syntax/traverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ final class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.list._
* scala> import cats.std.option._
* scala> import cats.syntax.traverse._
* scala> import cats.implicits._
* scala> def parseInt(s: String): Option[Int] = Xor.catchOnly[NumberFormatException](s.toInt).toOption
* scala> List("1", "2", "3").traverse(parseInt)
* res0: Option[List[Int]] = Some(List(1, 2, 3))
Expand All @@ -41,8 +39,7 @@ final class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.list._
* scala> import cats.syntax.traverse._
* scala> import cats.implicits._
* scala> def parseInt(s: String): Xor[String, Int] = Xor.catchOnly[NumberFormatException](s.toInt).leftMap(_ => "no number")
* scala> val ns = List("1", "2", "3")
* scala> ns.traverseU(parseInt)
Expand All @@ -60,9 +57,7 @@ final class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {
* Example:
* {{{
* scala> import cats.data.Xor
* scala> import cats.std.list._
* scala> import cats.std.option._
* scala> import cats.syntax.traverse._
* scala> import cats.implicits._
* scala> def parseInt(s: String): Option[Int] = Xor.catchOnly[NumberFormatException](s.toInt).toOption
* scala> val x = Option(List("1", "two", "3"))
* scala> x.traverseM(_.map(parseInt))
Expand All @@ -77,9 +72,7 @@ final class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {
*
* Example:
* {{{
* scala> import cats.std.list._
* scala> import cats.std.option._
* scala> import cats.syntax.traverse._
* scala> import cats.implicits._
* scala> val x: List[Option[Int]] = List(Some(1), Some(2))
* scala> val y: List[Option[Int]] = List(None, Some(2))
* scala> x.sequence
Expand All @@ -97,8 +90,7 @@ final class TraverseOps[F[_], A](fa: F[A])(implicit F: Traverse[F]) {
* Example:
* {{{
* scala> import cats.data.{Validated, ValidatedNel}
* scala> import cats.std.list._
* scala> import cats.syntax.traverse._
* scala> import cats.implicits._
* scala> val x: List[ValidatedNel[String, Int]] = List(Validated.valid(1), Validated.invalid("a"), Validated.invalid("b")).map(_.toValidatedNel)
* scala> x.sequenceU
* res0: cats.data.ValidatedNel[String,List[Int]] = Invalid(OneAnd(a,List(b)))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/applicative.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ obvious. For `Option`, the `pure` operation wraps the value in

```tut:book
import cats._
import cats.std.all._
import cats.implicits._

Applicative[Option].pure(1)
Applicative[List].pure(1)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ In order to use it, first import `cats.syntax.all._` or `cats.syntax.cartesian._
Here we see that the following two functions, `f1` and `f2`, are equivalent:

```tut:book
import cats.syntax.cartesian._
import cats.implicits._

def f1(a: Option[Int], b: Option[Int], c: Option[Int]) =
(a |@| b |@| c) map { _ * _ * _ }
Expand Down
Loading