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

Remove Group #279

Merged
merged 1 commit into from Feb 15, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 0 additions & 37 deletions core/src/main/scala/scalaz/Group.scala

This file was deleted.

8 changes: 0 additions & 8 deletions core/src/main/scala/scalaz/Isomorphism.scala
Expand Up @@ -130,14 +130,6 @@ trait IsomorphismMonoid[F, G] extends Monoid[F] with IsomorphismSemigroup[F, G]
def zero: F = iso.from(G.zero)
}

trait IsomorphismGroup[F, G] extends Group[F] with IsomorphismMonoid[F, G] {
implicit def G: Group[G]

def iso: F <=> G

def inverse(f: F): F = iso.from(G.inverse(iso.to(f)))
}

trait IsomorphismEqual[F, G] extends Equal[F] {
implicit def G: Equal[G]

Expand Down
57 changes: 7 additions & 50 deletions core/src/main/scala/scalaz/LazyTuple.scala
Expand Up @@ -81,7 +81,7 @@ trait LazyTupleFunctions {
}
}

trait LazyTuple2Instances1 {
trait LazyTuple2Instances0 {
implicit def lazyTuple2Instance[A1, A2] = new Bitraverse[LazyTuple2] {
override def bimap[A, B, C, D](fab: LazyTuple2[A, B])(f: (A) => C, g: (B) => D): LazyTuple2[C, D] = LazyTuple.lazyTuple2(f(fab._1), g(fab._2))
def bitraverseImpl[G[_]: Applicative, A, B, C, D](fab: LazyTuple2[A, B])(f: (A) => G[C], g: (B) => G[D]): G[LazyTuple2[C, D]] = {
Expand All @@ -96,7 +96,8 @@ trait LazyTuple2Instances1 {

implicit def lazyTuple2Functor[A1]: Functor[({type f[x] = LazyTuple2[A1, x]})#f] = new LazyTuple2Functor[A1] {}
}
trait LazyTuple2Instances0 extends LazyTuple2Instances1 {

trait LazyTuple2Instances extends LazyTuple2Instances0 {

implicit def lazyTuple2Show[A1, A2](implicit A1: Show[A1], A2: Show[A2]) = new LazyTuple2Show[A1, A2] {
implicit def _1 = A1
Expand All @@ -118,14 +119,7 @@ trait LazyTuple2Instances0 extends LazyTuple2Instances1 {
}
}

trait LazyTuple2Instances extends LazyTuple2Instances0 {
implicit def lazyTuple2Group[A1, A2](implicit A1: Group[A1], A2: Group[A2]) = new LazyTuple2Group[A1, A2] {
implicit def _1 = A1
implicit def _2 = A2
}
}

trait LazyTuple3Instances1 {
trait LazyTuple3Instances0 {
implicit def lazyTuple3Semigroup[A1, A2, A3](implicit A1: Semigroup[A1], A2: Semigroup[A2], A3: Semigroup[A3]) = new LazyTuple3Semigroup[A1, A2, A3] {
implicit def _1 = A1
implicit def _2 = A2
Expand All @@ -140,7 +134,7 @@ trait LazyTuple3Instances1 {
implicit def _3 = A3
}
}
trait LazyTuple3Instances0 extends LazyTuple3Instances1 {
trait LazyTuple3Instances extends LazyTuple3Instances0 {

implicit def lazyTuple3Show[A1, A2, A3](implicit A1: Show[A1], A2: Show[A2], A3: Show[A3]) = new LazyTuple3Show[A1, A2, A3] {
implicit def _1 = A1
Expand All @@ -166,15 +160,7 @@ trait LazyTuple3Instances0 extends LazyTuple3Instances1 {
}
}

trait LazyTuple3Instances extends LazyTuple3Instances0 {
implicit def lazyTuple3Group[A1, A2, A3](implicit A1: Group[A1], A2: Group[A2], A3: Group[A3]) = new LazyTuple3Group[A1, A2, A3] {
implicit def _1 = A1
implicit def _2 = A2
implicit def _3 = A3
}
}

trait LazyTuple4Instances1 {
trait LazyTuple4Instances0 {
implicit def lazyTuple4Semigroup[A1, A2, A3, A4](implicit A1: Semigroup[A1], A2: Semigroup[A2], A3: Semigroup[A3], A4: Semigroup[A4]) = new LazyTuple4Semigroup[A1, A2, A3, A4] {
implicit def _1 = A1
implicit def _2 = A2
Expand All @@ -191,7 +177,7 @@ trait LazyTuple4Instances1 {
implicit def _4 = A4
}
}
trait LazyTuple4Instances0 extends LazyTuple4Instances1 {
trait LazyTuple4Instances extends LazyTuple4Instances0 {

implicit def lazyTuple4Show[A1, A2, A3, A4](implicit A1: Show[A1], A2: Show[A2], A3: Show[A3], A4: Show[A4]) = new LazyTuple4Show[A1, A2, A3, A4] {
implicit def _1 = A1
Expand Down Expand Up @@ -221,15 +207,6 @@ trait LazyTuple4Instances0 extends LazyTuple4Instances1 {
}
}

trait LazyTuple4Instances extends LazyTuple4Instances0 {
implicit def lazyTuple4Group[A1, A2, A3, A4](implicit A1: Group[A1], A2: Group[A2], A3: Group[A3], A4: Group[A4]) = new LazyTuple4Group[A1, A2, A3, A4] {
implicit def _1 = A1
implicit def _2 = A2
implicit def _3 = A3
implicit def _4 = A4
}
}

////

private[scalaz] trait LazyTuple2Functor[A1] extends Functor[({type f[x] = LazyTuple2[A1, x]})#f] {
Expand Down Expand Up @@ -379,26 +356,6 @@ private[scalaz] trait LazyTuple4Monoid[A1, A2, A3, A4] extends Monoid[LazyTuple4
def zero: LazyTuple4[A1, A2, A3, A4] = LazyTuple4(_1.zero, _2.zero, _3.zero, _4.zero)
}

private[scalaz] trait LazyTuple2Group[A1, A2] extends Group[LazyTuple2[A1, A2]] with LazyTuple2Monoid[A1, A2] {
implicit def _1 : Group[A1]
implicit def _2 : Group[A2]
def inverse(f: LazyTuple2[A1, A2]) = LazyTuple2(_1.inverse(f._1), _2.inverse(f._2))
}
private[scalaz] trait LazyTuple3Group[A1, A2, A3] extends Group[LazyTuple3[A1, A2, A3]] with LazyTuple3Monoid[A1, A2, A3] {
implicit def _1 : Group[A1]
implicit def _2 : Group[A2]
implicit def _3 : Group[A3]
def inverse(f: LazyTuple3[A1, A2, A3]) = LazyTuple3(_1.inverse(f._1), _2.inverse(f._2), _3.inverse(f._3))
}
private[scalaz] trait LazyTuple4Group[A1, A2, A3, A4] extends Group[LazyTuple4[A1, A2, A3, A4]] with LazyTuple4Monoid[A1, A2, A3, A4] {
implicit def _1 : Group[A1]
implicit def _2 : Group[A2]
implicit def _3 : Group[A3]
implicit def _4 : Group[A4]
def inverse(f: LazyTuple4[A1, A2, A3, A4]) = lazyTuple4(_1.inverse(f._1), _2.inverse(f._2), _3.inverse(f._3), _4.inverse(f._4))
}


// LazyTupleN forms a Monad if the element types other than the last are Monoids.

private[scalaz] trait LazyTuple2Monad[A1] extends Monad[({type f[x] = LazyTuple2[A1, x]})#f] with LazyTuple2Functor[A1] {
Expand Down
9 changes: 0 additions & 9 deletions core/src/main/scala/scalaz/State.scala
Expand Up @@ -32,13 +32,4 @@ trait StateFunctions extends IndexedStateFunctions {
val r = f(s);
(r, ())
})

/**
* Computes the difference between the current and previous values of `a`
*/
def delta[A](a: A)(implicit A: Group[A]): State[A, A] = State{
(prevA) =>
val diff = A.minus(a, prevA)
(diff, a)
}
}
1 change: 0 additions & 1 deletion core/src/main/scala/scalaz/package.scala
Expand Up @@ -16,7 +16,6 @@
*
* - [[scalaz.Semigroup]]
* - [[scalaz.Monoid]] extends [[scalaz.Semigroup]]
* - [[scalaz.Group]] extends [[scalaz.Monoid]]
* - [[scalaz.Equal]]
* - [[scalaz.Length]]
* - [[scalaz.Show]]
Expand Down
32 changes: 8 additions & 24 deletions core/src/main/scala/scalaz/std/AnyVal.scala
Expand Up @@ -6,15 +6,13 @@ import Id._

trait AnyValInstances {

implicit val unitInstance: Group[Unit] with Enum[Unit] with Show[Unit] = new Group[Unit] with Enum[Unit] with Show[Unit] {
implicit val unitInstance: Monoid[Unit] with Enum[Unit] with Show[Unit] = new Monoid[Unit] with Enum[Unit] with Show[Unit] {
override def shows(f: Unit) = ().toString

def append(f1: Unit, f2: => Unit) = ()

def zero = ()

def inverse(f:Unit) = ()

def order(x: Unit, y: Unit) = Ordering.EQ

def succ(u: Unit) = ()
Expand Down Expand Up @@ -227,15 +225,13 @@ trait AnyValInstances {
override def equalIsNatural: Boolean = true
}

implicit val shortInstance: Group[Short] with Enum[Short] with Show[Short] = new Group[Short] with Enum[Short] with Show[Short] {
implicit val shortInstance: Monoid[Short] with Enum[Short] with Show[Short] = new Monoid[Short] with Enum[Short] with Show[Short] {
override def shows(f: Short) = f.toString

def append(f1: Short, f2: => Short) = (f1 + f2).toShort

def zero: Short = 0

def inverse(f:Short) = (-f).toShort

def order(x: Short, y: Short) = if (x < y) Ordering.LT else if (x == y) Ordering.EQ else Ordering.GT

def succ(b: Short) = (b + 1).toShort
Expand Down Expand Up @@ -275,15 +271,13 @@ trait AnyValInstances {
def order(a1: Short @@ Multiplication, a2: Short @@ Multiplication) = Order[Short].order(a1, a2)
}

implicit val intInstance: Group[Int] with Enum[Int] with Show[Int] = new Group[Int] with Enum[Int] with Show[Int] {
implicit val intInstance: Monoid[Int] with Enum[Int] with Show[Int] = new Monoid[Int] with Enum[Int] with Show[Int] {
override def shows(f: Int) = f.toString

def append(f1: Int, f2: => Int) = f1 + f2

def zero: Int = 0

def inverse(f:Int) = -f

def order(x: Int, y: Int) = if (x < y) Ordering.LT else if (x == y) Ordering.EQ else Ordering.GT

def succ(b: Int) = b + 1
Expand Down Expand Up @@ -327,15 +321,13 @@ trait AnyValInstances {
def order(a1: Int @@ Multiplication, a2: Int @@ Multiplication) = Order[Int].order(a1, a2)
}

implicit val longInstance: Group[Long] with Enum[Long] with Show[Long] = new Group[Long] with Enum[Long] with Show[Long] {
implicit val longInstance: Monoid[Long] with Enum[Long] with Show[Long] = new Monoid[Long] with Enum[Long] with Show[Long] {
override def shows(f: Long) = f.toString

def append(f1: Long, f2: => Long) = f1 + f2

def zero: Long = 0L

def inverse(f: Long) = -f

def order(x: Long, y: Long) = if (x < y) Ordering.LT else if (x == y) Ordering.EQ else Ordering.GT

def succ(b: Long) = b + 1
Expand Down Expand Up @@ -375,49 +367,41 @@ trait AnyValInstances {
def order(a1: Long @@ Multiplication, a2: Long @@ Multiplication) = Order[Long].order(a1, a2)
}

implicit val floatInstance: Group[Float] with Order[Float] with Show[Float] = new Group[Float] with Order[Float] with Show[Float] {
implicit val floatInstance: Monoid[Float] with Order[Float] with Show[Float] = new Monoid[Float] with Order[Float] with Show[Float] {
override def shows(f: Float) = f.toString

def append(f1: Float, f2: => Float) = f1 + f2

def zero: Float = 0f

def inverse(f: Float) = -f

override def equalIsNatural: Boolean = true

def order(x: Float, y: Float) = if (x < y) Ordering.LT else if (x == y) Ordering.EQ else Ordering.GT
}

implicit val floatMultiplicationNewType: Group[Float @@ Multiplication] = new Group[Float @@ Multiplication] {
implicit val floatMultiplicationNewType: Semigroup[Float @@ Multiplication] = new Semigroup[Float @@ Multiplication] {
def append(f1: Float @@ Multiplication, f2: => Float @@ Multiplication) = Multiplication(f1 * f2)

def zero: Float @@ Multiplication = Multiplication(1.0f)

def inverse(f: Float @@ Multiplication) = Multiplication(1.0f/f)

}

implicit val doubleInstance: Group[Double] with Order[Double] with Show[Double] = new Group[Double] with Order[Double] with Show[Double] {
implicit val doubleInstance: Monoid[Double] with Order[Double] with Show[Double] = new Monoid[Double] with Order[Double] with Show[Double] {
override def shows(f: Double) = f.toString

def append(f1: Double, f2: => Double) = f1 + f2

def zero: Double = 0d

def inverse(f: Double) = -f

override def equalIsNatural: Boolean = true

def order(x: Double, y: Double) = if (x < y) Ordering.LT else if (x == y) Ordering.EQ else Ordering.GT
}

implicit val doubleMultiplicationNewType: Group[Double @@ Multiplication] = new Group[Double @@ Multiplication] {
implicit val doubleMultiplicationNewType: Semigroup[Double @@ Multiplication] = new Semigroup[Double @@ Multiplication] {
def append(f1: Double @@ Multiplication, f2: => Double @@ Multiplication) = Multiplication(f1 * f2)

def zero: Double @@ Multiplication = Multiplication(1.0d)

def inverse(f: Double @@ Multiplication) = Multiplication(1.0d/f)
}
}

Expand Down
9 changes: 0 additions & 9 deletions core/src/main/scala/scalaz/std/Function.scala
Expand Up @@ -85,10 +85,6 @@ trait FunctionInstances extends FunctionInstances0 {
implicit def function1Contravariant[R] = new Contravariant[({type l[a] = (a => R)})#l] {
def contramap[A, B](r: (A) => R)(f: (B) => A) = r compose f
}

implicit def function1Group[A, R](implicit R0: Group[R]) = new Function1Group[A, R] {
implicit def R: Group[R] = R0
}

implicit def function2Instance[T1, T2] = new Monad[({type l[a] = ((T1, T2) => a)})#l] {
def point[A](a: => A) = (t1, t2) => a
Expand Down Expand Up @@ -157,8 +153,3 @@ trait Function1Comonad[M, R] extends Comonad[({type λ[α]=(M => α)})#λ] {
def cobind[A, B](fa: (M) => A)(f: ((M) => A) => B) = (m1: M) => f((m2: M) => fa(M.append(m1, m2)))
def map[A, B](fa: (M) => A)(f: (A) => B) = fa andThen f
}

trait Function1Group[A, R] extends Group[A => R] with Function1Monoid[A, R] {
implicit def R: Group[R]
def inverse(f: A=>R) = a => R.inverse(f(a))
}