scalaz/scalaz — pull request #114 by folone (2012-07-31 10:15:21+00:00)
Title: Fixed Validation's Semigroup instance.

#103 got polluted with unnecessary commits, so I decided to create a new pull request and close that one. Here's what this is for (from #101):

I've noticed, that `Validation`'s `Semigroup` instance requires that only the left (`Failure`) element is a `Semigroup`. At the same time, `Validation` itself has an `append` method, which requires both elements to be `Semigroups`. I've changed the default instance to use that method. The old definition is still used to generate `FailProjection`'s `Semigroup` instance and is renamed to `validationSemigroupFail`. Here's how this works now:

```scala
scala> val success1 = 1.success[String]
success1: scalaz.Validation[String,Int] = Success(1)

scala> val success2 = 2.success[String]
success2: scalaz.Validation[String,Int] = Success(2)

scala> val success3 = 1.success[String].fail
success3: scalaz.FailProjection[String,Int] = scalaz.Validation$$anon$18@59bdcda

scala> val success4 = 2.success[String].fail
success4: scalaz.FailProjection[String,Int] = scalaz.Validation$$anon$18@655554a8

scala> success1 |+| success2
res0: scalaz.Validation[String,Int] = Success(3) // was: Success(1)

scala> success3 |+| success4
res1: scalaz.FailProjection[String,Int] = scalaz.Validation$$anon$18@5f6bfe9c

scala> .validation
res2: scalaz.Validation[String,Int] = Success(1)
```

Does this make sense?

**P.S.** [Does not](http://travis-ci.org/#!/folone/scalaz/builds/1998964) break the build.