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

Add more scalastyle rules #1142

Merged
merged 8 commits into from
Jun 24, 2016
Merged
Show file tree
Hide file tree
Changes from 6 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/Applicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import simulacrum.typeclass
ap(pure(f))(fa)

/**
* Given `fa` and `n`, apply `fa` `n` times to construct an `F[List[A]]` value.
*/
* Given `fa` and `n`, apply `fa` `n` times to construct an `F[List[A]]` value.
*/
def replicateA[A](n: Int, fa: F[A]): F[List[A]] =
sequence(List.fill(n)(fa))

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Apply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import simulacrum.typeclass
*
* Must obey the laws defined in cats.laws.ApplyLaws.
*/
@typeclass(excludeParents=List("ApplyArityFunctions"))
@typeclass(excludeParents = List("ApplyArityFunctions"))
trait Apply[F[_]] extends Functor[F] with Cartesian[F] with ApplyArityFunctions[F] { self =>

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Bitraverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object Bitraverse {
private[cats] trait ComposedBitraverse[F[_, _], G[_, _]]
extends Bitraverse[λ[(α, β) => F[G[α, β], G[α, β]]]]
with ComposedBifoldable[F, G]
with ComposedBifunctor[F,G] {
with ComposedBifunctor[F, G] {
def F: Bitraverse[F]
def G: Bitraverse[G]

Expand Down
70 changes: 35 additions & 35 deletions core/src/main/scala/cats/CoflatMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@ package cats
import simulacrum.typeclass

/**
* `CoflatMap` is the dual of `FlatMap`.
*
* Must obey the laws in cats.laws.CoflatMapLaws
*/
* `CoflatMap` is the dual of `FlatMap`.
*
* Must obey the laws in cats.laws.CoflatMapLaws
*/
@typeclass trait CoflatMap[F[_]] extends Functor[F] {

/**
* `coflatMap` is the dual of `flatMap` on `FlatMap`. It applies
* a value in a Monadic context to a function that takes a value
* in a context and returns a normal value.
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> import cats.Monad
* scala> import cats.CoflatMap
* scala> val fa = Monad[Option].pure(3)
* scala> def f(a: Option[Int]): Int = a match {
* | case Some(x) => 2 * x
* | case None => 0 }
* scala> CoflatMap[Option].coflatMap(fa)(f)
* res0: Option[Int] = Some(6)
* }}}
*/
* `coflatMap` is the dual of `flatMap` on `FlatMap`. It applies
* a value in a Monadic context to a function that takes a value
* in a context and returns a normal value.
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> import cats.Monad
* scala> import cats.CoflatMap
* scala> val fa = Monad[Option].pure(3)
* scala> def f(a: Option[Int]): Int = a match {
* | case Some(x) => 2 * x
* | case None => 0 }
* scala> CoflatMap[Option].coflatMap(fa)(f)
* res0: Option[Int] = Some(6)
* }}}
*/
def coflatMap[A, B](fa: F[A])(f: F[A] => B): F[B]

/**
* `coflatten` is the dual of `flatten` on `FlatMap`. Whereas flatten removes
* a layer of `F`, coflatten adds a layer of `F`
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> import cats.Monad
* scala> import cats.CoflatMap
* scala> val fa = Monad[Option].pure(3)
* fa: Option[Int] = Some(3)
* scala> CoflatMap[Option].coflatten(fa)
* res0: Option[Option[Int]] = Some(Some(3))
* }}}
*/
* `coflatten` is the dual of `flatten` on `FlatMap`. Whereas flatten removes
* a layer of `F`, coflatten adds a layer of `F`
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> import cats.Monad
* scala> import cats.CoflatMap
* scala> val fa = Monad[Option].pure(3)
* fa: Option[Int] = Some(3)
* scala> CoflatMap[Option].coflatten(fa)
* res0: Option[Option[Int]] = Some(Some(3))
* }}}
*/
def coflatten[A](fa: F[A]): F[F[A]] =
coflatMap(fa)(fa => fa)
}
38 changes: 19 additions & 19 deletions core/src/main/scala/cats/Comonad.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import simulacrum.typeclass


/**
* Comonad
*
* Comonad is the dual of Monad. Whereas Monads allow for the composition of effectful functions,
* Comonads allow for composition of functions that extract the value from their context.
*
* Must obey the laws defined in cats.laws.ComonadLaws.
*/
* Comonad
*
* Comonad is the dual of Monad. Whereas Monads allow for the composition of effectful functions,
* Comonads allow for composition of functions that extract the value from their context.
*
* Must obey the laws defined in cats.laws.ComonadLaws.
*/
@typeclass trait Comonad[F[_]] extends CoflatMap[F] {

/**
* `extract` is the dual of `pure` on Monad (via `Applicative`)
* and extracts the value from its context
*
* Example:
* {{{
* scala> import cats.Id
* scala> import cats.Comonad
* scala> val id: Id[Int] = 3
* scala> Comonad[Id].extract(id)
* res0: cats.Id[Int] = 3
* }}}
*/
* `extract` is the dual of `pure` on Monad (via `Applicative`)
* and extracts the value from its context
*
* Example:
* {{{
* scala> import cats.Id
* scala> import cats.Comonad
* scala> val id: Id[Int] = 3
* scala> Comonad[Id].extract(id)
* res0: cats.Id[Int] = 3
* }}}
*/
def extract[A](x: F[A]): A
}
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/MonadError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package cats
trait MonadError[F[_], E] extends ApplicativeError[F, E] with Monad[F] {

/**
* Turns a successful value into an error if it does not satisfy a given predicate.
*/
* Turns a successful value into an error if it does not satisfy a given predicate.
*/
def ensure[A](fa: F[A])(error: => E)(predicate: A => Boolean): F[A] =
flatMap(fa)(a => if (predicate(a)) pure(a) else raiseError(error))

Expand Down
30 changes: 15 additions & 15 deletions core/src/main/scala/cats/MonadState.scala
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package cats

/** A monad that can read, update, and pass along state (e.g. `StateT`).
*
* A common use case for `MonadState` is for syntax, especially when
* dealing with large monad transformer stacks. For instance:
*
* {{{
* val M = MonadState[StateT[List, Int, ?], Int]
* import M._
*
* for {
* g <- get
* _ <- set(g + 1)
* r <- inspect(_ * 100)
* } yield r
* }}}
*/
*
* A common use case for `MonadState` is for syntax, especially when
* dealing with large monad transformer stacks. For instance:
*
* {{{
* val M = MonadState[StateT[List, Int, ?], Int]
* import M._
*
* for {
* g <- get
* _ <- set(g + 1)
* r <- inspect(_ * 100)
* } yield r
* }}}
*/
trait MonadState[F[_], S] extends Monad[F] {
def get: F[S]

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/SemigroupK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import simulacrum.typeclass
/**
* Combine two F[A] values.
*/
@simulacrum.op("<+>", alias=true)
@simulacrum.op("<+>", alias = true)
def combineK[A](x: F[A], y: F[A]): F[A]

/**
Expand Down
Loading