Skip to content

Commit

Permalink
IList groupBy uses NonEmptyList instead of IList
Browse files Browse the repository at this point in the history
  • Loading branch information
adelbertc committed Jun 10, 2015
1 parent e8dc3f1 commit b6e2fb6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/src/main/scala/scalaz/IList.scala
Expand Up @@ -152,9 +152,9 @@ sealed abstract class IList[A] extends Product with Serializable {

// no forall; use Foldable#all

def groupBy[K](f: A => K)(implicit ev: Order[K]): K ==>> IList[A] =
foldLeft(==>>.empty[K, IList[A]]) { (m, a) =>
m.alter(f(a), _.map(a :: _) orElse Some(single(a)))
def groupBy[K](f: A => K)(implicit ev: Order[K]): K ==>> NonEmptyList[A] =
foldLeft(==>>.empty[K, NonEmptyList[A]]) { (m, a) =>
m.alter(f(a), _.map(a <:: _) orElse Some(NonEmptyList(a)))
} .map(_.reverse) // should we bother with this? we don't do it for groupBy1

def groupBy1[K](f: A => K)(implicit ev: Order[K]): K ==>> OneAnd[IList, A] =
Expand Down

0 comments on commit b6e2fb6

Please sign in to comment.