Skip to content

Commit

Permalink
Unfold single-line comments
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Jun 18, 2020
1 parent 0dc267c commit 0a3da31
Show file tree
Hide file tree
Showing 38 changed files with 225 additions and 114 deletions.
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ rewrite.rules = [AvoidInfix, SortImports, RedundantParens, SortModifiers]
docstrings = JavaDoc
newlines.afterCurlyLambda = preserve
docstrings.style = Asterisk
docstrings.oneline = unfold
15 changes: 10 additions & 5 deletions core/src/main/scala/cats/Apply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,33 @@ trait Apply[F[_]] extends Functor[F] with InvariantSemigroupal[F] with ApplyArit
ap(map(fa)(a => (b: B) => (a, b)))(fb)

/**
* Alias for [[ap]]. */
* Alias for [[ap]].
*/
@inline final def <*>[A, B](ff: F[A => B])(fa: F[A]): F[B] =
ap(ff)(fa)

/**
* Alias for [[productR]]. */
* Alias for [[productR]].
*/
@inline final def *>[A, B](fa: F[A])(fb: F[B]): F[B] =
productR(fa)(fb)

/**
* Alias for [[productL]]. */
* Alias for [[productL]].
*/
@inline final def <*[A, B](fa: F[A])(fb: F[B]): F[A] =
productL(fa)(fb)

/**
* Alias for [[productR]]. */
* Alias for [[productR]].
*/
@deprecated("Use *> or productR instead.", "1.0.0-RC2")
@noop @inline final private[cats] def followedBy[A, B](fa: F[A])(fb: F[B]): F[B] =
productR(fa)(fb)

/**
* Alias for [[productL]]. */
* Alias for [[productL]].
*/
@deprecated("Use <* or productL instead.", "1.0.0-RC2")
@noop @inline final private[cats] def forEffect[A, B](fa: F[A])(fb: F[B]): F[A] =
productL(fa)(fb)
Expand Down
9 changes: 6 additions & 3 deletions core/src/main/scala/cats/Bifoldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import scala.annotation.implicitNotFound
@typeclass trait Bifoldable[F[_, _]] extends Serializable { self =>

/**
* Collapse the structure with a left-associative function */
* Collapse the structure with a left-associative function
*/
def bifoldLeft[A, B, C](fab: F[A, B], c: C)(f: (C, A) => C, g: (C, B) => C): C

/**
* Collapse the structure with a right-associative function */
* Collapse the structure with a right-associative function
*/
def bifoldRight[A, B, C](fab: F[A, B], c: Eval[C])(f: (A, Eval[C]) => Eval[C], g: (B, Eval[C]) => Eval[C]): Eval[C]

/**
* Collapse the structure by mapping each element to an element of a type that has a [[cats.Monoid]] */
* Collapse the structure by mapping each element to an element of a type that has a [[cats.Monoid]]
*/
def bifoldMap[A, B, C](fab: F[A, B])(f: A => C, g: B => C)(implicit C: Monoid[C]): C =
bifoldLeft(fab, C.empty)(
(c: C, a: A) => C.combine(c, f(a)),
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/Bifunctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import scala.annotation.implicitNotFound
def leftMap[A, B, C](fab: F[A, B])(f: A => C): F[C, B] = bimap(fab)(f, identity)

/**
* The composition of two Bifunctors is itself a Bifunctor */
* The composition of two Bifunctors is itself a Bifunctor
*/
def compose[G[_, _]](implicit G0: Bifunctor[G]): Bifunctor[λ[(α, β) => F[G[α, β], G[α, β]]]] =
new ComposedBifunctor[F, G] {
val F = self
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/scala/cats/Bitraverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import simulacrum.{noop, typeclass}
import scala.annotation.implicitNotFound

/**
* A type class abstracting over types that give rise to two independent [[cats.Traverse]]s.
* A type class abstracting over types that give rise to two independent [[cats.Traverse]]s.
*/
@implicitNotFound("Could not find an instance of Bitraverse for ${F}")
@typeclass trait Bitraverse[F[_, _]] extends Bifoldable[F] with Bifunctor[F] { self =>
Expand Down Expand Up @@ -55,7 +55,8 @@ import scala.annotation.implicitNotFound
bitraverse(fab)(identity, identity)

/**
* If F and G are both [[cats.Bitraverse]] then so is their composition F[G[_, _], G[_, _]] */
* If F and G are both [[cats.Bitraverse]] then so is their composition F[G[_, _], G[_, _]]
*/
def compose[G[_, _]](implicit ev: Bitraverse[G]): Bitraverse[λ[(α, β) => F[G[α, β], G[α, β]]]] =
new ComposedBitraverse[F, G] {
val F = self
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Reducible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import scala.annotation.implicitNotFound
def reduceLeftTo[A, B](fa: F[A])(f: A => B)(g: (B, A) => B): B

/**
* Monadic variant of [[reduceLeftTo]].
* Monadic variant of [[reduceLeftTo]].
*/
def reduceLeftM[G[_], A, B](fa: F[A])(f: A => G[B])(g: (B, A) => G[B])(implicit G: FlatMap[G]): G[B] =
reduceLeftTo(fa)(f)((gb, a) => G.flatMap(gb)(g(_, a)))
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/Show.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ object Show extends ScalaVersionSpecificShowInstances with ShowInstances {
}

/**
* creates an instance of [[Show]] using the provided function */
* creates an instance of [[Show]] using the provided function
*/
def show[A](f: A => String): Show[A] =
new Show[A] {
def show(a: A): String = f(a)
}

/**
* creates an instance of [[Show]] using object toString */
* creates an instance of [[Show]] using object toString
*/
def fromToString[A]: Show[A] =
new Show[A] {
def show(a: A): String = a.toString
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/data/AndThen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ sealed abstract class AndThen[-T, +R] extends (T => R) with Product with Seriali
object AndThen extends AndThenInstances0 {

/**
* Builds an [[AndThen]] reference by wrapping a plain function. */
* Builds an [[AndThen]] reference by wrapping a plain function.
*/
def apply[A, B](f: A => B): AndThen[A, B] =
f match {
case ref: AndThen[A, B] @unchecked => ref
Expand Down
15 changes: 10 additions & 5 deletions core/src/main/scala/cats/data/Chain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -596,31 +596,36 @@ object Chain extends ChainInstances {
}

/**
* Empty Chain. */
* Empty Chain.
*/
val nil: Chain[Nothing] = Empty

def empty[A]: Chain[A] = nil

/**
* Creates a Chain of 1 element. */
* Creates a Chain of 1 element.
*/
def one[A](a: A): Chain[A] = Singleton(a)

/**
* Concatenates two Chains. */
* Concatenates two Chains.
*/
def concat[A](c: Chain[A], c2: Chain[A]): Chain[A] =
if (c.isEmpty) c2
else if (c2.isEmpty) c
else Append(c, c2)

/**
* Creates a Chain from the specified sequence. */
* Creates a Chain from the specified sequence.
*/
def fromSeq[A](s: Seq[A]): Chain[A] =
if (s.isEmpty) nil
else if (s.lengthCompare(1) == 0) one(s.head)
else Wrap(s)

/**
* Creates a Chain from the specified elements. */
* Creates a Chain from the specified elements.
*/
def apply[A](as: A*): Chain[A] =
fromSeq(as)

Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/ContT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ object ContT {
}

/**
* Lift a pure value into `ContT` */
* Lift a pure value into `ContT`
*/
def pure[M[_], A, B](b: B): ContT[M, A, B] =
apply { cb =>
cb(b)
Expand Down Expand Up @@ -154,7 +155,8 @@ object ContT {
FromFn(AndThen(fn))

/**
* Similar to [[apply]] but evaluation of the argument is deferred. */
* Similar to [[apply]] but evaluation of the argument is deferred.
*/
def later[M[_], A, B](fn: => (B => M[A]) => M[A]): ContT[M, A, B] =
DeferCont(() => FromFn(AndThen(fn)))

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,8 @@ object EitherT extends EitherTInstances {
)

/**
* Similar to `fromOptionF` but the left is carried from monadic `F[_]` context when the option is `None` */
* Similar to `fromOptionF` but the left is carried from monadic `F[_]` context when the option is `None`
*/
final def fromOptionM[F[_], E, A](fopt: F[Option[A]], ifNone: => F[E])(implicit F: Monad[F]): EitherT[F, E, A] =
EitherT(
F.flatMap(fopt) {
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/Func.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ sealed abstract class Func[F[_], A, B] { self =>
object Func extends FuncInstances {

/**
* function `A => F[B]`. */
* function `A => F[B]`.
*/
def func[F[_], A, B](run0: A => F[B]): Func[F, A, B] =
new Func[F, A, B] {
def run: A => F[B] = run0
}

/**
* applicative function. */
* applicative function.
*/
def appFunc[F[_], A, B](run0: A => F[B])(implicit FF: Applicative[F]): AppFunc[F, A, B] =
new AppFunc[F, A, B] {
def F: Applicative[F] = FF
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/data/IorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ object IorT extends IorTInstances {
IorT(F.map(foption)(_.fold[Ior[E, A]](Ior.left(ifNone))(Ior.right)))

/**
* Similar to `fromOptionF` but the left is carried from monadic `F[_]` context when the option is `None` */
* Similar to `fromOptionF` but the left is carried from monadic `F[_]` context when the option is `None`
*/
final def fromOptionM[F[_], E, A](foption: F[Option[A]], ifNone: => F[E])(implicit F: Monad[F]): IorT[F, E, A] =
IorT(
F.flatMap(foption) {
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ final case class Kleisli[F[_], -A, B](run: A => F[B]) { self =>
Kleisli { case (c, a) => F.map(run(a))(c -> _) }

/**
* Discard computed B and yield the input value. */
* Discard computed B and yield the input value.
*/
def tap[AA <: A](implicit F: Functor[F]): Kleisli[F, AA, AA] =
Kleisli(a => F.as(run(a), a))

/**
* Yield computed B combined with input value. */
* Yield computed B combined with input value.
*/
def tapWith[C, AA <: A](f: (AA, B) => C)(implicit F: Functor[F]): Kleisli[F, AA, C] =
Kleisli(a => F.map(run(a))(b => f(a, b)))

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/data/NonEmptyChain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ class NonEmptyChainOps[A](private val value: NonEmptyChain[A])
final def reverseIterator: Iterator[A] = toChain.reverseIterator

/**
* Reverses this `NonEmptyChain` */
* Reverses this `NonEmptyChain`
*/
final def reverse: NonEmptyChain[A] =
create(toChain.reverse)

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) extends NonEmptyCollec
def length: Int = size

/**
* Applies f to all the elements of the structure
* Applies f to all the elements of the structure
*/
def map[B](f: A => B): NonEmptyList[B] =
NonEmptyList(f(head), tail.map(f))
Expand Down
11 changes: 7 additions & 4 deletions core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A])
with NonEmptyCollection[A, Vector, NonEmptyVector] {

/**
* Gets the element at the index, if it exists */
* Gets the element at the index, if it exists
*/
def get(i: Int): Option[A] =
toVector.lift(i)

/**
* Gets the element at the index, or throws an exception if none exists */
* Gets the element at the index, or throws an exception if none exists
*/
def getUnsafe(i: Int): A = toVector(i)

/**
* Updates the element at the index, if it exists */
* Updates the element at the index, if it exists
*/
def updated[AA >: A](i: Int, a: AA): Option[NonEmptyVector[AA]] =
if (toVector.isDefinedAt(i)) Some(new NonEmptyVector(toVector.updated(i, a))) else None

Expand Down Expand Up @@ -162,7 +165,7 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A])
new NonEmptyVector(toVector.map(f))

/**
* Applies f to all elements and combines the result
* Applies f to all elements and combines the result
*/
def flatMap[B](f: A => NonEmptyVector[B]): NonEmptyVector[B] =
new NonEmptyVector(toVector.flatMap(a => f(a).toVector))
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ package object cats {
type = Any

/**
* [[cats.InjectK]][F, G] */
* [[cats.InjectK]][F, G]
*/
type :<:[F[_], G[_]] = InjectK[F, G]

/**
* [[cats.InjectK]][F, G] */
* [[cats.InjectK]][F, G]
*/
type :≺:[F[_], G[_]] = InjectK[F, G]

/**
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/syntax/apply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ final class IfApplyOps[F[_]](private val fcond: F[Boolean]) extends AnyVal {
final class ApplyOps[F[_], A](private val fa: F[A]) extends AnyVal {

/**
* Alias for [[Apply.productR]]. */
* Alias for [[Apply.productR]].
*/
@deprecated("Use *> or productR instead.", "1.0.0-RC2")
@inline private[syntax] def followedBy[B](fb: F[B])(implicit F: Apply[F]): F[B] =
F.productR(fa)(fb)

/**
* Alias for [[Apply.productL]]. */
* Alias for [[Apply.productL]].
*/
@deprecated("Use <* or productL instead.", "1.0.0-RC2")
@inline private[syntax] def forEffect[B](fb: F[B])(implicit F: Apply[F]): F[A] =
F.productL(fa)(fb)
Expand Down
18 changes: 12 additions & 6 deletions core/src/main/scala/cats/syntax/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -391,32 +391,37 @@ final class EitherObjectOps(private val either: Either.type) extends AnyVal { //
}

/**
* Cached value of `Right(())` to avoid allocations for a common case. */
* Cached value of `Right(())` to avoid allocations for a common case.
*/
def unit[A]: Either[A, Unit] = EitherUtil.unit
}

final class LeftOps[A, B](private val left: Left[A, B]) extends AnyVal {

/**
* Cast the right type parameter of the `Left`. */
* Cast the right type parameter of the `Left`.
*/
def rightCast[C]: Either[A, C] = left.asInstanceOf[Either[A, C]]
}

final class RightOps[A, B](private val right: Right[A, B]) extends AnyVal {

/**
* Cast the left type parameter of the `Right`. */
* Cast the left type parameter of the `Right`.
*/
def leftCast[C]: Either[C, B] = right.asInstanceOf[Either[C, B]]
}

final class EitherIdOps[A](private val obj: A) extends AnyVal {

/**
* Wrap a value in `Left`. */
* Wrap a value in `Left`.
*/
def asLeft[B]: Either[A, B] = Left(obj)

/**
* Wrap a value in `Right`. */
* Wrap a value in `Right`.
*/
def asRight[B]: Either[B, A] = Right(obj)

/**
Expand Down Expand Up @@ -493,7 +498,8 @@ final private[syntax] class EitherOpsBinCompat0[A, B](private val value: Either[
}

/**
* Convenience methods to use `Either` syntax inside `Either` syntax definitions. */
* Convenience methods to use `Either` syntax inside `Either` syntax definitions.
*/
private[cats] object EitherUtil {
def leftCast[A, B, C](right: Right[A, B]): Either[C, B] =
right.asInstanceOf[Either[C, B]]
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/syntax/eq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ package syntax
trait EqSyntax {

/**
* not final so it can be disabled in favor of scalactic equality in tests */
* not final so it can be disabled in favor of scalactic equality in tests
*/
implicit def catsSyntaxEq[A: Eq](a: A): EqOps[A] =
new EqOps[A](a)
}
Expand Down
Loading

0 comments on commit 0a3da31

Please sign in to comment.