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

Rename std package to instances #1140

Merged
merged 3 commits into from
Jun 22, 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 bench/src/main/scala/cats/bench/FoldBench.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cats.bench

import cats.data.Const
import cats.std.string._
import cats.std.list._
import cats.instances.string._
import cats.instances.list._
import cats.{Foldable, Traverse}
import org.openjdk.jmh.annotations.{Benchmark, Scope, State}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Applicative.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cats

import cats.std.list._
import cats.instances.list._
import simulacrum.typeclass

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Foldable.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats

import scala.collection.mutable
import cats.std.long._
import cats.instances.long._
import simulacrum.typeclass

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/OneAnd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package data

import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer
import cats.std.list._
import cats.instances.list._

/**
* A data type which represents a single element (head) and some other
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
@@ -1,7 +1,7 @@
package cats
package data

import std.option.{catsStdInstancesForOption => optionInstance}
import instances.option.{catsStdInstancesForOption => optionInstance}

/**
* `OptionT[F[_], A]` is a light wrapper on an `F[Option[A]]` with some
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/WriterT.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package data

import cats.kernel.std.tuple._
import cats.kernel.instances.tuple._
import cats.functor.{Bifunctor, Contravariant}

final case class WriterT[F[_], L, V](run: F[(L, V)]) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/implicits/package.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package cats

object implicits extends syntax.AllSyntax with std.AllInstances
object implicits extends syntax.AllSyntax with instances.AllInstances
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cats
package std
package instances

trait AllInstances
extends FunctionInstances
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cats
package std
package instances

trait AnyValInstances
extends IntInstances
Expand All @@ -13,38 +13,38 @@ trait AnyValInstances
with UnitInstances
with TupleInstances

trait IntInstances extends cats.kernel.std.IntInstances {
trait IntInstances extends cats.kernel.instances.IntInstances {
implicit val catsStdShowForInt: Show[Int] = Show.fromToString[Int]
}

trait ByteInstances extends cats.kernel.std.ByteInstances {
trait ByteInstances extends cats.kernel.instances.ByteInstances {
implicit val catsStdShowForByte: Show[Byte] = Show.fromToString[Byte]
}

trait CharInstances extends cats.kernel.std.CharInstances {
trait CharInstances extends cats.kernel.instances.CharInstances {
implicit val catsStdShowForChar: Show[Char] = Show.fromToString[Char]
}

trait ShortInstances extends cats.kernel.std.ShortInstances {
trait ShortInstances extends cats.kernel.instances.ShortInstances {
implicit val catsStdShowForShort: Show[Short] = Show.fromToString[Short]
}

trait LongInstances extends cats.kernel.std.LongInstances {
trait LongInstances extends cats.kernel.instances.LongInstances {
implicit val catsStdShowForLong: Show[Long] = Show.fromToString[Long]
}

trait FloatInstances extends cats.kernel.std.FloatInstances {
trait FloatInstances extends cats.kernel.instances.FloatInstances {
implicit val catsStdShowForFloat: Show[Float] = Show.fromToString[Float]
}

trait DoubleInstances extends cats.kernel.std.DoubleInstances {
trait DoubleInstances extends cats.kernel.instances.DoubleInstances {
implicit val catsStdShowForDouble: Show[Double] = Show.fromToString[Double]
}

trait BooleanInstances extends cats.kernel.std.BooleanInstances {
trait BooleanInstances extends cats.kernel.instances.BooleanInstances {
implicit val catsStdShowForBoolean: Show[Boolean] = Show.fromToString[Boolean]
}

trait UnitInstances extends cats.kernel.std.UnitInstances {
trait UnitInstances extends cats.kernel.instances.UnitInstances {
implicit val catsStdShowForUnit: Show[Unit] = Show.fromToString[Unit]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cats
package std
package instances

trait BigDecimalInstances {
implicit val catsStdShowForBigDecimal: Show[BigDecimal] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package std
package instances

trait BigIntInstances extends cats.kernel.std.BigIntInstances {
trait BigIntInstances extends cats.kernel.instances.BigIntInstances {
implicit val catsStdShowForBigInt: Show[BigInt] =
Show.fromToString[BigInt]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cats
package std
package instances

import scala.annotation.tailrec
import cats.data.Xor
Expand Down Expand Up @@ -82,7 +82,7 @@ trait EitherInstances extends EitherInstances1 {
}
}

private[std] sealed trait EitherInstances1 extends EitherInstances2 {
private[instances] sealed trait EitherInstances1 extends EitherInstances2 {
implicit def catsStdPartialOrderForEither[A, B](implicit A: PartialOrder[A], B: PartialOrder[B]): PartialOrder[Either[A, B]] =
new PartialOrder[Either[A, B]] {
def partialCompare(x: Either[A, B], y: Either[A, B]): Double = x.fold(
Expand All @@ -92,7 +92,7 @@ private[std] sealed trait EitherInstances1 extends EitherInstances2 {
}
}

private[std] sealed trait EitherInstances2 {
private[instances] sealed trait EitherInstances2 {
implicit def catsStdEqForEither[A, B](implicit A: Eq[A], B: Eq[B]): Eq[Either[A, B]] = new Eq[Either[A, B]] {
def eqv(x: Either[A, B], y: Either[A, B]): Boolean = x.fold(
a => y.fold(A.eqv(a, _), _ => false),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cats
package std
package instances

import cats.arrow.{Arrow, Choice}
import cats.data.Xor
import cats.functor.Contravariant

private[std] sealed trait Function0Instances {
private[instances] sealed trait Function0Instances {

implicit val catsStdBimonadForFunction0: Bimonad[Function0] =
new Bimonad[Function0] {
Expand All @@ -26,7 +26,7 @@ private[std] sealed trait Function0Instances {
}
}

private[std] sealed trait Function1Instances extends Function1Instances0 {
private[instances] sealed trait Function1Instances extends Function1Instances0 {
implicit def catsStdContravariantForFunction1[R]: Contravariant[? => R] =
new Contravariant[? => R] {
def contramap[T1, T0](fa: T1 => R)(f: T0 => T1): T0 => R =
Expand Down Expand Up @@ -78,33 +78,33 @@ private[std] sealed trait Function1Instances extends Function1Instances0 {
new Function1MonoidK {}
}

private[std] sealed trait Function1Instances0 {
private[instances] sealed trait Function1Instances0 {
implicit def catsStdSemigroupForFunction1[A,B](implicit S: Semigroup[B]): Semigroup[A => B] =
new Function1Semigroup[A, B] { def B: Semigroup[B] = S }

implicit val catsStdSemigroupKForFunction1: SemigroupK[λ[α => α => α]] =
new Function1SemigroupK {}
}

private[std] sealed trait Function1Semigroup[A, B] extends Semigroup[A => B] {
private[instances] sealed trait Function1Semigroup[A, B] extends Semigroup[A => B] {
implicit def B: Semigroup[B]

override def combine(x: A => B, y: A => B): A => B = { a =>
B.combine(x(a), y(a))
}
}

private[std] sealed trait Function1Monoid[A, B] extends Monoid[A => B] with Function1Semigroup[A, B] {
private[instances] sealed trait Function1Monoid[A, B] extends Monoid[A => B] with Function1Semigroup[A, B] {
implicit def B: Monoid[B]

override def empty: A => B = _ => B.empty
}

private[std] sealed trait Function1SemigroupK extends SemigroupK[λ[α => α => α]] {
private[instances] sealed trait Function1SemigroupK extends SemigroupK[λ[α => α => α]] {
override def combineK[A](x: A => A, y: A => A): A => A = x compose y
}

private[std] sealed trait Function1MonoidK extends MonoidK[λ[α => α => α]] with Function1SemigroupK {
private[instances] sealed trait Function1MonoidK extends MonoidK[λ[α => α => α]] with Function1SemigroupK {
override def empty[A]: A => A = identity[A]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cats
package std
package instances

import cats.data.Xor

Expand Down Expand Up @@ -35,12 +35,12 @@ trait FutureInstances extends FutureInstances1 {
}
}

private[std] sealed trait FutureInstances1 extends FutureInstances2 {
private[instances] sealed trait FutureInstances1 extends FutureInstances2 {
implicit def catsStdMonoidForFuture[A: Monoid](implicit ec: ExecutionContext): Monoid[Future[A]] =
new FutureMonoid[A]
}

private[std] sealed trait FutureInstances2 {
private[instances] sealed trait FutureInstances2 {
implicit def catsStdSemigroupForFuture[A: Semigroup](implicit ec: ExecutionContext): Semigroup[Future[A]] =
new FutureSemigroup[A]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cats
package std
package instances

import cats.syntax.show._

Expand All @@ -8,7 +8,7 @@ import scala.collection.mutable.ListBuffer

import cats.data.Xor

trait ListInstances extends cats.kernel.std.ListInstances {
trait ListInstances extends cats.kernel.instances.ListInstances {

implicit val catsStdInstancesForList: Traverse[List] with MonadCombine[List] with MonadRec[List] with CoflatMap[List] =
new Traverse[List] with MonadCombine[List] with MonadRec[List] with CoflatMap[List] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package std
package instances

trait MapInstances extends cats.kernel.std.MapInstances {
trait MapInstances extends cats.kernel.instances.MapInstances {

implicit def catsStdShowForMap[A, B](implicit showA: Show[A], showB: Show[B]): Show[Map[A, B]] =
Show.show[Map[A, B]] { m =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cats
package std
package instances

import scala.annotation.tailrec
import cats.data.Xor

trait OptionInstances extends cats.kernel.std.OptionInstances {
trait OptionInstances extends cats.kernel.instances.OptionInstances {

implicit val catsStdInstancesForOption: Traverse[Option] with MonadError[Option, Unit] with MonadCombine[Option] with MonadRec[Option] with CoflatMap[Option] with Alternative[Option] =
new Traverse[Option] with MonadError[Option, Unit] with MonadCombine[Option] with MonadRec[Option] with CoflatMap[Option] with Alternative[Option] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cats

package object std {
package object instances {
object all extends AllInstances

object either extends EitherInstances
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cats
package std
package instances

import cats.syntax.show._

trait SetInstances extends cats.kernel.std.SetInstances {
trait SetInstances extends cats.kernel.instances.SetInstances {

implicit val catsStdInstancesForSet: Foldable[Set] with MonoidK[Set] =
new Foldable[Set] with MonoidK[Set] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cats
package std
package instances

import cats.syntax.show._

trait StreamInstances extends cats.kernel.std.StreamInstances {
trait StreamInstances extends cats.kernel.instances.StreamInstances {
implicit val catsStdInstancesForStream: Traverse[Stream] with MonadCombine[Stream] with CoflatMap[Stream] =
new Traverse[Stream] with MonadCombine[Stream] with CoflatMap[Stream] {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package std
package instances

trait StringInstances extends cats.kernel.std.StringInstances {
trait StringInstances extends cats.kernel.instances.StringInstances {
implicit val catsStdShowForString: Show[String] =
Show.fromToString[String]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cats
package std
package instances

import cats.data.Xor
import TryInstances.castFailure
Expand Down Expand Up @@ -106,20 +106,20 @@ trait TryInstances extends TryInstances1 {
}
}

private[std] object TryInstances {
private[instances] object TryInstances {
/**
* A `Failure` can be statically typed as `Try[A]` for all `A`, because it
* does not actually contain an `A` value (as `Success[A]` does).
*/
@inline final def castFailure[A](f: Failure[_]): Try[A] = f.asInstanceOf[Try[A]]
}

private[std] sealed trait TryInstances1 extends TryInstances2 {
private[instances] sealed trait TryInstances1 extends TryInstances2 {
implicit def catsStdMonoidForTry[A: Monoid]: Monoid[Try[A]] =
new TryMonoid[A]
}

private[std] sealed trait TryInstances2 {
private[instances] sealed trait TryInstances2 {
implicit def catsStdSemigroupForTry[A: Semigroup]: Semigroup[Try[A]] =
new TrySemigroup[A]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package std
package instances

trait TupleInstances extends Tuple2Instances with cats.kernel.std.TupleInstances
trait TupleInstances extends Tuple2Instances with cats.kernel.instances.TupleInstances

sealed trait Tuple2Instances {
implicit val catsStdBitraverseForTuple2: Bitraverse[Tuple2] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package cats
package std
package instances

import cats.syntax.show._

import scala.annotation.tailrec
import scala.collection.+:
import scala.collection.immutable.VectorBuilder

trait VectorInstances extends cats.kernel.std.VectorInstances {
trait VectorInstances extends cats.kernel.instances.VectorInstances {
implicit val catsStdInstancesForVector: Traverse[Vector] with MonadCombine[Vector] with CoflatMap[Vector] =
new Traverse[Vector] with MonadCombine[Vector] with CoflatMap[Vector] {

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ val o: Option[String] = None
o.orEmpty
```

**Note**: if you import `cats.implicits._` (the preferred method), you should _not_ also use imports like `cats.syntax.option._` or `cats.std.either._`. This can result in ambiguous implicit values that cause bewildering compile errors.
**Note**: if you import `cats.implicits._` (the preferred method), you should _not_ also use imports like `cats.syntax.option._` or `cats.instances.either._`. This can result in ambiguous implicit values that cause bewildering compile errors.

## Why can't the compiler find implicit instances for Future?<a id="future-instances" href="#future-instances"></a>

Expand Down
Loading